- Added Dave patch for Informix handling of numeric/int conversion.
authorMichael Meskes
Tue, 9 Sep 2003 10:46:42 +0000 (10:46 +0000)
committerMichael Meskes
Tue, 9 Sep 2003 10:46:42 +0000 (10:46 +0000)
- Changed all new datatypes to lowercase.
- Fixed rounding bug in numerical types.

22 files changed:
src/interfaces/ecpg/compatlib/informix.c
src/interfaces/ecpg/ecpglib/data.c
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/misc.c
src/interfaces/ecpg/ecpglib/typename.c
src/interfaces/ecpg/include/datetime.h
src/interfaces/ecpg/include/decimal.h
src/interfaces/ecpg/include/pgtypes_date.h
src/interfaces/ecpg/include/pgtypes_interval.h
src/interfaces/ecpg/include/pgtypes_numeric.h
src/interfaces/ecpg/include/pgtypes_timestamp.h
src/interfaces/ecpg/pgtypeslib/datetime.c
src/interfaces/ecpg/pgtypeslib/dt.h
src/interfaces/ecpg/pgtypeslib/dt_common.c
src/interfaces/ecpg/pgtypeslib/interval.c
src/interfaces/ecpg/pgtypeslib/numeric.c
src/interfaces/ecpg/pgtypeslib/timestamp.c
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/type.c
src/interfaces/ecpg/test/dt_test.pgc
src/interfaces/ecpg/test/num_test.pgc

index 15101094f58de9c1a0779e50320287dec922fd54..c7017e286d9580494525b4934e5144428f89c857 100644 (file)
@@ -13,9 +13,9 @@
 char      *ECPGalloc(long, int);
 
 static int
-deccall2(Decimal * arg1, Decimal * arg2, int (*ptr) (Numeric *, Numeric *))
+deccall2(decimal * arg1, decimal * arg2, int (*ptr) (numeric *, numeric *))
 {
-   Numeric    *a1,
+   numeric    *a1,
               *a2;
    int         i;
 
@@ -51,9 +51,9 @@ deccall2(Decimal * arg1, Decimal * arg2, int (*ptr) (Numeric *, Numeric *))
 }
 
 static int
