Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit021778e

Browse files
committed
We store Cash/money as int of size 4, so make it an int rather than a long.
1 parent7515bb4 commit021778e

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

‎src/backend/parser/parser.c

Lines changed: 4 additions & 4 deletions
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/2200:02:08 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.22 1997/08/2207:12:45 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -196,7 +196,7 @@ parser_typecast(Value *expr, TypeName *typename, int typlen)
196196
caseT_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
caseCASHOID:/* 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
caseCASHOID:/* 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
caseTEXTOID:/* text */

‎src/backend/utils/adt/cash.c

Lines changed: 4 additions & 4 deletions
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 aslongs
6+
* and handle it asint4s
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 aslong as we have less */
100+
/* we look for digits asint4 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 along as well but to a representation using words
424+
* This converts aint4 as well but to a representation using words
425425
* Obviously way North American centric - sorry
426426
*/
427427
constchar*

‎src/include/utils/cash.h

Lines changed: 3 additions & 2 deletions
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 aslong integers.
6+
* and handle it asint4.
77
*/
88

99
#ifndefCASH_H
1010
#defineCASH_H
1111

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

1415
externconstchar*cash_out(Cash*value);
1516
externCash*cash_in(constchar*str);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp