diff options
author | Michael Meskes <meskes@postgresql.org> | 2003-07-01 12:40:52 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2003-07-01 12:40:52 +0000 |
commit | 2bdd2e5dcff20e4cf5987c901a71b794808d582b (patch) | |
tree | e158aaeb7ac2ab4db9e2e738e6be2aefa9cf4a50 /src/interfaces/ecpg/include | |
parent | f973b74583c24e28ff8977d0fdd455474705604a (diff) | |
download | postgresql-2bdd2e5dcff20e4cf5987c901a71b794808d582b.tar.gz postgresql-2bdd2e5dcff20e4cf5987c901a71b794808d582b.zip |
Use ISO dates in pgtypeslib by default.
Applied patch by Philip Yarra to fix some thread issues.
Added a new data type "decimal" which is mostly the same as our
"numeric" but uses a fixed length array to store the digits. This is
for compatibility with Informix and maybe others.
Diffstat (limited to 'src/interfaces/ecpg/include')
-rw-r--r-- | src/interfaces/ecpg/include/decimal.h | 2 | ||||
-rw-r--r-- | src/interfaces/ecpg/include/ecpgtype.h | 4 | ||||
-rw-r--r-- | src/interfaces/ecpg/include/pgtypes_numeric.h | 16 | ||||
-rw-r--r-- | src/interfaces/ecpg/include/sqltypes.h | 2 |
4 files changed, 19 insertions, 5 deletions
diff --git a/src/interfaces/ecpg/include/decimal.h b/src/interfaces/ecpg/include/decimal.h index acbb758814a..e0cb06bd5c8 100644 --- a/src/interfaces/ecpg/include/decimal.h +++ b/src/interfaces/ecpg/include/decimal.h @@ -1,7 +1,7 @@ #include <pgtypes_numeric.h> #ifndef dec_t -#define dec_t Numeric +#define dec_t Decimal #endif /* dec_t */ int decadd(dec_t *, dec_t *, dec_t *); diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h index 94899413da5..7a299d0be89 100644 --- a/src/interfaces/ecpg/include/ecpgtype.h +++ b/src/interfaces/ecpg/include/ecpgtype.h @@ -44,8 +44,8 @@ enum ECPGttype ECPGt_bool, ECPGt_float, ECPGt_double, ECPGt_varchar, ECPGt_varchar2, - ECPGt_numeric, - ECPGt_decimal, /* only used internally */ + ECPGt_numeric, /* this is a decimal that stores its digits in a malloced array */ + ECPGt_decimal, /* this is a decimal that stores its digits in a fixed array */ ECPGt_date, ECPGt_timestamp, ECPGt_interval, diff --git a/src/interfaces/ecpg/include/pgtypes_numeric.h b/src/interfaces/ecpg/include/pgtypes_numeric.h index cd7552db384..28b902f290d 100644 --- a/src/interfaces/ecpg/include/pgtypes_numeric.h +++ b/src/interfaces/ecpg/include/pgtypes_numeric.h @@ -9,6 +9,8 @@ #define NUMERIC_MIN_DISPLAY_SCALE 0 #define NUMERIC_MIN_SIG_DIGITS 16 +#define DECSIZE 30 + typedef unsigned char NumericDigit; typedef struct { @@ -21,7 +23,17 @@ typedef struct NumericDigit *digits; /* decimal digits */ } Numeric; -Numeric *PGTYPESnew(void); +typedef struct +{ + int ndigits; /* number of digits in digits[] - can be 0! */ + int weight; /* weight of first digit */ + int rscale; /* result scale */ + int dscale; /* display scale */ + int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */ + NumericDigit digits[DECSIZE]; /* decimal digits */ +} Decimal; + +Numeric *PGTYPESnumeric_new(void); void PGTYPESnumeric_free(Numeric *); Numeric *PGTYPESnumeric_from_asc(char *, char **); char *PGTYPESnumeric_to_asc(Numeric *, int); @@ -37,5 +49,7 @@ int PGTYPESnumeric_from_double(double, Numeric *); int PGTYPESnumeric_to_double(Numeric *, double *); int PGTYPESnumeric_to_int(Numeric *, int *); int PGTYPESnumeric_to_long(Numeric *, long *); +int PGTYPESnumeric_to_decimal(Numeric *, Decimal *); +int PGTYPESnumeric_from_decimal(Decimal *, Numeric *); #endif /* PGTYPES_NUMERIC */ diff --git a/src/interfaces/ecpg/include/sqltypes.h b/src/interfaces/ecpg/include/sqltypes.h index e6a96bcf48d..c50bf54314b 100644 --- a/src/interfaces/ecpg/include/sqltypes.h +++ b/src/interfaces/ecpg/include/sqltypes.h @@ -4,7 +4,7 @@ #define CLONGTYPE ECPGt_long #define CFLOATTYPE ECPGt_float #define CDOUBLETYPE ECPGt_double -#define CDECIMALTYPE ECPGt_numeric +#define CDECIMALTYPE ECPGt_decimal #define CFIXCHARTYPE 108 #define CSTRINGTYPE ECPGt_char #define CDATETYPE ECPGt_date |