-deccall3(Decimal * arg1, Decimal * arg2, Decimal * result, int (*ptr) (Numeric *, Numeric *, Numeric *))
+deccall3(decimal * arg1, decimal * arg2, decimal * result, int (*ptr) (numeric *, numeric *, numeric *))
 {
-   Numeric    *a1,
+   numeric    *a1,
               *a2,
               *nres;
    int         i;
@@ -110,7 +110,7 @@ deccall3(Decimal * arg1, Decimal * arg2, Decimal * result, int (*ptr) (Numeric *
 
 /* we start with the numeric functions */
 int
-decadd(Decimal * arg1, Decimal * arg2, Decimal * sum)
+decadd(decimal * arg1, decimal * arg2, decimal * sum)
 {
    deccall3(arg1, arg2, sum, PGTYPESnumeric_add);
 
@@ -123,15 +123,15 @@ decadd(Decimal * arg1, Decimal * arg2, Decimal * sum)
 }
 
 int
-deccmp(Decimal * arg1, Decimal * arg2)
+deccmp(decimal * arg1, decimal * arg2)
 {
    return (deccall2(arg1, arg2, PGTYPESnumeric_cmp));
 }
 
 void
-deccopy(Decimal * src, Decimal * target)
+deccopy(decimal * src, decimal * target)
 {
-   memcpy(target, src, sizeof(Decimal));
+   memcpy(target, src, sizeof(decimal));
 }
 
 static char *
@@ -154,12 +154,12 @@ strndup(const char *str, size_t len)
 }
 
 int
-deccvasc(char *cp, int len, Decimal * np)
+deccvasc(char *cp, int len, decimal * np)
 {
-   char       *str = strndup(cp, len); /* Decimal_in always converts the
+   char       *str = strndup(cp, len); /* decimal_in always converts the
                                         * complete string */
    int         ret = 0;
-   Numeric    *result;
+   numeric    *result;
 
    if (risnull(CSTRINGTYPE, cp))
    {
@@ -201,9 +201,9 @@ deccvasc(char *cp, int len, Decimal * np)
 }
 
 int
-deccvdbl(double dbl, Decimal * np)
+deccvdbl(double dbl, decimal * np)
 {
-   Numeric    *nres = PGTYPESnumeric_new();
+   numeric    *nres = PGTYPESnumeric_new();
    int         result = 1;
 
    if (risnull(CDOUBLETYPE, (char *) &dbl))
@@ -224,9 +224,9 @@ deccvdbl(double dbl, Decimal * np)
 }
 
 int
-deccvint(int in, Decimal * np)
+deccvint(int in, decimal * np)
 {
-   Numeric    *nres = PGTYPESnumeric_new();
+   numeric    *nres = PGTYPESnumeric_new();
    int         result = 1;
 
    if (risnull(CINTTYPE, (char *) &in))
@@ -247,9 +247,9 @@ deccvint(int in, Decimal * np)
 }
 
 int
-deccvlong(long lng, Decimal * np)
+deccvlong(long lng, decimal * np)
 {
-   Numeric    *nres = PGTYPESnumeric_new();
+   numeric    *nres = PGTYPESnumeric_new();
    int         result = 1;
 
    if (risnull(CLONGTYPE, (char *) &lng))
@@ -270,7 +270,7 @@ deccvlong(long lng, Decimal * np)
 }
 
 int
-decdiv(Decimal * n1, Decimal * n2, Decimal * n3)
+decdiv(decimal * n1, decimal * n2, decimal * n3)
 {
    int         i = deccall3(n1, n2, n3, PGTYPESnumeric_div);
 
@@ -292,7 +292,7 @@ decdiv(Decimal * n1, Decimal * n2, Decimal * n3)
 }
 
 int
-decmul(Decimal * n1, Decimal * n2, Decimal * n3)
+decmul(decimal * n1, decimal * n2, decimal * n3)
 {
    int         i = deccall3(n1, n2, n3, PGTYPESnumeric_mul);
 
@@ -311,7 +311,7 @@ decmul(Decimal * n1, Decimal * n2, Decimal * n3)
 }
 
 int
-decsub(Decimal * n1, Decimal * n2, Decimal * n3)
+decsub(decimal * n1, decimal * n2, decimal * n3)
 {
    int         i = deccall3(n1, n2, n3, PGTYPESnumeric_sub);
 
@@ -330,10 +330,10 @@ decsub(Decimal * n1, Decimal * n2, Decimal * n3)
 }
 
 int
-dectoasc(Decimal * np, char *cp, int len, int right)
+dectoasc(decimal * np, char *cp, int len, int right)
 {
    char       *str;
-   Numeric    *nres = PGTYPESnumeric_new();
+   numeric    *nres = PGTYPESnumeric_new();
 
    if (nres == NULL)
        return -1211;
@@ -367,9 +367,9 @@ dectoasc(Decimal * np, char *cp, int len, int right)
 }
 
 int
-dectodbl(Decimal * np, double *dblp)
+dectodbl(decimal * np, double *dblp)
 {
-   Numeric    *nres = PGTYPESnumeric_new();
+   numeric    *nres = PGTYPESnumeric_new();
    int         i;
 
    if (nres == NULL)
@@ -385,10 +385,10 @@ dectodbl(Decimal * np, double *dblp)
 }
 
 int
-dectoint(Decimal * np, int *ip)
+dectoint(decimal * np, int *ip)
 {
    int         ret;
-   Numeric    *nres = PGTYPESnumeric_new();
+   numeric    *nres = PGTYPESnumeric_new();
 
    if (nres == NULL)
        return -1211;
@@ -405,10 +405,10 @@ dectoint(Decimal * np, int *ip)
 }
 
 int
-dectolong(Decimal * np, long *lngp)
+dectolong(decimal * np, long *lngp)
 {
    int         ret;
-   Numeric    *nres = PGTYPESnumeric_new();;
+   numeric    *nres = PGTYPESnumeric_new();;
 
    if (nres == NULL)
        return -1211;
@@ -529,15 +529,15 @@ rdayofweek(Date d)
 /* And the datetime stuff */
 
 void
-dtcurrent(Timestamp *ts)
+dtcurrent(timestamp *ts)
 {
    PGTYPEStimestamp_current(ts);
 }
 
 int
-dtcvasc(char *str, Timestamp *ts)
+dtcvasc(char *str, timestamp *ts)
 {
-   Timestamp   ts_tmp;
+   timestamp   ts_tmp;
    int         i;
    char      **endptr = &str;
 
@@ -558,13 +558,13 @@ dtcvasc(char *str, Timestamp *ts)
 }
 
 int
-dtsub(Timestamp *ts1, Timestamp *ts2, Interval *iv)
+dtsub(timestamp *ts1, timestamp *ts2, interval *iv)
 {
    return PGTYPEStimestamp_sub(ts1, ts2, iv);
 }
 
 int
-dttoasc(Timestamp *ts, char *output)
+dttoasc(timestamp *ts, char *output)
 {
    char       *asctime = PGTYPEStimestamp_to_asc(*ts);
 
@@ -574,13 +574,13 @@ dttoasc(Timestamp *ts, char *output)
 }
 
 int
-dttofmtasc(Timestamp *ts, char *output, int str_len, char *fmtstr)
+dttofmtasc(timestamp *ts, char *output, int str_len, char *fmtstr)
 {
    return PGTYPEStimestamp_fmt_asc(ts, output, str_len, fmtstr);
 }
 
 int
-intoasc(Interval *i, char *str)
+intoasc(interval *i, char *str)
 {
    str = PGTYPESinterval_to_asc(i);
 
index e095ed671d35bf75e62775659899aa91c42c63da..4bfcb128ba41989f0750e4aae947bde8a86e6d0c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.16 2003/08/04 00:43:32 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.17 2003/09/09 10:46:37 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -115,10 +115,10 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                unsigned long ures;
                double      dres;
                char       *scan_length;
-               Numeric    *nres;
-               Date        ddres;
-               Timestamp   tres;
-               Interval   *ires;
+               numeric    *nres;
+               date        ddres;
+               timestamp   tres;
+               interval   *ires;
 
            case ECPGt_short:
            case ECPGt_int:
@@ -126,8 +126,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                if (pval)
                {
                    res = strtol(pval, &scan_length, 10);
+                   /* INFORMIX allows for selecting a numeric into an int, the result is truncated */
                    if ((isarray && *scan_length != ',' && *scan_length != '}')
-                       || (!isarray && *scan_length != '\0' && *scan_length != ' '))   /* Garbage left */
+                       || (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' '))    /* Garbage left */
                    {
                        ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
                        return (false);
@@ -160,7 +161,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                {
                    ures = strtoul(pval, &scan_length, 10);
                    if ((isarray && *scan_length != ',' && *scan_length != '}')
-                       || (!isarray && *scan_length != '\0' && *scan_length != ' '))   /* Garbage left */
+                       || (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' '))    /* Garbage left */
                    {
                        ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
                        return (false);
@@ -193,7 +194,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                {
                    *((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
                    if ((isarray && *scan_length != ',' && *scan_length != '}')
-                       || (!isarray && *scan_length != '\0' && *scan_length != ' '))   /* Garbage left */
+                       || (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' '))    /* Garbage left */
                    {
                        ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
                        return (false);
@@ -210,7 +211,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                {
                    *((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
                    if ((isarray && *scan_length != ',' && *scan_length != '}')
-                       || (!isarray && *scan_length != '\0' && *scan_length != ' '))   /* Garbage left */
+                       || (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' '))    /* Garbage left */
                    {
                        ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
                        return (false);
@@ -403,9 +404,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                    nres = PGTYPESnumeric_from_asc("0.0", &scan_length);
 
                if (type == ECPGt_numeric)
-                   PGTYPESnumeric_copy(nres, (Numeric *) (var + offset * act_tuple));
+                   PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple));
                else
-                   PGTYPESnumeric_to_decimal(nres, (Decimal *) (var + offset * act_tuple));
+                   PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
                break;
 
            case ECPGt_interval:
@@ -429,7 +430,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                else
                    ires = PGTYPESinterval_from_asc("0 seconds", NULL);
 
-               PGTYPESinterval_copy(ires, (Interval *) (var + offset * act_tuple));
+               PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple));
                break;
            case ECPGt_date:
                if (pval)
@@ -449,7 +450,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                        return (false);
                    }
 
-                   *((Date *) (var + offset * act_tuple)) = ddres;
+                   *((date *) (var + offset * act_tuple)) = ddres;
                }
                break;
 
@@ -471,7 +472,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                        return (false);
                    }
 
-                   *((Timestamp *) (var + offset * act_tuple)) = tres;
+                   *((timestamp *) (var + offset * act_tuple)) = tres;
                }
                break;
 
index c45441d47cac9f777da861401928c5ebc09f50b5..6a6b4d8e465978feabc7f888c88e2585daa73f25 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.23 2003/08/04 00:43:32 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.24 2003/09/09 10:46:37 meskes Exp $ */
 
 /*
  * The aim is to get a simpler inteface to the database routines.
@@ -846,16 +846,16 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
                {
                    char       *str = NULL;
                    int         slen;
-                   Numeric    *nval = PGTYPESnumeric_new();
+                   numeric    *nval = PGTYPESnumeric_new();
 
                    if (var->arrsize > 1)
                    {
                        for (element = 0; element < var->arrsize; element++)
                        {
                            if (var->type == ECPGt_numeric)
-                               PGTYPESnumeric_copy((Numeric *) ((var + var->offset * element)->value), nval);
+                               PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);
                            else
-                               PGTYPESnumeric_from_decimal((Decimal *) ((var + var->offset * element)->value), nval);
+                               PGTYPESnumeric_from_decimal((decimal *) ((var + var->offset * element)->value), nval);
 
                            str = PGTYPESnumeric_to_asc(nval, 0);
                            PGTYPESnumeric_free(nval);
@@ -875,9 +875,9 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
                    else
                    {
                        if (var->type == ECPGt_numeric)
-                           PGTYPESnumeric_copy((Numeric *) (var->value), nval);
+                           PGTYPESnumeric_copy((numeric *) (var->value), nval);
                        else
-                           PGTYPESnumeric_from_decimal((Decimal *) (var->value), nval);
+                           PGTYPESnumeric_from_decimal((decimal *) (var->value), nval);
 
                        str = PGTYPESnumeric_to_asc(nval, 0);
 
@@ -906,7 +906,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
                    {
                        for (element = 0; element < var->arrsize; element++)
                        {
-                           str = quote_postgres(PGTYPESinterval_to_asc((Interval *) ((var + var->offset * element)->value)), stmt->lineno);
+                           str = quote_postgres(PGTYPESinterval_to_asc((interval *) ((var + var->offset * element)->value)), stmt->lineno);
                            slen = strlen(str);
 
                            if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],interval "), stmt->lineno)))
@@ -923,7 +923,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
                    }
                    else
                    {
-                       str = quote_postgres(PGTYPESinterval_to_asc((Interval *) (var->value)), stmt->lineno);
+                       str = quote_postgres(PGTYPESinterval_to_asc((interval *) (var->value)), stmt->lineno);
                        slen = strlen(str);
 
                        if (!(mallocedval = ECPGalloc(slen + sizeof("interval ") + 1, stmt->lineno)))
@@ -949,7 +949,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
                    {
                        for (element = 0; element < var->arrsize; element++)
                        {
-                           str = quote_postgres(PGTYPESdate_to_asc(*(Date *) ((var + var->offset * element)->value)), stmt->lineno);
+                           str = quote_postgres(PGTYPESdate_to_asc(*(date *) ((var + var->offset * element)->value)), stmt->lineno);
                            slen = strlen(str);
 
                            if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],date "), stmt->lineno)))
@@ -966,7 +966,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
                    }
                    else
                    {
-                       str = quote_postgres(PGTYPESdate_to_asc(*(Date *) (var->value)), stmt->lineno);
+                       str = quote_postgres(PGTYPESdate_to_asc(*(date *) (var->value)), stmt->lineno);
                        slen = strlen(str);
 
                        if (!(mallocedval = ECPGalloc(slen + sizeof("date ") + 1, stmt->lineno)))
@@ -992,7 +992,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
                    {
                        for (element = 0; element < var->arrsize; element++)
                        {
-                           str = quote_postgres(PGTYPEStimestamp_to_asc(*(Timestamp *) ((var + var->offset * element)->value)), stmt->lineno);
+                           str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) ((var + var->offset * element)->value)), stmt->lineno);
                            slen = strlen(str);
 
                            if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [], timestamp "), stmt->lineno)))
@@ -1009,7 +1009,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
                    }
                    else
                    {
-                       str = quote_postgres(PGTYPEStimestamp_to_asc(*(Timestamp *) (var->value)), stmt->lineno);
+                       str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) (var->value)), stmt->lineno);
                        slen = strlen(str);
 
                        if (!(mallocedval = ECPGalloc(slen + sizeof("timestamp") + 1, stmt->lineno)))
index 63d4d969b1557a1c27b8cec64cf6c76b50a248a2..bd144057cbe2b6ebd7ff90456769ff41b49362eb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.14 2003/08/08 13:17:58 petere Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.15 2003/09/09 10:46:37 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -294,18 +294,18 @@ ECPGset_informix_null(enum ECPGttype type, void *ptr)
            *(((struct ECPGgeneric_varchar *) ptr)->arr) = 0x00;
            break;
        case ECPGt_decimal:
-           memset((char *) ptr, 0, sizeof(Decimal));
-           ((Decimal *) ptr)->sign = NUMERIC_NAN;
+           memset((char *) ptr, 0, sizeof(decimal));
+           ((decimal *) ptr)->sign = NUMERIC_NAN;
            break;
        case ECPGt_numeric:
-           memset((char *) ptr, 0, sizeof(Numeric));
-           ((Numeric *) ptr)->sign = NUMERIC_NAN;
+           memset((char *) ptr, 0, sizeof(numeric));
+           ((numeric *) ptr)->sign = NUMERIC_NAN;
            break;
        case ECPGt_interval:
-           memset((char *) ptr, 0xff, sizeof(Interval));
+           memset((char *) ptr, 0xff, sizeof(interval));
            break;
        case ECPGt_timestamp:
-           memset((char *) ptr, 0xff, sizeof(Timestamp));
+           memset((char *) ptr, 0xff, sizeof(timestamp));
            break;
        default:
            break;
@@ -365,18 +365,18 @@ ECPGis_informix_null(enum ECPGttype type, void *ptr)
                return true;
            break;
        case ECPGt_decimal:
-           if (((Decimal *) ptr)->sign == NUMERIC_NAN)
+           if (((decimal *) ptr)->sign == NUMERIC_NAN)
                return true;
            break;
        case ECPGt_numeric:
-           if (((Numeric *) ptr)->sign == NUMERIC_NAN)
+           if (((numeric *) ptr)->sign == NUMERIC_NAN)
                return true;
            break;
        case ECPGt_interval:
-           return (_check(ptr, sizeof(Interval)));
+           return (_check(ptr, sizeof(interval)));
            break;
        case ECPGt_timestamp:
-           return (_check(ptr, sizeof(Timestamp)));
+           return (_check(ptr, sizeof(timestamp)));
            break;
        default:
            break;
index 752b4f6063ed760552c1e1b856d806e9b5ab0654..3a3dbd9a387235278e3a5b98dd6fe55d52f61068 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.8 2003/07/01 12:40:51 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/typename.c,v 1.9 2003/09/09 10:46:37 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -49,15 +49,15 @@ ECPGtype_name(enum ECPGttype typ)
        case ECPGt_char_variable:
            return "char";
        case ECPGt_decimal:
-           return "Decimal";
+           return "decimal";
        case ECPGt_numeric:
-           return "Numeric";
+           return "numeric";
        case ECPGt_date:
-           return "Date";
+           return "date";
        case ECPGt_timestamp:
-           return "Timestamp";
+           return "timestamp";
        case ECPGt_interval:
-           return "Interval";
+           return "interval";
        case ECPGt_const:
            return "Const";
        default:
index ed8f31dfc8a7757c219c90306f2d8e75415e1f07..db765cac23cf8e62e362d355380c5d485f203316 100644 (file)
@@ -2,11 +2,11 @@
 #include 
 
 #ifndef dtime_t
-#define dtime_t Timestamp
+#define dtime_t timestamp
 #endif   /* dtime_t */
 
 #ifndef intrvl_t
-#define intrvl_t Interval
+#define intrvl_t interval
 #endif   /* intrvl_t */
 
 extern void dtcurrent(dtime_t *);
index c68e253e68273d29a7fef147b634434da6eb6736..2531be38ef6874650abf31fd5d77b1374727a457 100644 (file)
@@ -1,7 +1,7 @@
 #include 
 
 #ifndef dec_t
-#define dec_t Decimal
+#define dec_t decimal
 #endif   /* dec_t */
 
 int            decadd(dec_t *, dec_t *, dec_t *);
index 391eeedce8c10b6f129e79b1485d8820d76213af..99fa9a8504f77e526a698798027f524d3cbf71f4 100644 (file)
@@ -3,16 +3,16 @@
 
 #include 
 
-#define Date long
+#define date long
 
-extern Date PGTYPESdate_from_asc(char *, char **);
-extern char *PGTYPESdate_to_asc(Date);
-extern Date PGTYPESdate_from_timestamp(Timestamp);
-extern void PGTYPESdate_julmdy(Date, int *);
-extern void PGTYPESdate_mdyjul(int *, Date *);
-extern int PGTYPESdate_dayofweek(Date);
-extern void PGTYPESdate_today(Date *);
-extern int PGTYPESdate_defmt_asc(Date *, char *, char *);
-extern int PGTYPESdate_fmt_asc(Date, char *, char *);
+extern date PGTYPESdate_from_asc(char *, char **);
+extern char *PGTYPESdate_to_asc(date);
+extern date PGTYPESdate_from_timestamp(timestamp);
+extern void PGTYPESdate_julmdy(date, int *);
+extern void PGTYPESdate_mdyjul(int *, date *);
+extern int PGTYPESdate_dayofweek(date);
+extern void PGTYPESdate_today(date *);
+extern int PGTYPESdate_defmt_asc(date *, char *, char *);
+extern int PGTYPESdate_fmt_asc(date, char *, char *);
 
 #endif   /* PGTYPES_DATETIME */
index 4e1fa6e10b27ab7edababd44800fbccf5dcf5972..98b29bcd80f2beb798544bc1be97dccd440e158b 100644 (file)
@@ -12,10 +12,10 @@ typedef struct
 #endif
    long        month;          /* months and years, after time for
                                 * alignment */
-} Interval;
+} interval;
 
-extern Interval *PGTYPESinterval_from_asc(char *, char **);
-extern char *PGTYPESinterval_to_asc(Interval *);
-extern int PGTYPESinterval_copy(Interval *, Interval *);
+extern interval *PGTYPESinterval_from_asc(char *, char **);
+extern char *PGTYPESinterval_to_asc(interval *);
+extern int PGTYPESinterval_copy(interval *, interval *);
 
 #endif   /* PGTYPES_INTERVAL */
index 55d2924e59332b48c7684cd4b82ee5aecdbeea7e..db4d02c2009fee078c8e0c462edaa0f84dab212a 100644 (file)
@@ -23,7 +23,7 @@ typedef struct
                                 * NUMERIC_NAN */
    NumericDigit *buf;          /* start of alloc'd space for digits[] */
    NumericDigit *digits;       /* decimal digits */
-} Numeric;
+} numeric;
 
 typedef struct
 {
@@ -35,25 +35,25 @@ typedef struct
    int         sign;           /* NUMERIC_POS, NUMERIC_NEG, or
                                 * NUMERIC_NAN */
    NumericDigit digits[DECSIZE];       /* decimal digits */
-}  Decimal;
+}  decimal;
 
-Numeric    *PGTYPESnumeric_new(void);
-void       PGTYPESnumeric_free(Numeric *);
-Numeric    *PGTYPESnumeric_from_asc(char *, char **);
-char      *PGTYPESnumeric_to_asc(Numeric *, int);
-int            PGTYPESnumeric_add(Numeric *, Numeric *, Numeric *);
-int            PGTYPESnumeric_sub(Numeric *, Numeric *, Numeric *);
-int            PGTYPESnumeric_mul(Numeric *, Numeric *, Numeric *);
-int            PGTYPESnumeric_div(Numeric *, Numeric *, Numeric *);
-int            PGTYPESnumeric_cmp(Numeric *, Numeric *);
-int            PGTYPESnumeric_from_int(signed int, Numeric *);
-int            PGTYPESnumeric_from_long(signed long int, Numeric *);
-int            PGTYPESnumeric_copy(Numeric *, Numeric *);
-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 *);
+numeric    *PGTYPESnumeric_new(void);
+void       PGTYPESnumeric_free(numeric *);
+numeric    *PGTYPESnumeric_from_asc(char *, char **);
+char      *PGTYPESnumeric_to_asc(numeric *, int);
+int            PGTYPESnumeric_add(numeric *, numeric *, numeric *);
+int            PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
+int            PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
+int            PGTYPESnumeric_div(numeric *, numeric *, numeric *);
+int            PGTYPESnumeric_cmp(numeric *, numeric *);
+int            PGTYPESnumeric_from_int(signed int, numeric *);
+int            PGTYPESnumeric_from_long(signed long int, numeric *);
+int            PGTYPESnumeric_copy(numeric *, numeric *);
+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 */
index f1aabcbea2bfe090c4874f71c01f2c33184cd805..f4a4b0ba3c3b1440859cb7d04f512ef0802109c5 100644 (file)
@@ -4,19 +4,19 @@
 #include 
 
 #ifdef HAVE_INT64_TIMESTAMP
-typedef int64 Timestamp;
+typedef int64 timestamp;
 typedef int64 TimestampTz;
 
 #else
-typedef double Timestamp;
+typedef double timestamp;
 typedef double TimestampTz;
 #endif
 
-extern Timestamp PGTYPEStimestamp_from_asc(char *, char **);
-extern char *PGTYPEStimestamp_to_asc(Timestamp);
-extern int PGTYPEStimestamp_sub(Timestamp *, Timestamp *, Interval *);
-extern int PGTYPEStimestamp_fmt_asc(Timestamp *, char *, int, char *);
-extern void PGTYPEStimestamp_current(Timestamp *);
-extern int PGTYPEStimestamp_defmt_asc(char *, char *, Timestamp *);
+extern timestamp PGTYPEStimestamp_from_asc(char *, char **);
+extern char *PGTYPEStimestamp_to_asc(timestamp);
+extern int PGTYPEStimestamp_sub(timestamp *, timestamp *, interval *);
+extern int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, char *);
+extern void PGTYPEStimestamp_current(timestamp *);
+extern int PGTYPEStimestamp_defmt_asc(char *, char *, timestamp *);
 
 #endif   /* PGTYPES_TIMESTAMP */
index 34ed888b66ae32c0564d9f30c0c280da57494dde..2b5e1c93e833875debbdbff4fc505a59bbbe72b6 100644 (file)
@@ -9,10 +9,10 @@
 #include "pgtypes_error.h"
 #include "pgtypes_date.h"
 
-Date
-PGTYPESdate_from_timestamp(Timestamp dt)
+date
+PGTYPESdate_from_timestamp(timestamp dt)
 {
-   Date        dDate;
+   date        dDate;
 
    dDate = 0;                  /* suppress compiler warning */
 
@@ -30,11 +30,11 @@ PGTYPESdate_from_timestamp(Timestamp dt)
    return dDate;
 }
 
-Date
+date
 PGTYPESdate_from_asc(char *str, char **endptr)
 {
 
-   Date        dDate;
+   date        dDate;
    fsec_t      fsec;
    struct tm   tt,
               *tm = &tt;
@@ -83,7 +83,7 @@ PGTYPESdate_from_asc(char *str, char **endptr)
 }
 
 char *
-PGTYPESdate_to_asc(Date dDate)
+PGTYPESdate_to_asc(date dDate)
 {
    struct tm   tt,
               *tm = &tt;
@@ -97,7 +97,7 @@ PGTYPESdate_to_asc(Date dDate)
 }
 
 void
-PGTYPESdate_julmdy(Date jd, int *mdy)
+PGTYPESdate_julmdy(date jd, int *mdy)
 {
    int         y,
                m,
@@ -110,17 +110,17 @@ PGTYPESdate_julmdy(Date jd, int *mdy)
 }
 
 void
-PGTYPESdate_mdyjul(int *mdy, Date * jdate)
+PGTYPESdate_mdyjul(int *mdy, date * jdate)
 {
    /* month is mdy[0] */
    /* day   is mdy[1] */
    /* year  is mdy[2] */
 
-   *jdate = (Date) (date2j(mdy[2], mdy[0], mdy[1]) - date2j(2000, 1, 1));
+   *jdate = (date) (date2j(mdy[2], mdy[0], mdy[1]) - date2j(2000, 1, 1));
 }
 
 int
