mirror of
https://github.com/postgres/postgres.git
synced 2025-05-24 00:03:23 -04:00
We store Cash/money as int of size 4, so make it an int rather than a long.
This commit is contained in:
parent
7515bb484e
commit
021778eed3
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.21 1997/08/22 00:02:08 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.22 1997/08/22 07:12:45 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -196,7 +196,7 @@ parser_typecast(Value *expr, TypeName *typename, int typlen)
|
|||||||
case T_Integer:
|
case T_Integer:
|
||||||
const_string = (char *) palloc(256);
|
const_string = (char *) palloc(256);
|
||||||
string_palloced = true;
|
string_palloced = true;
|
||||||
sprintf(const_string, "%ld", expr->val.ival);
|
sprintf(const_string, "%d", expr->val.ival);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
elog(WARN,
|
elog(WARN,
|
||||||
@ -242,7 +242,7 @@ parser_typecast(Value *expr, TypeName *typename, int typlen)
|
|||||||
case CASHOID: /* money */
|
case CASHOID: /* money */
|
||||||
const_string = (char *) palloc(256);
|
const_string = (char *) palloc(256);
|
||||||
string_palloced = true;
|
string_palloced = true;
|
||||||
sprintf(const_string,"%ld",
|
sprintf(const_string,"%d",
|
||||||
(int) ((Const*)expr)->constvalue);
|
(int) ((Const*)expr)->constvalue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ parser_typecast2(Node *expr, Oid exprType, Type tp, int typlen)
|
|||||||
case CASHOID: /* money */
|
case CASHOID: /* money */
|
||||||
const_string = (char *) palloc(256);
|
const_string = (char *) palloc(256);
|
||||||
string_palloced = true;
|
string_palloced = true;
|
||||||
sprintf(const_string,"%ld",
|
sprintf(const_string,"%d",
|
||||||
(long) ((Const*)expr)->constvalue);
|
(long) ((Const*)expr)->constvalue);
|
||||||
break;
|
break;
|
||||||
case TEXTOID: /* text */
|
case TEXTOID: /* text */
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
* Written by D'Arcy J.M. Cain
|
* Written by D'Arcy J.M. Cain
|
||||||
*
|
*
|
||||||
* Functions to allow input and output of money normally but store
|
* Functions to allow input and output of money normally but store
|
||||||
* and handle it as longs
|
* and handle it as int4s
|
||||||
*
|
*
|
||||||
* A slightly modified version of this file and a discussion of the
|
* A slightly modified version of this file and a discussion of the
|
||||||
* workings can be found in the book "Software Solutions in C" by
|
* workings can be found in the book "Software Solutions in C" by
|
||||||
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
|
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.8 1997/08/21 23:56:37 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.9 1997/08/22 07:12:52 momjian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -97,7 +97,7 @@ cash_in(const char *str)
|
|||||||
while (isspace(*s) || *s == csymbol) s++;
|
while (isspace(*s) || *s == csymbol) s++;
|
||||||
|
|
||||||
for (; ; s++) {
|
for (; ; s++) {
|
||||||
/* we look for digits as long as we have less */
|
/* we look for digits as int4 as we have less */
|
||||||
/* than the required number of decimal places */
|
/* than the required number of decimal places */
|
||||||
if (isdigit(*s) && dec < fpoint) {
|
if (isdigit(*s) && dec < fpoint) {
|
||||||
value = (value * 10) + *s - '0';
|
value = (value * 10) + *s - '0';
|
||||||
@ -421,7 +421,7 @@ cashsmaller(Cash *c1, Cash *c2)
|
|||||||
|
|
||||||
|
|
||||||
/* cash_words_out()
|
/* cash_words_out()
|
||||||
* This converts a long as well but to a representation using words
|
* This converts a int4 as well but to a representation using words
|
||||||
* Obviously way North American centric - sorry
|
* Obviously way North American centric - sorry
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
* Written by D'Arcy J.M. Cain
|
* Written by D'Arcy J.M. Cain
|
||||||
*
|
*
|
||||||
* Functions to allow input and output of money normally but store
|
* Functions to allow input and output of money normally but store
|
||||||
* and handle it as long integers.
|
* and handle it as int4.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CASH_H
|
#ifndef CASH_H
|
||||||
#define CASH_H
|
#define CASH_H
|
||||||
|
|
||||||
typedef long int Cash;
|
/* if we store this as 4 bytes, we better make it int, not long, bjm */
|
||||||
|
typedef signed int Cash;
|
||||||
|
|
||||||
extern const char *cash_out(Cash *value);
|
extern const char *cash_out(Cash *value);
|
||||||
extern Cash *cash_in(const char *str);
|
extern Cash *cash_in(const char *str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user