Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 021778e

Browse files
committed
We store Cash/money as int of size 4, so make it an int rather than a long.
1 parent 7515bb4 commit 021778e

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/backend/parser/parser.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.21 1997/08/22 00:02:08 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.22 1997/08/22 07:12:45 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -196,7 +196,7 @@ parser_typecast(Value *expr, TypeName *typename, int typlen)
196196
case T_Integer:
197197
const_string = (char *) palloc(256);
198198
string_palloced = true;
199-
sprintf(const_string, "%ld", expr->val.ival);
199+
sprintf(const_string, "%d", expr->val.ival);
200200
break;
201201
default:
202202
elog(WARN,
@@ -242,7 +242,7 @@ parser_typecast(Value *expr, TypeName *typename, int typlen)
242242
case CASHOID: /* money */
243243
const_string = (char *) palloc(256);
244244
string_palloced = true;
245-
sprintf(const_string,"%ld",
245+
sprintf(const_string,"%d",
246246
(int) ((Const*)expr)->constvalue);
247247
break;
248248

@@ -360,7 +360,7 @@ parser_typecast2(Node *expr, Oid exprType, Type tp, int typlen)
360360
case CASHOID: /* money */
361361
const_string = (char *) palloc(256);
362362
string_palloced = true;
363-
sprintf(const_string,"%ld",
363+
sprintf(const_string,"%d",
364364
(long) ((Const*)expr)->constvalue);
365365
break;
366366
case TEXTOID: /* text */

src/backend/utils/adt/cash.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* Written by D'Arcy J.M. Cain
44
*
55
* Functions to allow input and output of money normally but store
6-
* and handle it as longs
6+
* and handle it as int4s
77
*
88
* A slightly modified version of this file and a discussion of the
99
* workings can be found in the book "Software Solutions in C" by
1010
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
1111
*
12-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.8 1997/08/21 23:56:37 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.9 1997/08/22 07:12:52 momjian Exp $
1313
*/
1414

1515
#include <stdio.h>
@@ -97,7 +97,7 @@ cash_in(const char *str)
9797
while (isspace(*s) || *s == csymbol) s++;
9898

9999
for (; ; s++) {
100-
/* we look for digits as long as we have less */
100+
/* we look for digits as int4 as we have less */
101101
/* than the required number of decimal places */
102102
if (isdigit(*s) && dec < fpoint) {
103103
value = (value * 10) + *s - '0';
@@ -421,7 +421,7 @@ cashsmaller(Cash *c1, Cash *c2)
421421

422422

423423
/* cash_words_out()
424-
* This converts a long as well but to a representation using words
424+
* This converts a int4 as well but to a representation using words
425425
* Obviously way North American centric - sorry
426426
*/
427427
const char *

src/include/utils/cash.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* Written by D'Arcy J.M. Cain
44
*
55
* Functions to allow input and output of money normally but store
6-
* and handle it as long integers.
6+
* and handle it as int4.
77
*/
88

99
#ifndef CASH_H
1010
#define CASH_H
1111

12-
typedef long int Cash;
12+
/* if we store this as 4 bytes, we better make it int, not long, bjm */
13+
typedef signed int Cash;
1314

1415
extern const char *cash_out(Cash *value);
1516
extern Cash *cash_in(const char *str);

0 commit comments

Comments
 (0)