diff options
author | Michael Meskes <meskes@postgresql.org> | 2003-04-01 14:37:25 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2003-04-01 14:37:25 +0000 |
commit | 7b85b730f59c9330b825472011d22bd173005c27 (patch) | |
tree | 1d621d1324af6bdc419ce7b0d631c2be98a3ccc7 /src/interfaces/ecpg/compatlib/informix.c | |
parent | 52bc8cadd4f3d68fbaa9a1c1a32c2b08962131a2 (diff) | |
download | postgresql-7b85b730f59c9330b825472011d22bd173005c27.tar.gz postgresql-7b85b730f59c9330b825472011d22bd173005c27.zip |
More patches for informix compatibility.
Diffstat (limited to 'src/interfaces/ecpg/compatlib/informix.c')
-rw-r--r-- | src/interfaces/ecpg/compatlib/informix.c | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index b8fd79acde7..23e0a820f2f 100644 --- a/src/interfaces/ecpg/compatlib/informix.c +++ b/src/interfaces/ecpg/compatlib/informix.c @@ -64,7 +64,7 @@ deccvasc(char *cp, int len, Numeric *np) ret = -1201; else { - np = PGTYPESnumeric_aton(str, NULL); + np = PGTYPESnumeric_from_asc(str, NULL); if (!np) { switch (errno) @@ -85,19 +85,19 @@ deccvasc(char *cp, int len, Numeric *np) int deccvdbl(double dbl, Numeric *np) { - return(PGTYPESnumeric_dton(dbl, np)); + return(PGTYPESnumeric_from_double(dbl, np)); } int deccvint(int in, Numeric *np) { - return(PGTYPESnumeric_iton(in, np)); + return(PGTYPESnumeric_from_int(in, np)); } int deccvlong(long lng, Numeric *np) { - return(PGTYPESnumeric_lton(lng, np)); + return(PGTYPESnumeric_from_long(lng, np)); } int @@ -159,9 +159,9 @@ dectoasc(Numeric *np, char *cp, int len, int right) char *str; if (right >= 0) - str = PGTYPESnumeric_ntoa(np, right); + str = PGTYPESnumeric_to_asc(np, right); else - str = PGTYPESnumeric_ntoa(np, 0); + str = PGTYPESnumeric_to_asc(np, 0); if (!str) return -1; @@ -176,13 +176,13 @@ dectoasc(Numeric *np, char *cp, int len, int right) int dectodbl(Numeric *np, double *dblp) { - return(PGTYPESnumeric_ntod(np, dblp)); + return(PGTYPESnumeric_to_double(np, dblp)); } int dectoint(Numeric *np, int *ip) { - int ret = PGTYPESnumeric_ntoi(np, ip); + int ret = PGTYPESnumeric_to_int(np, ip); if (ret == PGTYPES_NUM_OVERFLOW) ret = -1200; @@ -193,7 +193,7 @@ dectoint(Numeric *np, int *ip) int dectolong(Numeric *np, long *lngp) { - int ret = PGTYPESnumeric_ntol(np, lngp); + int ret = PGTYPESnumeric_to_long(np, lngp); if (ret == PGTYPES_NUM_OVERFLOW) ret = -1200; @@ -205,7 +205,7 @@ dectolong(Numeric *np, long *lngp) int rdatestr (Date d, char *str) { - char *tmp = PGTYPESdate_dtoa(d); + char *tmp = PGTYPESdate_to_asc(d); if (!tmp) return -1210; @@ -217,6 +217,15 @@ rdatestr (Date d, char *str) return 0; } +int +rstrdate (char *str, Date *d) +{ + Date dat = PGTYPESdate_from_asc(str, NULL); + + /* XXX: ERROR handling hier und in datetime.c */ + return 0; +} + void rtoday (Date *d) { @@ -237,7 +246,7 @@ rdefmtdate (Date *d, char *fmt, char *str) /* TODO: take care of DBCENTURY environment variable */ /* PGSQL functions allow all centuries */ - if (PGTYPESdate_defmtdate(d, fmt, str) == 0) + if (PGTYPESdate_defmt_asc(d, fmt, str) == 0) return 0; switch (errno) @@ -254,7 +263,7 @@ rdefmtdate (Date *d, char *fmt, char *str) int rfmtdate (Date d, char *fmt, char *str) { - if (PGTYPESdate_fmtdate(d, fmt, str) == 0) + if (PGTYPESdate_fmt_asc(d, fmt, str) == 0) return 0; if (errno == ENOMEM) @@ -275,19 +284,36 @@ rmdyjul (short mdy[3], Date *d) void dtcurrent (Timestamp *ts) { - return; + PGTYPEStimestamp_current (ts); } int dtcvasc (char *str, Timestamp *ts) { + Timestamp ts_tmp; + int i; + char **endptr = &str; + + ts_tmp = PGTYPEStimestamp_from_asc(str, endptr); + i = errno; + if (i) { + return i; + } + if (**endptr) { + /* extra characters exist at the end */ + return -1264; + } + + /* everything went fine */ + *ts = ts_tmp; + return 0; } int dtsub (Timestamp *ts1, Timestamp *ts2, Interval *iv) { - return 0; + return PGTYPEStimestamp_sub(ts1, ts2, iv); } int @@ -299,23 +325,22 @@ dttoasc (Timestamp *ts, char *output) int dttofmtasc (Timestamp *ts, char *output, int str_len, char *fmtstr) { - return 0; + return PGTYPEStimestamp_fmt_asc(ts, output, str_len, fmtstr); } int intoasc(Interval *i, char *str) { + str = PGTYPESinterval_to_asc(i); + + if (!str) + return -errno; + return 0; } /* And finally some misc functions */ int -rstrdate (char *str, Date *d) -{ - return 0; -} - -int rfmtlong(long lvalue, char *format, char *outbuf) { return 0; @@ -352,8 +377,10 @@ rtypmsize(int type, int len) } void -rupshift(char *s) +rupshift(char *str) { + for (; *str != '\0'; str++) + if (islower(*str)) *str = toupper(*str); return; } |