-PGTYPESdate_dayofweek(Date dDate)
+PGTYPESdate_dayofweek(date dDate)
 {
    /*
     * Sunday:      0 Monday:      1 Tuesday:     2 Wednesday:   3
@@ -130,7 +130,7 @@ PGTYPESdate_dayofweek(Date dDate)
 }
 
 void
-PGTYPESdate_today(Date * d)
+PGTYPESdate_today(date * d)
 {
    struct tm   ts;
 
@@ -151,7 +151,7 @@ PGTYPESdate_today(Date * d)
 #define PGTYPES_FMTDATE_YEAR_DIGITS_LONG   6
 
 int
-PGTYPESdate_fmt_asc(Date dDate, char *fmtstring, char *outbuf)
+PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf)
 {
    static struct
    {
@@ -315,7 +315,7 @@ PGTYPESdate_fmt_asc(Date dDate, char *fmtstring, char *outbuf)
 
 #define PGTYPES_DATE_MONTH_MAXLENGTH       20  /* probably even less  :-) */
 int
-PGTYPESdate_defmt_asc(Date * d, char *fmt, char *str)
+PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
 {
    /*
     * token[2] = { 4,6 } means that token 2 starts at position 4 and ends
index ba6a38f2bd80181df982a7d193bb4953529a45c7..f745bf2756dde81cfa9df3546843276a5069aacd 100644 (file)
@@ -295,7 +295,7 @@ int         EncodeTimeOnly(struct tm * tm, fsec_t fsec, int *tzp, int style, char *str
 int            EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str, bool);
 int            EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str);
 
-int            tm2timestamp(struct tm *, fsec_t, int *, Timestamp *);
+int            tm2timestamp(struct tm *, fsec_t, int *, timestamp *);
 
 int            DecodeUnits(int field, char *lowtoken, int *val);
 bool       ClearDateCache(bool, bool, bool);
index c4d28b034962230e0c9b7c5129157bba3cca7f77..af9638ddc01274bfdf55372cb4b974ffc6720f31 100644 (file)
@@ -2736,11 +2736,11 @@ pgtypes_defmt_scan(union un_fmt_comb * scan_val, int scan_type, char **pstr, cha
 }
 
 /* XXX range checking */
-int PGTYPEStimestamp_defmt_scan(char **, char *, Timestamp *, int *, int *, int *,
+int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int *,
                            int *, int *, int *, int *);
 
 int
-PGTYPEStimestamp_defmt_scan(char **str, char *fmt, Timestamp *d,
+PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d,
                            int *year, int *month, int *day,
                            int *hour, int *minute, int *second,
                            int *tz)
index efde760c87cd6c0c920f76b2592514a3c7f7fc36..cbf606069663123bdeae5e71280943a6cac3b623 100644 (file)
@@ -677,7 +677,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
  * Convert a interval data type to a tm structure.
  */
 static int
-interval2tm(Interval span, struct tm * tm, fsec_t *fsec)
+interval2tm(interval span, struct tm * tm, fsec_t *fsec)
 {
 #ifdef HAVE_INT64_TIMESTAMP
    int64       time;
@@ -721,7 +721,7 @@ interval2tm(Interval span, struct tm * tm, fsec_t *fsec)
 }  /* interval2tm() */
 
 static int
-tm2interval(struct tm * tm, fsec_t fsec, Interval *span)
+tm2interval(struct tm * tm, fsec_t fsec, interval *span)
 {
    span->month = ((tm->tm_year * 12) + tm->tm_mon);
 #ifdef HAVE_INT64_TIMESTAMP
@@ -740,10 +740,10 @@ tm2interval(struct tm * tm, fsec_t fsec, Interval *span)
    return 0;
 }  /* tm2interval() */
 
-Interval *
+interval *
 PGTYPESinterval_from_asc(char *str, char **endptr)
 {
-   Interval   *result = NULL;
+   interval   *result = NULL;
    fsec_t      fsec;
    struct tm   tt,
               *tm = &tt;
@@ -776,7 +776,7 @@ PGTYPESinterval_from_asc(char *str, char **endptr)
        return NULL;
    }
 
-   result = (Interval *) pgtypes_alloc(sizeof(Interval));
+   result = (interval *) pgtypes_alloc(sizeof(interval));
    if (!result)
        return NULL;
 
@@ -796,7 +796,7 @@ PGTYPESinterval_from_asc(char *str, char **endptr)
 }
 
 char *
-PGTYPESinterval_to_asc(Interval *span)
+PGTYPESinterval_to_asc(interval *span)
 {
    struct tm   tt,
               *tm = &tt;
@@ -820,7 +820,7 @@ PGTYPESinterval_to_asc(Interval *span)
 }
 
 int
-PGTYPESinterval_copy(Interval *intvlsrc, Interval *intrcldest)
+PGTYPESinterval_copy(interval *intvlsrc, interval *intrcldest)
 {
    intrcldest->time = intvlsrc->time;
    intrcldest->month = intvlsrc->month;
index 5811be61c8f1a3176045c35490e4b1ddf95813ac..c4db798395293b72f54a5d23df43db8a20c989b7 100644 (file)
@@ -8,7 +8,7 @@
 #define Max(x, y)              ((x) > (y) ? (x) : (y))
 #define Min(x, y)              ((x) < (y) ? (x) : (y))
 
-#define init_var(v)                memset(v,0,sizeof(Numeric))
+#define init_var(v)                memset(v,0,sizeof(numeric))
 
 #define digitbuf_alloc(size) ((NumericDigit *) pgtypes_alloc(size))
 #define digitbuf_free(buf)     \
@@ -28,7 +28,7 @@
  * ----------
  */
 static int
-apply_typmod(Numeric *var, long typmod)
+apply_typmod(numeric *var, long typmod)
 {
    int         precision;
    int         scale;
@@ -108,7 +108,7 @@ apply_typmod(Numeric *var, long typmod)
  * ----------
  */
 static int
-alloc_var(Numeric *var, int ndigits)
+alloc_var(numeric *var, int ndigits)
 {
    digitbuf_free(var->buf);
    var->buf = digitbuf_alloc(ndigits + 1);
@@ -120,12 +120,12 @@ alloc_var(Numeric *var, int ndigits)
    return 0;
 }
 
-Numeric *
+numeric *
 PGTYPESnumeric_new(void)
 {
-   Numeric    *var;
+   numeric    *var;
 
-   if ((var = (Numeric *) pgtypes_alloc(sizeof(Numeric))) == NULL)
+   if ((var = (numeric *) pgtypes_alloc(sizeof(numeric))) == NULL)
        return NULL;
 
    if (alloc_var(var, 0) < 0)
@@ -141,7 +141,7 @@ PGTYPESnumeric_new(void)
  * ----------
  */
 static int
-set_var_from_str(char *str, char **ptr, Numeric *dest)
+set_var_from_str(char *str, char **ptr, numeric *dest)
 {
    bool        have_dp = FALSE;
    int         i = 0;
@@ -270,7 +270,7 @@ set_var_from_str(char *str, char **ptr, Numeric *dest)
  * ----------
  */
 static char *
-get_str_from_var(Numeric *var, int dscale)
+get_str_from_var(numeric *var, int dscale)
 {
    char       *str;
    char       *cp;
@@ -356,10 +356,10 @@ get_str_from_var(Numeric *var, int dscale)
    return str;
 }
 
-Numeric *
+numeric *
 PGTYPESnumeric_from_asc(char *str, char **endptr)
 {
-   Numeric    *value = (Numeric *) pgtypes_alloc(sizeof(Numeric));
+   numeric    *value = (numeric *) pgtypes_alloc(sizeof(numeric));
    int         ret;
 
 #if 0
@@ -384,9 +384,9 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
 }
 
 char *
-PGTYPESnumeric_to_asc(Numeric *num, int dscale)
+PGTYPESnumeric_to_asc(numeric *num, int dscale)
 {
-   if (dscale <= 0)
+   if (dscale < 0)
        dscale = num->dscale;
 
    return (get_str_from_var(num, dscale));
@@ -400,7 +400,7 @@ PGTYPESnumeric_to_asc(Numeric *num, int dscale)
  * ----------
  */
 static void
-zero_var(Numeric *var)
+zero_var(numeric *var)
 {
    digitbuf_free(var->buf);
    var->buf = NULL;
@@ -411,7 +411,7 @@ zero_var(Numeric *var)
 }
 
 void
-PGTYPESnumeric_free(Numeric *var)
+PGTYPESnumeric_free(numeric *var)
 {
    digitbuf_free(var->buf);
    free(var);
@@ -427,7 +427,7 @@ PGTYPESnumeric_free(Numeric *var)
  * ----------
  */
 static int
-cmp_abs(Numeric *var1, Numeric *var2)
+cmp_abs(numeric *var1, numeric *var2)
 {
    int         i1 = 0;
    int         i2 = 0;
@@ -485,7 +485,7 @@ cmp_abs(Numeric *var1, Numeric *var2)
  * ----------
  */
 static int
-add_abs(Numeric *var1, Numeric *var2, Numeric *result)
+add_abs(numeric *var1, numeric *var2, numeric *result)
 {
    NumericDigit *res_buf;
    NumericDigit *res_digits;
@@ -573,7 +573,7 @@ add_abs(Numeric *var1, Numeric *var2, Numeric *result)
  * ----------
  */
 static int
-sub_abs(Numeric *var1, Numeric *var2, Numeric *result)
+sub_abs(numeric *var1, numeric *var2, numeric *result)
 {
    NumericDigit *res_buf;
    NumericDigit *res_digits;
@@ -657,7 +657,7 @@ sub_abs(Numeric *var1, Numeric *var2, Numeric *result)
  * ----------
  */
 int
-PGTYPESnumeric_add(Numeric *var1, Numeric *var2, Numeric *result)
+PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result)
 {
    /*
     * Decide on the signs of the two variables what to do
@@ -786,7 +786,7 @@ PGTYPESnumeric_add(Numeric *var1, Numeric *var2, Numeric *result)
  * ----------
  */
 int
-PGTYPESnumeric_sub(Numeric *var1, Numeric *var2, Numeric *result)
+PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result)
 {
    /*
     * Decide on the signs of the two variables what to do
@@ -917,7 +917,7 @@ PGTYPESnumeric_sub(Numeric *var1, Numeric *var2, Numeric *result)
  * ----------
  */
 int
-PGTYPESnumeric_mul(Numeric *var1, Numeric *var2, Numeric *result)
+PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result)
 {
    NumericDigit *res_buf;
    NumericDigit *res_digits;
@@ -1008,7 +1008,7 @@ PGTYPESnumeric_mul(Numeric *var1, Numeric *var2, Numeric *result)
  * Note that this must be called before div_var.
  */
 static int
-select_div_scale(Numeric *var1, Numeric *var2, int *rscale)
+select_div_scale(numeric *var1, numeric *var2, int *rscale)
 {
    int         weight1,
                weight2,
@@ -1075,14 +1075,14 @@ select_div_scale(Numeric *var1, Numeric *var2, int *rscale)
 }
 
 int
-PGTYPESnumeric_div(Numeric *var1, Numeric *var2, Numeric *result)
+PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result)
 {
    NumericDigit *res_digits;
    int         res_ndigits;
    int         res_sign;
    int         res_weight;
-   Numeric     dividend;
-   Numeric     divisor[10];
+   numeric     dividend;
+   numeric     divisor[10];
    int         ndigits_tmp;
    int         weight_tmp;
    int         rscale_tmp;
@@ -1198,7 +1198,7 @@ PGTYPESnumeric_div(Numeric *var1, Numeric *var2, Numeric *result)
                int         i;
                long        sum = 0;
 
-               memcpy(&divisor[guess], &divisor[1], sizeof(Numeric));
+               memcpy(&divisor[guess], &divisor[1], sizeof(numeric));
                divisor[guess].buf = digitbuf_alloc(divisor[guess].ndigits);
                divisor[guess].digits = divisor[guess].buf;
                for (i = divisor[1].ndigits - 1; i >= 0; i--)
@@ -1281,7 +1281,7 @@ PGTYPESnumeric_div(Numeric *var1, Numeric *var2, Numeric *result)
 
 
 int
-PGTYPESnumeric_cmp(Numeric *var1, Numeric *var2)
+PGTYPESnumeric_cmp(numeric *var1, numeric *var2)
 {
 
    /* use cmp_abs function to calculate the result */
@@ -1312,7 +1312,7 @@ PGTYPESnumeric_cmp(Numeric *var1, Numeric *var2)
 }
 
 int
-PGTYPESnumeric_from_int(signed int int_val, Numeric *var)
+PGTYPESnumeric_from_int(signed int int_val, numeric *var)
 {
    /* implicit conversion */
    signed long int long_int = int_val;
@@ -1321,7 +1321,7 @@ PGTYPESnumeric_from_int(signed int int_val, Numeric *var)
 }
 
 int
-PGTYPESnumeric_from_long(signed long int long_val, Numeric *var)
+PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
 {
    /* calculate the size of the long int number */
    /* a number n needs log_10 n digits */
@@ -1382,7 +1382,7 @@ PGTYPESnumeric_from_long(signed long int long_val, Numeric *var)
 }
 
 int
-PGTYPESnumeric_copy(Numeric *src, Numeric *dst)
+PGTYPESnumeric_copy(numeric *src, numeric *dst)
 {
    int         i;
 
@@ -1403,10 +1403,10 @@ PGTYPESnumeric_copy(Numeric *src, Numeric *dst)
 }
 
 int
-PGTYPESnumeric_from_double(double d, Numeric *dst)
+PGTYPESnumeric_from_double(double d, numeric *dst)
 {
    char        buffer[100];
-   Numeric    *tmp;
+   numeric    *tmp;
 
    if (sprintf(buffer, "%f", d) == 0)
        return -1;
@@ -1420,7 +1420,7 @@ PGTYPESnumeric_from_double(double d, Numeric *dst)
 }
 
 static int
-numericvar_to_double_no_overflow(Numeric *var, double *dp)
+numericvar_to_double_no_overflow(numeric *var, double *dp)
 {
    char       *tmp;
    double      val;
@@ -1444,7 +1444,7 @@ numericvar_to_double_no_overflow(Numeric *var, double *dp)
 }
 
 int
-PGTYPESnumeric_to_double(Numeric *nv, double *dp)
+PGTYPESnumeric_to_double(numeric *nv, double *dp)
 {
    double      tmp;
    int         i;
@@ -1456,7 +1456,7 @@ PGTYPESnumeric_to_double(Numeric *nv, double *dp)
 }
 
 int
-PGTYPESnumeric_to_int(Numeric *nv, int *ip)
+PGTYPESnumeric_to_int(numeric *nv, int *ip)
 {
    long        l;
    int         i;
@@ -1475,7 +1475,7 @@ PGTYPESnumeric_to_int(Numeric *nv, int *ip)
 }
 
 int
-PGTYPESnumeric_to_long(Numeric *nv, long *lp)
+PGTYPESnumeric_to_long(numeric *nv, long *lp)
 {
    int         i;
    long        l = 0;
@@ -1503,7 +1503,7 @@ PGTYPESnumeric_to_long(Numeric *nv, long *lp)
 }
 
 int
-PGTYPESnumeric_to_decimal(Numeric *src, Decimal * dst)
+PGTYPESnumeric_to_decimal(numeric *src, decimal * dst)
 {
    int         i;
 
@@ -1526,7 +1526,7 @@ PGTYPESnumeric_to_decimal(Numeric *src, Decimal * dst)
 }
 
 int
-PGTYPESnumeric_from_decimal(Decimal * src, Numeric *dst)
+PGTYPESnumeric_from_decimal(decimal * src, numeric *dst)
 {
    int         i;
 
index 9ad82ba4d2b504004bce9a7dbe7e3f84812eb096..7581df2bf2fd2de2f94d5bc839ee17bb32e33baf 100644 (file)
@@ -13,7 +13,7 @@
 #include "pgtypes_date.h"
 #include "datetime.h"
 
-int PGTYPEStimestamp_defmt_scan(char **, char *, Timestamp *, int *, int *, int *,
+int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int *,
                            int *, int *, int *, int *);
 
 #ifdef HAVE_INT64_TIMESTAMP
@@ -31,8 +31,8 @@ time2t(const int hour, const int min, const int sec, const fsec_t fsec)
 }  /* time2t() */
 #endif
 
-static Timestamp
-dt2local(Timestamp dt, int tz)
+static timestamp
+dt2local(timestamp dt, int tz)
 {
 #ifdef HAVE_INT64_TIMESTAMP
    dt -= (tz * INT64CONST(1000000));
@@ -51,22 +51,21 @@ dt2local(Timestamp dt, int tz)
  * Returns -1 on failure (overflow).
  */
 int
-tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
+tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, timestamp *result)
 {
 #ifdef HAVE_INT64_TIMESTAMP
-   int         date;
+   int     dDate;
    int64       time;
 
 #else
-   double      date,
-               time;
+   double      dDate, time;
 #endif
 
    /* Julian day routines are not correct for negative Julian days */
    if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday))
        return -1;
 
-   date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1);
+   dDate = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1);
    time = time2t(tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
 #ifdef HAVE_INT64_TIMESTAMP
    *result = (date * INT64CONST(86400000000)) + time;
@@ -77,7 +76,7 @@ tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
    if ((*result < 0) ? (date >= 0) : (date < 0))
        return -1;
 #else
-   *result = ((date * 86400) + time);
+   *result = ((dDate * 86400) + time);
 #endif
    if (tzp != NULL)
        *result = dt2local(*result, -(*tzp));
@@ -85,10 +84,10 @@ tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
    return 0;
 }  /* tm2timestamp() */
 
-static Timestamp
+static timestamp
 SetEpochTimestamp(void)
 {
-   Timestamp   dt;
+   timestamp   dt;
    struct tm   tt,
               *tm = &tt;
 
@@ -98,7 +97,7 @@ SetEpochTimestamp(void)
 }  /* SetEpochTimestamp() */
 
 static void
-dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
+dt2time(timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
 {
 #ifdef HAVE_INT64_TIMESTAMP
    int64       time;
@@ -141,16 +140,14 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
  * local time zone. If out of this range, leave as GMT. - tgl 97/05/27
  */
 static int
-timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
+timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
 {
 #ifdef HAVE_INT64_TIMESTAMP
-   int         date,
-               date0;
+   int     dDate, date0;
    int64       time;
 
 #else
-   double      date,
-               date0;
+   double      dDate, date0;
    double      time;
 #endif
    time_t      utime;
@@ -163,31 +160,31 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
 
    time = dt;
 #ifdef HAVE_INT64_TIMESTAMP
-   TMODULO(time, date, INT64CONST(86400000000));
+   TMODULO(time, dDate, INT64CONST(86400000000));
 
    if (time < INT64CONST(0))
    {
        time += INT64CONST(86400000000);
-       date -= 1;
+       dDate -= 1;
    }
 #else
-   TMODULO(time, date, 86400e0);
+   TMODULO(time, dDate, 86400e0);
 
    if (time < 0)
    {
        time += 86400;
-       date -= 1;
+       dDate -= 1;
    }
 #endif
 
    /* Julian day routine does not work for negative Julian days */
-   if (date < -date0)
+   if (dDate < -date0)
        return -1;
 
    /* add offset to go from J2000 back to standard Julian date */
-   date += date0;
+   dDate += date0;
 
-   j2date((int) date, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
+   j2date((int) dDate, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
    dt2time(time, &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
 
    if (tzp != NULL)
@@ -260,7 +257,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
  * * Convert reserved timestamp data type to string.
  *  */
 static int
-EncodeSpecialTimestamp(Timestamp dt, char *str)
+EncodeSpecialTimestamp(timestamp dt, char *str)
 {
    if (TIMESTAMP_IS_NOBEGIN(dt))
        strcpy(str, EARLY);
@@ -272,10 +269,10 @@ EncodeSpecialTimestamp(Timestamp dt, char *str)
    return TRUE;
 }  /* EncodeSpecialTimestamp() */
 
-Timestamp
+timestamp
 PGTYPEStimestamp_from_asc(char *str, char **endptr)
 {
-   Timestamp   result;
+   timestamp   result;
 
 #ifdef HAVE_INT64_TIMESTAMP
    int64       noresult = 0;
@@ -346,7 +343,7 @@ PGTYPEStimestamp_from_asc(char *str, char **endptr)
 }
 
 char *
-PGTYPEStimestamp_to_asc(Timestamp tstamp)
+PGTYPEStimestamp_to_asc(timestamp tstamp)
 {
    struct tm   tt,
               *tm = &tt;
@@ -369,7 +366,7 @@ PGTYPEStimestamp_to_asc(Timestamp tstamp)
 }
 
 void
-PGTYPEStimestamp_current(Timestamp *ts)
+PGTYPEStimestamp_current(timestamp *ts)
 {
    struct tm   tm;
 
@@ -379,7 +376,7 @@ PGTYPEStimestamp_current(Timestamp *ts)
 }
 
 static int
-dttofmtasc_replace(Timestamp *ts, Date dDate, int dow, struct tm * tm,
+dttofmtasc_replace(timestamp *ts, date dDate, int dow, struct tm * tm,
                   char *output, int *pstr_len, char *fmtstr)
 {
    union un_fmt_comb replace_val;
@@ -769,11 +766,11 @@ dttofmtasc_replace(Timestamp *ts, Date dDate, int dow, struct tm * tm,
 
 
 int
-PGTYPEStimestamp_fmt_asc(Timestamp *ts, char *output, int str_len, char *fmtstr)
+PGTYPEStimestamp_fmt_asc(timestamp *ts, char *output, int str_len, char *fmtstr)
 {
    struct tm   tm;
    fsec_t      fsec;
-   Date        dDate;
+   date        dDate;
    int         dow;
 
    dDate = PGTYPESdate_from_timestamp(*ts);
@@ -784,7 +781,7 @@ PGTYPEStimestamp_fmt_asc(Timestamp *ts, char *output, int str_len, char *fmtstr)
 }
 
 int
-PGTYPEStimestamp_sub(Timestamp *ts1, Timestamp *ts2, Interval *iv)
+PGTYPEStimestamp_sub(timestamp *ts1, timestamp *ts2, interval *iv)
 {
    if (TIMESTAMP_NOT_FINITE(*ts1) || TIMESTAMP_NOT_FINITE(*ts2))
        return PGTYPES_TS_ERR_EINFTIME;
@@ -801,7 +798,7 @@ PGTYPEStimestamp_sub(Timestamp *ts1, Timestamp *ts2, Interval *iv)
 }
 
 int
-PGTYPEStimestamp_defmt_asc(char *str, char *fmt, Timestamp *d)
+PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d)
 {
    int         year,
                month,
index 7cf8eeebb2faa8b33c0067a6590559796741c47f..86d46036794dd91682619e8e1db5c6947d4ab49f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.77 2003/08/04 00:43:33 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.78 2003/09/09 10:46:38 meskes Exp $ */
 
 /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
 /* (C) Michael Meskes  Feb 5th, 1998 */
@@ -173,9 +173,9 @@ main(int argc, char *const argv[])
                {
                    compat = (strcmp(optarg, "INFORMIX") == 0) ? ECPG_COMPAT_INFORMIX : ECPG_COMPAT_INFORMIX_SE;
                    /* system_includes = true; */
-                   add_preprocessor_define("dec_t=Numeric");
-                   add_preprocessor_define("intrvl_t=Interval");
-                   add_preprocessor_define("dtime_t=Timestamp");
+                   add_preprocessor_define("dec_t=numeric");
+                   add_preprocessor_define("intrvl_t=interval");
+                   add_preprocessor_define("dtime_t=timestamp");
                }
                else
                {
index e295d1f164a9b3c82df1c3d2833319f0489ef269..9976f6f533395e6fb45c74e7432ece37df28be92 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.253 2003/08/26 16:09:01 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.254 2003/09/09 10:46:38 meskes Exp $ */
 
 /* Copyright comment */
 %{
@@ -4505,7 +4505,7 @@ single_vt_type: common_type
            else if (strcmp($1, "decimal") == 0)
            {
                $$.type_enum = ECPGt_decimal;
-               $$.type_str = make_str("Decimal");
+               $$.type_str = make_str("decimal");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4513,7 +4513,7 @@ single_vt_type: common_type
            else if (strcmp($1, "date") == 0)
            {
                $$.type_enum = ECPGt_date;
-               $$.type_str = make_str("Date");
+               $$.type_str = make_str("date");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4521,7 +4521,7 @@ single_vt_type: common_type
            else if (strcmp($1, "timestamp") == 0)
            {
                $$.type_enum = ECPGt_timestamp;
-               $$.type_str = make_str("Timestamp");
+               $$.type_str = make_str("timestamp");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4529,7 +4529,7 @@ single_vt_type: common_type
            else if (strcmp($1, "datetime") == 0)
            {
                $$.type_enum = ECPGt_timestamp;
-               $$.type_str = make_str("Timestamp");
+               $$.type_str = make_str("timestamp");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4537,7 +4537,7 @@ single_vt_type: common_type
            else if (strcmp($1, "interval") == 0)
            {
                $$.type_enum = ECPGt_interval;
-               $$.type_str = make_str("Interval");
+               $$.type_str = make_str("interval");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4806,12 +4806,12 @@ common_type: simple_type
            if (strcmp($1, "numeric") == 0)
            {
                $$.type_enum = ECPGt_numeric;
-               $$.type_str = make_str("Numeric");
+               $$.type_str = make_str("numeric");
            }
            else if (strcmp($1, "decimal") == 0)
            {
                $$.type_enum = ECPGt_decimal;
-               $$.type_str = make_str("Decimal");
+               $$.type_str = make_str("decimal");
            }
            else
                mmerror(PARSE_ERROR, ET_ERROR, "Only numeric/decimal have precision/scale argument");
@@ -4859,7 +4859,7 @@ var_type: common_type
            else if (strcmp($1, "numeric") == 0)
            {
                $$.type_enum = ECPGt_numeric;
-               $$.type_str = make_str("Numeric");
+               $$.type_str = make_str("numeric");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4867,7 +4867,7 @@ var_type: common_type
            else if (strcmp($1, "decimal") == 0)
            {
                $$.type_enum = ECPGt_decimal;
-               $$.type_str = make_str("Deciaml");
+               $$.type_str = make_str("decimal");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4875,7 +4875,7 @@ var_type: common_type
            else if (strcmp($1, "date") == 0)
            {
                $$.type_enum = ECPGt_date;
-               $$.type_str = make_str("Date");
+               $$.type_str = make_str("date");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4883,7 +4883,7 @@ var_type: common_type
            else if (strcmp($1, "timestamp") == 0)
            {
                $$.type_enum = ECPGt_timestamp;
-               $$.type_str = make_str("Timestamp");
+               $$.type_str = make_str("timestamp");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4891,7 +4891,7 @@ var_type: common_type
            else if (strcmp($1, "interval") == 0)
            {
                $$.type_enum = ECPGt_interval;
-               $$.type_str = make_str("Interval");
+               $$.type_str = make_str("interval");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
@@ -4899,7 +4899,7 @@ var_type: common_type
            else if (strcmp($1, "datetime") == 0)
            {
                $$.type_enum = ECPGt_timestamp;
-               $$.type_str = make_str("Timestamp");
+               $$.type_str = make_str("timestamp");
                $$.type_dimension = make_str("-1");
                $$.type_index = make_str("-1");
                $$.type_sizeof = NULL;
index 6eb1209ede4bfa5d213360bf77cc925f0868d21e..e14321d54f93ef6aba3182816060aa85b3ec33a5 100644 (file)
@@ -366,7 +366,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
                 * we have to use a pointer here
                 */
                sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
-               sprintf(offset, "sizeof(Numeric)");
+               sprintf(offset, "sizeof(numeric)");
                break;
            case ECPGt_interval:
 
@@ -374,7 +374,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
                 * we have to use a pointer here
                 */
                sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
-               sprintf(offset, "sizeof(Interval)");
+               sprintf(offset, "sizeof(interval)");
                break;
            case ECPGt_date:
 
@@ -383,7 +383,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
                 * type
                 */
                sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
-               sprintf(offset, "sizeof(Date)");
+               sprintf(offset, "sizeof(date)");
                break;
            case ECPGt_timestamp:
 
@@ -392,7 +392,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
                 * type
                 */
                sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
-               sprintf(offset, "sizeof(Date)");
+               sprintf(offset, "sizeof(timestamp)");
                break;
            case ECPGt_const:
 
index df6edc30a82d437ef14f05f7de6075bbb49171a5..0e509925b1e617be8bf82d065408b67a43f2f1c5 100644 (file)
@@ -14,7 +14,7 @@ main()
        interval iv1;
        char *text;
    exec sql end declare section;
-   Date date2;
+   date date2;
    int mdy[3] = { 4, 19, 1998 };
    char *fmt, *out, *in;
    char *d1 = "Mon Jan 17 1966";
index 7cf687c220abec44143e7d84a80f59e7e5eafad9..3b0a1dba15a59ec5755f74b00720fbd3ed1d9e21 100644 (file)
@@ -6,7 +6,7 @@ int
 main()
 {
    char *text="error\n";
-   Numeric *value1, *value2, *res;
+   numeric *value1, *value2, *res;
    exec sql begin declare section;
        numeric(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
    exec sql end declare section;