mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
- Added Dave patch for Informix handling of numeric/int conversion.
- Changed all new datatypes to lowercase. - Fixed rounding bug in numerical types.
This commit is contained in:
parent
fd65be4a78
commit
fcdf0e22fc
@ -13,9 +13,9 @@
|
|||||||
char *ECPGalloc(long, int);
|
char *ECPGalloc(long, int);
|
||||||
|
|
||||||
static 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;
|
*a2;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -51,9 +51,9 @@ deccall2(Decimal * arg1, Decimal * arg2, int (*ptr) (Numeric *, Numeric *))
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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,
|
*a2,
|
||||||
*nres;
|
*nres;
|
||||||
int i;
|
int i;
|
||||||
@ -110,7 +110,7 @@ deccall3(Decimal * arg1, Decimal * arg2, Decimal * result, int (*ptr) (Numeric *
|
|||||||
|
|
||||||
/* we start with the numeric functions */
|
/* we start with the numeric functions */
|
||||||
int
|
int
|
||||||
decadd(Decimal * arg1, Decimal * arg2, Decimal * sum)
|
decadd(decimal * arg1, decimal * arg2, decimal * sum)
|
||||||
{
|
{
|
||||||
deccall3(arg1, arg2, sum, PGTYPESnumeric_add);
|
deccall3(arg1, arg2, sum, PGTYPESnumeric_add);
|
||||||
|
|
||||||
@ -123,15 +123,15 @@ decadd(Decimal * arg1, Decimal * arg2, Decimal * sum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
deccmp(Decimal * arg1, Decimal * arg2)
|
deccmp(decimal * arg1, decimal * arg2)
|
||||||
{
|
{
|
||||||
return (deccall2(arg1, arg2, PGTYPESnumeric_cmp));
|
return (deccall2(arg1, arg2, PGTYPESnumeric_cmp));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
deccopy(Decimal * src, Decimal * target)
|
deccopy(decimal * src, decimal * target)
|
||||||
{
|
{
|
||||||
memcpy(target, src, sizeof(Decimal));
|
memcpy(target, src, sizeof(decimal));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@ -154,12 +154,12 @@ strndup(const char *str, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
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 */
|
* complete string */
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
Numeric *result;
|
numeric *result;
|
||||||
|
|
||||||
if (risnull(CSTRINGTYPE, cp))
|
if (risnull(CSTRINGTYPE, cp))
|
||||||
{
|
{
|
||||||
@ -201,9 +201,9 @@ deccvasc(char *cp, int len, Decimal * np)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
deccvdbl(double dbl, Decimal * np)
|
deccvdbl(double dbl, decimal * np)
|
||||||
{
|
{
|
||||||
Numeric *nres = PGTYPESnumeric_new();
|
numeric *nres = PGTYPESnumeric_new();
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|
||||||
if (risnull(CDOUBLETYPE, (char *) &dbl))
|
if (risnull(CDOUBLETYPE, (char *) &dbl))
|
||||||
@ -224,9 +224,9 @@ deccvdbl(double dbl, Decimal * np)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
deccvint(int in, Decimal * np)
|
deccvint(int in, decimal * np)
|
||||||
{
|
{
|
||||||
Numeric *nres = PGTYPESnumeric_new();
|
numeric *nres = PGTYPESnumeric_new();
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|
||||||
if (risnull(CINTTYPE, (char *) &in))
|
if (risnull(CINTTYPE, (char *) &in))
|
||||||
@ -247,9 +247,9 @@ deccvint(int in, Decimal * np)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
deccvlong(long lng, Decimal * np)
|
deccvlong(long lng, decimal * np)
|
||||||
{
|
{
|
||||||
Numeric *nres = PGTYPESnumeric_new();
|
numeric *nres = PGTYPESnumeric_new();
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|
||||||
if (risnull(CLONGTYPE, (char *) &lng))
|
if (risnull(CLONGTYPE, (char *) &lng))
|
||||||
@ -270,7 +270,7 @@ deccvlong(long lng, Decimal * np)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
decdiv(Decimal * n1, Decimal * n2, Decimal * n3)
|
decdiv(decimal * n1, decimal * n2, decimal * n3)
|
||||||
{
|
{
|
||||||
int i = deccall3(n1, n2, n3, PGTYPESnumeric_div);
|
int i = deccall3(n1, n2, n3, PGTYPESnumeric_div);
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ decdiv(Decimal * n1, Decimal * n2, Decimal * n3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
decmul(Decimal * n1, Decimal * n2, Decimal * n3)
|
decmul(decimal * n1, decimal * n2, decimal * n3)
|
||||||
{
|
{
|
||||||
int i = deccall3(n1, n2, n3, PGTYPESnumeric_mul);
|
int i = deccall3(n1, n2, n3, PGTYPESnumeric_mul);
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ decmul(Decimal * n1, Decimal * n2, Decimal * n3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
decsub(Decimal * n1, Decimal * n2, Decimal * n3)
|
decsub(decimal * n1, decimal * n2, decimal * n3)
|
||||||
{
|
{
|
||||||
int i = deccall3(n1, n2, n3, PGTYPESnumeric_sub);
|
int i = deccall3(n1, n2, n3, PGTYPESnumeric_sub);
|
||||||
|
|
||||||
@ -330,10 +330,10 @@ decsub(Decimal * n1, Decimal * n2, Decimal * n3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dectoasc(Decimal * np, char *cp, int len, int right)
|
dectoasc(decimal * np, char *cp, int len, int right)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
Numeric *nres = PGTYPESnumeric_new();
|
numeric *nres = PGTYPESnumeric_new();
|
||||||
|
|
||||||
if (nres == NULL)
|
if (nres == NULL)
|
||||||
return -1211;
|
return -1211;
|
||||||
@ -367,9 +367,9 @@ dectoasc(Decimal * np, char *cp, int len, int right)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dectodbl(Decimal * np, double *dblp)
|
dectodbl(decimal * np, double *dblp)
|
||||||
{
|
{
|
||||||
Numeric *nres = PGTYPESnumeric_new();
|
numeric *nres = PGTYPESnumeric_new();
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (nres == NULL)
|
if (nres == NULL)
|
||||||
@ -385,10 +385,10 @@ dectodbl(Decimal * np, double *dblp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dectoint(Decimal * np, int *ip)
|
dectoint(decimal * np, int *ip)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
Numeric *nres = PGTYPESnumeric_new();
|
numeric *nres = PGTYPESnumeric_new();
|
||||||
|
|
||||||
if (nres == NULL)
|
if (nres == NULL)
|
||||||
return -1211;
|
return -1211;
|
||||||
@ -405,10 +405,10 @@ dectoint(Decimal * np, int *ip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dectolong(Decimal * np, long *lngp)
|
dectolong(decimal * np, long *lngp)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
Numeric *nres = PGTYPESnumeric_new();;
|
numeric *nres = PGTYPESnumeric_new();;
|
||||||
|
|
||||||
if (nres == NULL)
|
if (nres == NULL)
|
||||||
return -1211;
|
return -1211;
|
||||||
@ -529,15 +529,15 @@ rdayofweek(Date d)
|
|||||||
/* And the datetime stuff */
|
/* And the datetime stuff */
|
||||||
|
|
||||||
void
|
void
|
||||||
dtcurrent(Timestamp *ts)
|
dtcurrent(timestamp *ts)
|
||||||
{
|
{
|
||||||
PGTYPEStimestamp_current(ts);
|
PGTYPEStimestamp_current(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dtcvasc(char *str, Timestamp *ts)
|
dtcvasc(char *str, timestamp *ts)
|
||||||
{
|
{
|
||||||
Timestamp ts_tmp;
|
timestamp ts_tmp;
|
||||||
int i;
|
int i;
|
||||||
char **endptr = &str;
|
char **endptr = &str;
|
||||||
|
|
||||||
@ -558,13 +558,13 @@ dtcvasc(char *str, Timestamp *ts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dtsub(Timestamp *ts1, Timestamp *ts2, Interval *iv)
|
dtsub(timestamp *ts1, timestamp *ts2, interval *iv)
|
||||||
{
|
{
|
||||||
return PGTYPEStimestamp_sub(ts1, ts2, iv);
|
return PGTYPEStimestamp_sub(ts1, ts2, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dttoasc(Timestamp *ts, char *output)
|
dttoasc(timestamp *ts, char *output)
|
||||||
{
|
{
|
||||||
char *asctime = PGTYPEStimestamp_to_asc(*ts);
|
char *asctime = PGTYPEStimestamp_to_asc(*ts);
|
||||||
|
|
||||||
@ -574,13 +574,13 @@ dttoasc(Timestamp *ts, char *output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
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);
|
return PGTYPEStimestamp_fmt_asc(ts, output, str_len, fmtstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
intoasc(Interval *i, char *str)
|
intoasc(interval *i, char *str)
|
||||||
{
|
{
|
||||||
str = PGTYPESinterval_to_asc(i);
|
str = PGTYPESinterval_to_asc(i);
|
||||||
|
|
||||||
|
@ -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
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -115,10 +115,10 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
unsigned long ures;
|
unsigned long ures;
|
||||||
double dres;
|
double dres;
|
||||||
char *scan_length;
|
char *scan_length;
|
||||||
Numeric *nres;
|
numeric *nres;
|
||||||
Date ddres;
|
date ddres;
|
||||||
Timestamp tres;
|
timestamp tres;
|
||||||
Interval *ires;
|
interval *ires;
|
||||||
|
|
||||||
case ECPGt_short:
|
case ECPGt_short:
|
||||||
case ECPGt_int:
|
case ECPGt_int:
|
||||||
@ -126,8 +126,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
if (pval)
|
if (pval)
|
||||||
{
|
{
|
||||||
res = strtol(pval, &scan_length, 10);
|
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 != '}')
|
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);
|
ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
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);
|
ures = strtoul(pval, &scan_length, 10);
|
||||||
if ((isarray && *scan_length != ',' && *scan_length != '}')
|
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);
|
ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
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);
|
*((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
|
||||||
if ((isarray && *scan_length != ',' && *scan_length != '}')
|
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);
|
ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
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);
|
*((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
|
||||||
if ((isarray && *scan_length != ',' && *scan_length != '}')
|
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);
|
ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
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);
|
nres = PGTYPESnumeric_from_asc("0.0", &scan_length);
|
||||||
|
|
||||||
if (type == ECPGt_numeric)
|
if (type == ECPGt_numeric)
|
||||||
PGTYPESnumeric_copy(nres, (Numeric *) (var + offset * act_tuple));
|
PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple));
|
||||||
else
|
else
|
||||||
PGTYPESnumeric_to_decimal(nres, (Decimal *) (var + offset * act_tuple));
|
PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ECPGt_interval:
|
case ECPGt_interval:
|
||||||
@ -429,7 +430,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
else
|
else
|
||||||
ires = PGTYPESinterval_from_asc("0 seconds", NULL);
|
ires = PGTYPESinterval_from_asc("0 seconds", NULL);
|
||||||
|
|
||||||
PGTYPESinterval_copy(ires, (Interval *) (var + offset * act_tuple));
|
PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple));
|
||||||
break;
|
break;
|
||||||
case ECPGt_date:
|
case ECPGt_date:
|
||||||
if (pval)
|
if (pval)
|
||||||
@ -449,7 +450,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
*((Date *) (var + offset * act_tuple)) = ddres;
|
*((date *) (var + offset * act_tuple)) = ddres;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -471,7 +472,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
*((Timestamp *) (var + offset * act_tuple)) = tres;
|
*((timestamp *) (var + offset * act_tuple)) = tres;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -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.
|
* 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;
|
char *str = NULL;
|
||||||
int slen;
|
int slen;
|
||||||
Numeric *nval = PGTYPESnumeric_new();
|
numeric *nval = PGTYPESnumeric_new();
|
||||||
|
|
||||||
if (var->arrsize > 1)
|
if (var->arrsize > 1)
|
||||||
{
|
{
|
||||||
for (element = 0; element < var->arrsize; element++)
|
for (element = 0; element < var->arrsize; element++)
|
||||||
{
|
{
|
||||||
if (var->type == ECPGt_numeric)
|
if (var->type == ECPGt_numeric)
|
||||||
PGTYPESnumeric_copy((Numeric *) ((var + var->offset * element)->value), nval);
|
PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);
|
||||||
else
|
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);
|
str = PGTYPESnumeric_to_asc(nval, 0);
|
||||||
PGTYPESnumeric_free(nval);
|
PGTYPESnumeric_free(nval);
|
||||||
@ -875,9 +875,9 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (var->type == ECPGt_numeric)
|
if (var->type == ECPGt_numeric)
|
||||||
PGTYPESnumeric_copy((Numeric *) (var->value), nval);
|
PGTYPESnumeric_copy((numeric *) (var->value), nval);
|
||||||
else
|
else
|
||||||
PGTYPESnumeric_from_decimal((Decimal *) (var->value), nval);
|
PGTYPESnumeric_from_decimal((decimal *) (var->value), nval);
|
||||||
|
|
||||||
str = PGTYPESnumeric_to_asc(nval, 0);
|
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++)
|
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);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],interval "), stmt->lineno)))
|
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
|
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);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGalloc(slen + sizeof("interval ") + 1, stmt->lineno)))
|
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++)
|
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);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],date "), stmt->lineno)))
|
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
|
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);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGalloc(slen + sizeof("date ") + 1, stmt->lineno)))
|
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++)
|
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);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [], timestamp "), stmt->lineno)))
|
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
|
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);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGalloc(slen + sizeof("timestamp") + 1, stmt->lineno)))
|
if (!(mallocedval = ECPGalloc(slen + sizeof("timestamp") + 1, stmt->lineno)))
|
||||||
|
@ -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
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -294,18 +294,18 @@ ECPGset_informix_null(enum ECPGttype type, void *ptr)
|
|||||||
*(((struct ECPGgeneric_varchar *) ptr)->arr) = 0x00;
|
*(((struct ECPGgeneric_varchar *) ptr)->arr) = 0x00;
|
||||||
break;
|
break;
|
||||||
case ECPGt_decimal:
|
case ECPGt_decimal:
|
||||||
memset((char *) ptr, 0, sizeof(Decimal));
|
memset((char *) ptr, 0, sizeof(decimal));
|
||||||
((Decimal *) ptr)->sign = NUMERIC_NAN;
|
((decimal *) ptr)->sign = NUMERIC_NAN;
|
||||||
break;
|
break;
|
||||||
case ECPGt_numeric:
|
case ECPGt_numeric:
|
||||||
memset((char *) ptr, 0, sizeof(Numeric));
|
memset((char *) ptr, 0, sizeof(numeric));
|
||||||
((Numeric *) ptr)->sign = NUMERIC_NAN;
|
((numeric *) ptr)->sign = NUMERIC_NAN;
|
||||||
break;
|
break;
|
||||||
case ECPGt_interval:
|
case ECPGt_interval:
|
||||||
memset((char *) ptr, 0xff, sizeof(Interval));
|
memset((char *) ptr, 0xff, sizeof(interval));
|
||||||
break;
|
break;
|
||||||
case ECPGt_timestamp:
|
case ECPGt_timestamp:
|
||||||
memset((char *) ptr, 0xff, sizeof(Timestamp));
|
memset((char *) ptr, 0xff, sizeof(timestamp));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -365,18 +365,18 @@ ECPGis_informix_null(enum ECPGttype type, void *ptr)
|
|||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case ECPGt_decimal:
|
case ECPGt_decimal:
|
||||||
if (((Decimal *) ptr)->sign == NUMERIC_NAN)
|
if (((decimal *) ptr)->sign == NUMERIC_NAN)
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case ECPGt_numeric:
|
case ECPGt_numeric:
|
||||||
if (((Numeric *) ptr)->sign == NUMERIC_NAN)
|
if (((numeric *) ptr)->sign == NUMERIC_NAN)
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case ECPGt_interval:
|
case ECPGt_interval:
|
||||||
return (_check(ptr, sizeof(Interval)));
|
return (_check(ptr, sizeof(interval)));
|
||||||
break;
|
break;
|
||||||
case ECPGt_timestamp:
|
case ECPGt_timestamp:
|
||||||
return (_check(ptr, sizeof(Timestamp)));
|
return (_check(ptr, sizeof(timestamp)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -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
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -49,15 +49,15 @@ ECPGtype_name(enum ECPGttype typ)
|
|||||||
case ECPGt_char_variable:
|
case ECPGt_char_variable:
|
||||||
return "char";
|
return "char";
|
||||||
case ECPGt_decimal:
|
case ECPGt_decimal:
|
||||||
return "Decimal";
|
return "decimal";
|
||||||
case ECPGt_numeric:
|
case ECPGt_numeric:
|
||||||
return "Numeric";
|
return "numeric";
|
||||||
case ECPGt_date:
|
case ECPGt_date:
|
||||||
return "Date";
|
return "date";
|
||||||
case ECPGt_timestamp:
|
case ECPGt_timestamp:
|
||||||
return "Timestamp";
|
return "timestamp";
|
||||||
case ECPGt_interval:
|
case ECPGt_interval:
|
||||||
return "Interval";
|
return "interval";
|
||||||
case ECPGt_const:
|
case ECPGt_const:
|
||||||
return "Const";
|
return "Const";
|
||||||
default:
|
default:
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
#include <pgtypes_interval.h>
|
#include <pgtypes_interval.h>
|
||||||
|
|
||||||
#ifndef dtime_t
|
#ifndef dtime_t
|
||||||
#define dtime_t Timestamp
|
#define dtime_t timestamp
|
||||||
#endif /* dtime_t */
|
#endif /* dtime_t */
|
||||||
|
|
||||||
#ifndef intrvl_t
|
#ifndef intrvl_t
|
||||||
#define intrvl_t Interval
|
#define intrvl_t interval
|
||||||
#endif /* intrvl_t */
|
#endif /* intrvl_t */
|
||||||
|
|
||||||
extern void dtcurrent(dtime_t *);
|
extern void dtcurrent(dtime_t *);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <pgtypes_numeric.h>
|
#include <pgtypes_numeric.h>
|
||||||
|
|
||||||
#ifndef dec_t
|
#ifndef dec_t
|
||||||
#define dec_t Decimal
|
#define dec_t decimal
|
||||||
#endif /* dec_t */
|
#endif /* dec_t */
|
||||||
|
|
||||||
int decadd(dec_t *, dec_t *, dec_t *);
|
int decadd(dec_t *, dec_t *, dec_t *);
|
||||||
|
@ -3,16 +3,16 @@
|
|||||||
|
|
||||||
#include <pgtypes_timestamp.h>
|
#include <pgtypes_timestamp.h>
|
||||||
|
|
||||||
#define Date long
|
#define date long
|
||||||
|
|
||||||
extern Date PGTYPESdate_from_asc(char *, char **);
|
extern date PGTYPESdate_from_asc(char *, char **);
|
||||||
extern char *PGTYPESdate_to_asc(Date);
|
extern char *PGTYPESdate_to_asc(date);
|
||||||
extern Date PGTYPESdate_from_timestamp(Timestamp);
|
extern date PGTYPESdate_from_timestamp(timestamp);
|
||||||
extern void PGTYPESdate_julmdy(Date, int *);
|
extern void PGTYPESdate_julmdy(date, int *);
|
||||||
extern void PGTYPESdate_mdyjul(int *, Date *);
|
extern void PGTYPESdate_mdyjul(int *, date *);
|
||||||
extern int PGTYPESdate_dayofweek(Date);
|
extern int PGTYPESdate_dayofweek(date);
|
||||||
extern void PGTYPESdate_today(Date *);
|
extern void PGTYPESdate_today(date *);
|
||||||
extern int PGTYPESdate_defmt_asc(Date *, char *, char *);
|
extern int PGTYPESdate_defmt_asc(date *, char *, char *);
|
||||||
extern int PGTYPESdate_fmt_asc(Date, char *, char *);
|
extern int PGTYPESdate_fmt_asc(date, char *, char *);
|
||||||
|
|
||||||
#endif /* PGTYPES_DATETIME */
|
#endif /* PGTYPES_DATETIME */
|
||||||
|
@ -12,10 +12,10 @@ typedef struct
|
|||||||
#endif
|
#endif
|
||||||
long month; /* months and years, after time for
|
long month; /* months and years, after time for
|
||||||
* alignment */
|
* alignment */
|
||||||
} Interval;
|
} interval;
|
||||||
|
|
||||||
extern Interval *PGTYPESinterval_from_asc(char *, char **);
|
extern interval *PGTYPESinterval_from_asc(char *, char **);
|
||||||
extern char *PGTYPESinterval_to_asc(Interval *);
|
extern char *PGTYPESinterval_to_asc(interval *);
|
||||||
extern int PGTYPESinterval_copy(Interval *, Interval *);
|
extern int PGTYPESinterval_copy(interval *, interval *);
|
||||||
|
|
||||||
#endif /* PGTYPES_INTERVAL */
|
#endif /* PGTYPES_INTERVAL */
|
||||||
|
@ -23,7 +23,7 @@ typedef struct
|
|||||||
* NUMERIC_NAN */
|
* NUMERIC_NAN */
|
||||||
NumericDigit *buf; /* start of alloc'd space for digits[] */
|
NumericDigit *buf; /* start of alloc'd space for digits[] */
|
||||||
NumericDigit *digits; /* decimal digits */
|
NumericDigit *digits; /* decimal digits */
|
||||||
} Numeric;
|
} numeric;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -35,25 +35,25 @@ typedef struct
|
|||||||
int sign; /* NUMERIC_POS, NUMERIC_NEG, or
|
int sign; /* NUMERIC_POS, NUMERIC_NEG, or
|
||||||
* NUMERIC_NAN */
|
* NUMERIC_NAN */
|
||||||
NumericDigit digits[DECSIZE]; /* decimal digits */
|
NumericDigit digits[DECSIZE]; /* decimal digits */
|
||||||
} Decimal;
|
} decimal;
|
||||||
|
|
||||||
Numeric *PGTYPESnumeric_new(void);
|
numeric *PGTYPESnumeric_new(void);
|
||||||
void PGTYPESnumeric_free(Numeric *);
|
void PGTYPESnumeric_free(numeric *);
|
||||||
Numeric *PGTYPESnumeric_from_asc(char *, char **);
|
numeric *PGTYPESnumeric_from_asc(char *, char **);
|
||||||
char *PGTYPESnumeric_to_asc(Numeric *, int);
|
char *PGTYPESnumeric_to_asc(numeric *, int);
|
||||||
int PGTYPESnumeric_add(Numeric *, Numeric *, Numeric *);
|
int PGTYPESnumeric_add(numeric *, numeric *, numeric *);
|
||||||
int PGTYPESnumeric_sub(Numeric *, Numeric *, Numeric *);
|
int PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
|
||||||
int PGTYPESnumeric_mul(Numeric *, Numeric *, Numeric *);
|
int PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
|
||||||
int PGTYPESnumeric_div(Numeric *, Numeric *, Numeric *);
|
int PGTYPESnumeric_div(numeric *, numeric *, numeric *);
|
||||||
int PGTYPESnumeric_cmp(Numeric *, Numeric *);
|
int PGTYPESnumeric_cmp(numeric *, numeric *);
|
||||||
int PGTYPESnumeric_from_int(signed int, Numeric *);
|
int PGTYPESnumeric_from_int(signed int, numeric *);
|
||||||
int PGTYPESnumeric_from_long(signed long int, Numeric *);
|
int PGTYPESnumeric_from_long(signed long int, numeric *);
|
||||||
int PGTYPESnumeric_copy(Numeric *, Numeric *);
|
int PGTYPESnumeric_copy(numeric *, numeric *);
|
||||||
int PGTYPESnumeric_from_double(double, Numeric *);
|
int PGTYPESnumeric_from_double(double, numeric *);
|
||||||
int PGTYPESnumeric_to_double(Numeric *, double *);
|
int PGTYPESnumeric_to_double(numeric *, double *);
|
||||||
int PGTYPESnumeric_to_int(Numeric *, int *);
|
int PGTYPESnumeric_to_int(numeric *, int *);
|
||||||
int PGTYPESnumeric_to_long(Numeric *, long *);
|
int PGTYPESnumeric_to_long(numeric *, long *);
|
||||||
int PGTYPESnumeric_to_decimal(Numeric *, Decimal *);
|
int PGTYPESnumeric_to_decimal(numeric *, decimal *);
|
||||||
int PGTYPESnumeric_from_decimal(Decimal *, Numeric *);
|
int PGTYPESnumeric_from_decimal(decimal *, numeric *);
|
||||||
|
|
||||||
#endif /* PGTYPES_NUMERIC */
|
#endif /* PGTYPES_NUMERIC */
|
||||||
|
@ -4,19 +4,19 @@
|
|||||||
#include <pgtypes_interval.h>
|
#include <pgtypes_interval.h>
|
||||||
|
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
typedef int64 Timestamp;
|
typedef int64 timestamp;
|
||||||
typedef int64 TimestampTz;
|
typedef int64 TimestampTz;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
typedef double Timestamp;
|
typedef double timestamp;
|
||||||
typedef double TimestampTz;
|
typedef double TimestampTz;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern Timestamp PGTYPEStimestamp_from_asc(char *, char **);
|
extern timestamp PGTYPEStimestamp_from_asc(char *, char **);
|
||||||
extern char *PGTYPEStimestamp_to_asc(Timestamp);
|
extern char *PGTYPEStimestamp_to_asc(timestamp);
|
||||||
extern int PGTYPEStimestamp_sub(Timestamp *, Timestamp *, Interval *);
|
extern int PGTYPEStimestamp_sub(timestamp *, timestamp *, interval *);
|
||||||
extern int PGTYPEStimestamp_fmt_asc(Timestamp *, char *, int, char *);
|
extern int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, char *);
|
||||||
extern void PGTYPEStimestamp_current(Timestamp *);
|
extern void PGTYPEStimestamp_current(timestamp *);
|
||||||
extern int PGTYPEStimestamp_defmt_asc(char *, char *, Timestamp *);
|
extern int PGTYPEStimestamp_defmt_asc(char *, char *, timestamp *);
|
||||||
|
|
||||||
#endif /* PGTYPES_TIMESTAMP */
|
#endif /* PGTYPES_TIMESTAMP */
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
#include "pgtypes_error.h"
|
#include "pgtypes_error.h"
|
||||||
#include "pgtypes_date.h"
|
#include "pgtypes_date.h"
|
||||||
|
|
||||||
Date
|
date
|
||||||
PGTYPESdate_from_timestamp(Timestamp dt)
|
PGTYPESdate_from_timestamp(timestamp dt)
|
||||||
{
|
{
|
||||||
Date dDate;
|
date dDate;
|
||||||
|
|
||||||
dDate = 0; /* suppress compiler warning */
|
dDate = 0; /* suppress compiler warning */
|
||||||
|
|
||||||
@ -30,11 +30,11 @@ PGTYPESdate_from_timestamp(Timestamp dt)
|
|||||||
return dDate;
|
return dDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
Date
|
date
|
||||||
PGTYPESdate_from_asc(char *str, char **endptr)
|
PGTYPESdate_from_asc(char *str, char **endptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
Date dDate;
|
date dDate;
|
||||||
fsec_t fsec;
|
fsec_t fsec;
|
||||||
struct tm tt,
|
struct tm tt,
|
||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
@ -83,7 +83,7 @@ PGTYPESdate_from_asc(char *str, char **endptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
PGTYPESdate_to_asc(Date dDate)
|
PGTYPESdate_to_asc(date dDate)
|
||||||
{
|
{
|
||||||
struct tm tt,
|
struct tm tt,
|
||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
@ -97,7 +97,7 @@ PGTYPESdate_to_asc(Date dDate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PGTYPESdate_julmdy(Date jd, int *mdy)
|
PGTYPESdate_julmdy(date jd, int *mdy)
|
||||||
{
|
{
|
||||||
int y,
|
int y,
|
||||||
m,
|
m,
|
||||||
@ -110,17 +110,17 @@ PGTYPESdate_julmdy(Date jd, int *mdy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PGTYPESdate_mdyjul(int *mdy, Date * jdate)
|
PGTYPESdate_mdyjul(int *mdy, date * jdate)
|
||||||
{
|
{
|
||||||
/* month is mdy[0] */
|
/* month is mdy[0] */
|
||||||
/* day is mdy[1] */
|
/* day is mdy[1] */
|
||||||
/* year is mdy[2] */
|
/* 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
|
int
|
||||||
PGTYPESdate_dayofweek(Date dDate)
|
PGTYPESdate_dayofweek(date dDate)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Sunday: 0 Monday: 1 Tuesday: 2 Wednesday: 3
|
* Sunday: 0 Monday: 1 Tuesday: 2 Wednesday: 3
|
||||||
@ -130,7 +130,7 @@ PGTYPESdate_dayofweek(Date dDate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PGTYPESdate_today(Date * d)
|
PGTYPESdate_today(date * d)
|
||||||
{
|
{
|
||||||
struct tm ts;
|
struct tm ts;
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ PGTYPESdate_today(Date * d)
|
|||||||
#define PGTYPES_FMTDATE_YEAR_DIGITS_LONG 6
|
#define PGTYPES_FMTDATE_YEAR_DIGITS_LONG 6
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESdate_fmt_asc(Date dDate, char *fmtstring, char *outbuf)
|
PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf)
|
||||||
{
|
{
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
@ -315,7 +315,7 @@ PGTYPESdate_fmt_asc(Date dDate, char *fmtstring, char *outbuf)
|
|||||||
|
|
||||||
#define PGTYPES_DATE_MONTH_MAXLENGTH 20 /* probably even less :-) */
|
#define PGTYPES_DATE_MONTH_MAXLENGTH 20 /* probably even less :-) */
|
||||||
int
|
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
|
* token[2] = { 4,6 } means that token 2 starts at position 4 and ends
|
||||||
|
@ -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 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 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);
|
int DecodeUnits(int field, char *lowtoken, int *val);
|
||||||
bool ClearDateCache(bool, bool, bool);
|
bool ClearDateCache(bool, bool, bool);
|
||||||
|
@ -2736,11 +2736,11 @@ pgtypes_defmt_scan(union un_fmt_comb * scan_val, int scan_type, char **pstr, cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX range checking */
|
/* 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 *, 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 *year, int *month, int *day,
|
||||||
int *hour, int *minute, int *second,
|
int *hour, int *minute, int *second,
|
||||||
int *tz)
|
int *tz)
|
||||||
|
@ -677,7 +677,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
|
|||||||
* Convert a interval data type to a tm structure.
|
* Convert a interval data type to a tm structure.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
interval2tm(Interval span, struct tm * tm, fsec_t *fsec)
|
interval2tm(interval span, struct tm * tm, fsec_t *fsec)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int64 time;
|
int64 time;
|
||||||
@ -721,7 +721,7 @@ interval2tm(Interval span, struct tm * tm, fsec_t *fsec)
|
|||||||
} /* interval2tm() */
|
} /* interval2tm() */
|
||||||
|
|
||||||
static int
|
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);
|
span->month = ((tm->tm_year * 12) + tm->tm_mon);
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
@ -740,10 +740,10 @@ tm2interval(struct tm * tm, fsec_t fsec, Interval *span)
|
|||||||
return 0;
|
return 0;
|
||||||
} /* tm2interval() */
|
} /* tm2interval() */
|
||||||
|
|
||||||
Interval *
|
interval *
|
||||||
PGTYPESinterval_from_asc(char *str, char **endptr)
|
PGTYPESinterval_from_asc(char *str, char **endptr)
|
||||||
{
|
{
|
||||||
Interval *result = NULL;
|
interval *result = NULL;
|
||||||
fsec_t fsec;
|
fsec_t fsec;
|
||||||
struct tm tt,
|
struct tm tt,
|
||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
@ -776,7 +776,7 @@ PGTYPESinterval_from_asc(char *str, char **endptr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (Interval *) pgtypes_alloc(sizeof(Interval));
|
result = (interval *) pgtypes_alloc(sizeof(interval));
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -796,7 +796,7 @@ PGTYPESinterval_from_asc(char *str, char **endptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
PGTYPESinterval_to_asc(Interval *span)
|
PGTYPESinterval_to_asc(interval *span)
|
||||||
{
|
{
|
||||||
struct tm tt,
|
struct tm tt,
|
||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
@ -820,7 +820,7 @@ PGTYPESinterval_to_asc(Interval *span)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESinterval_copy(Interval *intvlsrc, Interval *intrcldest)
|
PGTYPESinterval_copy(interval *intvlsrc, interval *intrcldest)
|
||||||
{
|
{
|
||||||
intrcldest->time = intvlsrc->time;
|
intrcldest->time = intvlsrc->time;
|
||||||
intrcldest->month = intvlsrc->month;
|
intrcldest->month = intvlsrc->month;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define Max(x, y) ((x) > (y) ? (x) : (y))
|
#define Max(x, y) ((x) > (y) ? (x) : (y))
|
||||||
#define Min(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_alloc(size) ((NumericDigit *) pgtypes_alloc(size))
|
||||||
#define digitbuf_free(buf) \
|
#define digitbuf_free(buf) \
|
||||||
@ -28,7 +28,7 @@
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
apply_typmod(Numeric *var, long typmod)
|
apply_typmod(numeric *var, long typmod)
|
||||||
{
|
{
|
||||||
int precision;
|
int precision;
|
||||||
int scale;
|
int scale;
|
||||||
@ -108,7 +108,7 @@ apply_typmod(Numeric *var, long typmod)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
alloc_var(Numeric *var, int ndigits)
|
alloc_var(numeric *var, int ndigits)
|
||||||
{
|
{
|
||||||
digitbuf_free(var->buf);
|
digitbuf_free(var->buf);
|
||||||
var->buf = digitbuf_alloc(ndigits + 1);
|
var->buf = digitbuf_alloc(ndigits + 1);
|
||||||
@ -120,12 +120,12 @@ alloc_var(Numeric *var, int ndigits)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Numeric *
|
numeric *
|
||||||
PGTYPESnumeric_new(void)
|
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;
|
return NULL;
|
||||||
|
|
||||||
if (alloc_var(var, 0) < 0)
|
if (alloc_var(var, 0) < 0)
|
||||||
@ -141,7 +141,7 @@ PGTYPESnumeric_new(void)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
bool have_dp = FALSE;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -270,7 +270,7 @@ set_var_from_str(char *str, char **ptr, Numeric *dest)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
get_str_from_var(Numeric *var, int dscale)
|
get_str_from_var(numeric *var, int dscale)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
char *cp;
|
char *cp;
|
||||||
@ -356,10 +356,10 @@ get_str_from_var(Numeric *var, int dscale)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
Numeric *
|
numeric *
|
||||||
PGTYPESnumeric_from_asc(char *str, char **endptr)
|
PGTYPESnumeric_from_asc(char *str, char **endptr)
|
||||||
{
|
{
|
||||||
Numeric *value = (Numeric *) pgtypes_alloc(sizeof(Numeric));
|
numeric *value = (numeric *) pgtypes_alloc(sizeof(numeric));
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -384,9 +384,9 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
PGTYPESnumeric_to_asc(Numeric *num, int dscale)
|
PGTYPESnumeric_to_asc(numeric *num, int dscale)
|
||||||
{
|
{
|
||||||
if (dscale <= 0)
|
if (dscale < 0)
|
||||||
dscale = num->dscale;
|
dscale = num->dscale;
|
||||||
|
|
||||||
return (get_str_from_var(num, dscale));
|
return (get_str_from_var(num, dscale));
|
||||||
@ -400,7 +400,7 @@ PGTYPESnumeric_to_asc(Numeric *num, int dscale)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
zero_var(Numeric *var)
|
zero_var(numeric *var)
|
||||||
{
|
{
|
||||||
digitbuf_free(var->buf);
|
digitbuf_free(var->buf);
|
||||||
var->buf = NULL;
|
var->buf = NULL;
|
||||||
@ -411,7 +411,7 @@ zero_var(Numeric *var)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PGTYPESnumeric_free(Numeric *var)
|
PGTYPESnumeric_free(numeric *var)
|
||||||
{
|
{
|
||||||
digitbuf_free(var->buf);
|
digitbuf_free(var->buf);
|
||||||
free(var);
|
free(var);
|
||||||
@ -427,7 +427,7 @@ PGTYPESnumeric_free(Numeric *var)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
cmp_abs(Numeric *var1, Numeric *var2)
|
cmp_abs(numeric *var1, numeric *var2)
|
||||||
{
|
{
|
||||||
int i1 = 0;
|
int i1 = 0;
|
||||||
int i2 = 0;
|
int i2 = 0;
|
||||||
@ -485,7 +485,7 @@ cmp_abs(Numeric *var1, Numeric *var2)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
add_abs(Numeric *var1, Numeric *var2, Numeric *result)
|
add_abs(numeric *var1, numeric *var2, numeric *result)
|
||||||
{
|
{
|
||||||
NumericDigit *res_buf;
|
NumericDigit *res_buf;
|
||||||
NumericDigit *res_digits;
|
NumericDigit *res_digits;
|
||||||
@ -573,7 +573,7 @@ add_abs(Numeric *var1, Numeric *var2, Numeric *result)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
sub_abs(Numeric *var1, Numeric *var2, Numeric *result)
|
sub_abs(numeric *var1, numeric *var2, numeric *result)
|
||||||
{
|
{
|
||||||
NumericDigit *res_buf;
|
NumericDigit *res_buf;
|
||||||
NumericDigit *res_digits;
|
NumericDigit *res_digits;
|
||||||
@ -657,7 +657,7 @@ sub_abs(Numeric *var1, Numeric *var2, Numeric *result)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
int
|
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
|
* Decide on the signs of the two variables what to do
|
||||||
@ -786,7 +786,7 @@ PGTYPESnumeric_add(Numeric *var1, Numeric *var2, Numeric *result)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
int
|
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
|
* Decide on the signs of the two variables what to do
|
||||||
@ -917,7 +917,7 @@ PGTYPESnumeric_sub(Numeric *var1, Numeric *var2, Numeric *result)
|
|||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_mul(Numeric *var1, Numeric *var2, Numeric *result)
|
PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result)
|
||||||
{
|
{
|
||||||
NumericDigit *res_buf;
|
NumericDigit *res_buf;
|
||||||
NumericDigit *res_digits;
|
NumericDigit *res_digits;
|
||||||
@ -1008,7 +1008,7 @@ PGTYPESnumeric_mul(Numeric *var1, Numeric *var2, Numeric *result)
|
|||||||
* Note that this must be called before div_var.
|
* Note that this must be called before div_var.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
select_div_scale(Numeric *var1, Numeric *var2, int *rscale)
|
select_div_scale(numeric *var1, numeric *var2, int *rscale)
|
||||||
{
|
{
|
||||||
int weight1,
|
int weight1,
|
||||||
weight2,
|
weight2,
|
||||||
@ -1075,14 +1075,14 @@ select_div_scale(Numeric *var1, Numeric *var2, int *rscale)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_div(Numeric *var1, Numeric *var2, Numeric *result)
|
PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result)
|
||||||
{
|
{
|
||||||
NumericDigit *res_digits;
|
NumericDigit *res_digits;
|
||||||
int res_ndigits;
|
int res_ndigits;
|
||||||
int res_sign;
|
int res_sign;
|
||||||
int res_weight;
|
int res_weight;
|
||||||
Numeric dividend;
|
numeric dividend;
|
||||||
Numeric divisor[10];
|
numeric divisor[10];
|
||||||
int ndigits_tmp;
|
int ndigits_tmp;
|
||||||
int weight_tmp;
|
int weight_tmp;
|
||||||
int rscale_tmp;
|
int rscale_tmp;
|
||||||
@ -1198,7 +1198,7 @@ PGTYPESnumeric_div(Numeric *var1, Numeric *var2, Numeric *result)
|
|||||||
int i;
|
int i;
|
||||||
long sum = 0;
|
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].buf = digitbuf_alloc(divisor[guess].ndigits);
|
||||||
divisor[guess].digits = divisor[guess].buf;
|
divisor[guess].digits = divisor[guess].buf;
|
||||||
for (i = divisor[1].ndigits - 1; i >= 0; i--)
|
for (i = divisor[1].ndigits - 1; i >= 0; i--)
|
||||||
@ -1281,7 +1281,7 @@ PGTYPESnumeric_div(Numeric *var1, Numeric *var2, Numeric *result)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_cmp(Numeric *var1, Numeric *var2)
|
PGTYPESnumeric_cmp(numeric *var1, numeric *var2)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* use cmp_abs function to calculate the result */
|
/* use cmp_abs function to calculate the result */
|
||||||
@ -1312,7 +1312,7 @@ PGTYPESnumeric_cmp(Numeric *var1, Numeric *var2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_from_int(signed int int_val, Numeric *var)
|
PGTYPESnumeric_from_int(signed int int_val, numeric *var)
|
||||||
{
|
{
|
||||||
/* implicit conversion */
|
/* implicit conversion */
|
||||||
signed long int long_int = int_val;
|
signed long int long_int = int_val;
|
||||||
@ -1321,7 +1321,7 @@ PGTYPESnumeric_from_int(signed int int_val, Numeric *var)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
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 */
|
/* calculate the size of the long int number */
|
||||||
/* a number n needs log_10 n digits */
|
/* a number n needs log_10 n digits */
|
||||||
@ -1382,7 +1382,7 @@ PGTYPESnumeric_from_long(signed long int long_val, Numeric *var)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_copy(Numeric *src, Numeric *dst)
|
PGTYPESnumeric_copy(numeric *src, numeric *dst)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1403,10 +1403,10 @@ PGTYPESnumeric_copy(Numeric *src, Numeric *dst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_from_double(double d, Numeric *dst)
|
PGTYPESnumeric_from_double(double d, numeric *dst)
|
||||||
{
|
{
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
Numeric *tmp;
|
numeric *tmp;
|
||||||
|
|
||||||
if (sprintf(buffer, "%f", d) == 0)
|
if (sprintf(buffer, "%f", d) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1420,7 +1420,7 @@ PGTYPESnumeric_from_double(double d, Numeric *dst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
numericvar_to_double_no_overflow(Numeric *var, double *dp)
|
numericvar_to_double_no_overflow(numeric *var, double *dp)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
double val;
|
double val;
|
||||||
@ -1444,7 +1444,7 @@ numericvar_to_double_no_overflow(Numeric *var, double *dp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_to_double(Numeric *nv, double *dp)
|
PGTYPESnumeric_to_double(numeric *nv, double *dp)
|
||||||
{
|
{
|
||||||
double tmp;
|
double tmp;
|
||||||
int i;
|
int i;
|
||||||
@ -1456,7 +1456,7 @@ PGTYPESnumeric_to_double(Numeric *nv, double *dp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_to_int(Numeric *nv, int *ip)
|
PGTYPESnumeric_to_int(numeric *nv, int *ip)
|
||||||
{
|
{
|
||||||
long l;
|
long l;
|
||||||
int i;
|
int i;
|
||||||
@ -1475,7 +1475,7 @@ PGTYPESnumeric_to_int(Numeric *nv, int *ip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_to_long(Numeric *nv, long *lp)
|
PGTYPESnumeric_to_long(numeric *nv, long *lp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
long l = 0;
|
long l = 0;
|
||||||
@ -1503,7 +1503,7 @@ PGTYPESnumeric_to_long(Numeric *nv, long *lp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_to_decimal(Numeric *src, Decimal * dst)
|
PGTYPESnumeric_to_decimal(numeric *src, decimal * dst)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1526,7 +1526,7 @@ PGTYPESnumeric_to_decimal(Numeric *src, Decimal * dst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPESnumeric_from_decimal(Decimal * src, Numeric *dst)
|
PGTYPESnumeric_from_decimal(decimal * src, numeric *dst)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "pgtypes_date.h"
|
#include "pgtypes_date.h"
|
||||||
#include "datetime.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 *);
|
int *, int *, int *, int *);
|
||||||
|
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
@ -31,8 +31,8 @@ time2t(const int hour, const int min, const int sec, const fsec_t fsec)
|
|||||||
} /* time2t() */
|
} /* time2t() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Timestamp
|
static timestamp
|
||||||
dt2local(Timestamp dt, int tz)
|
dt2local(timestamp dt, int tz)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
dt -= (tz * INT64CONST(1000000));
|
dt -= (tz * INT64CONST(1000000));
|
||||||
@ -51,22 +51,21 @@ dt2local(Timestamp dt, int tz)
|
|||||||
* Returns -1 on failure (overflow).
|
* Returns -1 on failure (overflow).
|
||||||
*/
|
*/
|
||||||
int
|
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
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int date;
|
int dDate;
|
||||||
int64 time;
|
int64 time;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
double date,
|
double dDate, time;
|
||||||
time;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Julian day routines are not correct for negative Julian days */
|
/* Julian day routines are not correct for negative Julian days */
|
||||||
if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday))
|
if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday))
|
||||||
return -1;
|
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);
|
time = time2t(tm->tm_hour, tm->tm_min, tm->tm_sec, fsec);
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
*result = (date * INT64CONST(86400000000)) + time;
|
*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))
|
if ((*result < 0) ? (date >= 0) : (date < 0))
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
#else
|
||||||
*result = ((date * 86400) + time);
|
*result = ((dDate * 86400) + time);
|
||||||
#endif
|
#endif
|
||||||
if (tzp != NULL)
|
if (tzp != NULL)
|
||||||
*result = dt2local(*result, -(*tzp));
|
*result = dt2local(*result, -(*tzp));
|
||||||
@ -85,10 +84,10 @@ tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
|
|||||||
return 0;
|
return 0;
|
||||||
} /* tm2timestamp() */
|
} /* tm2timestamp() */
|
||||||
|
|
||||||
static Timestamp
|
static timestamp
|
||||||
SetEpochTimestamp(void)
|
SetEpochTimestamp(void)
|
||||||
{
|
{
|
||||||
Timestamp dt;
|
timestamp dt;
|
||||||
struct tm tt,
|
struct tm tt,
|
||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
|
|
||||||
@ -98,7 +97,7 @@ SetEpochTimestamp(void)
|
|||||||
} /* SetEpochTimestamp() */
|
} /* SetEpochTimestamp() */
|
||||||
|
|
||||||
static void
|
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
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int64 time;
|
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
|
* local time zone. If out of this range, leave as GMT. - tgl 97/05/27
|
||||||
*/
|
*/
|
||||||
static int
|
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
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int date,
|
int dDate, date0;
|
||||||
date0;
|
|
||||||
int64 time;
|
int64 time;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
double date,
|
double dDate, date0;
|
||||||
date0;
|
|
||||||
double time;
|
double time;
|
||||||
#endif
|
#endif
|
||||||
time_t utime;
|
time_t utime;
|
||||||
@ -163,31 +160,31 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
|
|||||||
|
|
||||||
time = dt;
|
time = dt;
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
TMODULO(time, date, INT64CONST(86400000000));
|
TMODULO(time, dDate, INT64CONST(86400000000));
|
||||||
|
|
||||||
if (time < INT64CONST(0))
|
if (time < INT64CONST(0))
|
||||||
{
|
{
|
||||||
time += INT64CONST(86400000000);
|
time += INT64CONST(86400000000);
|
||||||
date -= 1;
|
dDate -= 1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
TMODULO(time, date, 86400e0);
|
TMODULO(time, dDate, 86400e0);
|
||||||
|
|
||||||
if (time < 0)
|
if (time < 0)
|
||||||
{
|
{
|
||||||
time += 86400;
|
time += 86400;
|
||||||
date -= 1;
|
dDate -= 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Julian day routine does not work for negative Julian days */
|
/* Julian day routine does not work for negative Julian days */
|
||||||
if (date < -date0)
|
if (dDate < -date0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* add offset to go from J2000 back to standard Julian date */
|
/* 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);
|
dt2time(time, &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec);
|
||||||
|
|
||||||
if (tzp != NULL)
|
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.
|
* * Convert reserved timestamp data type to string.
|
||||||
* */
|
* */
|
||||||
static int
|
static int
|
||||||
EncodeSpecialTimestamp(Timestamp dt, char *str)
|
EncodeSpecialTimestamp(timestamp dt, char *str)
|
||||||
{
|
{
|
||||||
if (TIMESTAMP_IS_NOBEGIN(dt))
|
if (TIMESTAMP_IS_NOBEGIN(dt))
|
||||||
strcpy(str, EARLY);
|
strcpy(str, EARLY);
|
||||||
@ -272,10 +269,10 @@ EncodeSpecialTimestamp(Timestamp dt, char *str)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
} /* EncodeSpecialTimestamp() */
|
} /* EncodeSpecialTimestamp() */
|
||||||
|
|
||||||
Timestamp
|
timestamp
|
||||||
PGTYPEStimestamp_from_asc(char *str, char **endptr)
|
PGTYPEStimestamp_from_asc(char *str, char **endptr)
|
||||||
{
|
{
|
||||||
Timestamp result;
|
timestamp result;
|
||||||
|
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
int64 noresult = 0;
|
int64 noresult = 0;
|
||||||
@ -346,7 +343,7 @@ PGTYPEStimestamp_from_asc(char *str, char **endptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
PGTYPEStimestamp_to_asc(Timestamp tstamp)
|
PGTYPEStimestamp_to_asc(timestamp tstamp)
|
||||||
{
|
{
|
||||||
struct tm tt,
|
struct tm tt,
|
||||||
*tm = &tt;
|
*tm = &tt;
|
||||||
@ -369,7 +366,7 @@ PGTYPEStimestamp_to_asc(Timestamp tstamp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PGTYPEStimestamp_current(Timestamp *ts)
|
PGTYPEStimestamp_current(timestamp *ts)
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
@ -379,7 +376,7 @@ PGTYPEStimestamp_current(Timestamp *ts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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)
|
char *output, int *pstr_len, char *fmtstr)
|
||||||
{
|
{
|
||||||
union un_fmt_comb replace_val;
|
union un_fmt_comb replace_val;
|
||||||
@ -769,11 +766,11 @@ dttofmtasc_replace(Timestamp *ts, Date dDate, int dow, struct tm * tm,
|
|||||||
|
|
||||||
|
|
||||||
int
|
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;
|
struct tm tm;
|
||||||
fsec_t fsec;
|
fsec_t fsec;
|
||||||
Date dDate;
|
date dDate;
|
||||||
int dow;
|
int dow;
|
||||||
|
|
||||||
dDate = PGTYPESdate_from_timestamp(*ts);
|
dDate = PGTYPESdate_from_timestamp(*ts);
|
||||||
@ -784,7 +781,7 @@ PGTYPEStimestamp_fmt_asc(Timestamp *ts, char *output, int str_len, char *fmtstr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
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))
|
if (TIMESTAMP_NOT_FINITE(*ts1) || TIMESTAMP_NOT_FINITE(*ts2))
|
||||||
return PGTYPES_TS_ERR_EINFTIME;
|
return PGTYPES_TS_ERR_EINFTIME;
|
||||||
@ -801,7 +798,7 @@ PGTYPEStimestamp_sub(Timestamp *ts1, Timestamp *ts2, Interval *iv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PGTYPEStimestamp_defmt_asc(char *str, char *fmt, Timestamp *d)
|
PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d)
|
||||||
{
|
{
|
||||||
int year,
|
int year,
|
||||||
month,
|
month,
|
||||||
|
@ -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. */
|
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
|
||||||
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
|
/* (C) Michael Meskes <meskes@postgresql.org> 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;
|
compat = (strcmp(optarg, "INFORMIX") == 0) ? ECPG_COMPAT_INFORMIX : ECPG_COMPAT_INFORMIX_SE;
|
||||||
/* system_includes = true; */
|
/* system_includes = true; */
|
||||||
add_preprocessor_define("dec_t=Numeric");
|
add_preprocessor_define("dec_t=numeric");
|
||||||
add_preprocessor_define("intrvl_t=Interval");
|
add_preprocessor_define("intrvl_t=interval");
|
||||||
add_preprocessor_define("dtime_t=Timestamp");
|
add_preprocessor_define("dtime_t=timestamp");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -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 */
|
/* Copyright comment */
|
||||||
%{
|
%{
|
||||||
@ -4505,7 +4505,7 @@ single_vt_type: common_type
|
|||||||
else if (strcmp($1, "decimal") == 0)
|
else if (strcmp($1, "decimal") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_decimal;
|
$$.type_enum = ECPGt_decimal;
|
||||||
$$.type_str = make_str("Decimal");
|
$$.type_str = make_str("decimal");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4513,7 +4513,7 @@ single_vt_type: common_type
|
|||||||
else if (strcmp($1, "date") == 0)
|
else if (strcmp($1, "date") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_date;
|
$$.type_enum = ECPGt_date;
|
||||||
$$.type_str = make_str("Date");
|
$$.type_str = make_str("date");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4521,7 +4521,7 @@ single_vt_type: common_type
|
|||||||
else if (strcmp($1, "timestamp") == 0)
|
else if (strcmp($1, "timestamp") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_timestamp;
|
$$.type_enum = ECPGt_timestamp;
|
||||||
$$.type_str = make_str("Timestamp");
|
$$.type_str = make_str("timestamp");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4529,7 +4529,7 @@ single_vt_type: common_type
|
|||||||
else if (strcmp($1, "datetime") == 0)
|
else if (strcmp($1, "datetime") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_timestamp;
|
$$.type_enum = ECPGt_timestamp;
|
||||||
$$.type_str = make_str("Timestamp");
|
$$.type_str = make_str("timestamp");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4537,7 +4537,7 @@ single_vt_type: common_type
|
|||||||
else if (strcmp($1, "interval") == 0)
|
else if (strcmp($1, "interval") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_interval;
|
$$.type_enum = ECPGt_interval;
|
||||||
$$.type_str = make_str("Interval");
|
$$.type_str = make_str("interval");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4806,12 +4806,12 @@ common_type: simple_type
|
|||||||
if (strcmp($1, "numeric") == 0)
|
if (strcmp($1, "numeric") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_numeric;
|
$$.type_enum = ECPGt_numeric;
|
||||||
$$.type_str = make_str("Numeric");
|
$$.type_str = make_str("numeric");
|
||||||
}
|
}
|
||||||
else if (strcmp($1, "decimal") == 0)
|
else if (strcmp($1, "decimal") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_decimal;
|
$$.type_enum = ECPGt_decimal;
|
||||||
$$.type_str = make_str("Decimal");
|
$$.type_str = make_str("decimal");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mmerror(PARSE_ERROR, ET_ERROR, "Only numeric/decimal have precision/scale argument");
|
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)
|
else if (strcmp($1, "numeric") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_numeric;
|
$$.type_enum = ECPGt_numeric;
|
||||||
$$.type_str = make_str("Numeric");
|
$$.type_str = make_str("numeric");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4867,7 +4867,7 @@ var_type: common_type
|
|||||||
else if (strcmp($1, "decimal") == 0)
|
else if (strcmp($1, "decimal") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_decimal;
|
$$.type_enum = ECPGt_decimal;
|
||||||
$$.type_str = make_str("Deciaml");
|
$$.type_str = make_str("decimal");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4875,7 +4875,7 @@ var_type: common_type
|
|||||||
else if (strcmp($1, "date") == 0)
|
else if (strcmp($1, "date") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_date;
|
$$.type_enum = ECPGt_date;
|
||||||
$$.type_str = make_str("Date");
|
$$.type_str = make_str("date");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4883,7 +4883,7 @@ var_type: common_type
|
|||||||
else if (strcmp($1, "timestamp") == 0)
|
else if (strcmp($1, "timestamp") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_timestamp;
|
$$.type_enum = ECPGt_timestamp;
|
||||||
$$.type_str = make_str("Timestamp");
|
$$.type_str = make_str("timestamp");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4891,7 +4891,7 @@ var_type: common_type
|
|||||||
else if (strcmp($1, "interval") == 0)
|
else if (strcmp($1, "interval") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_interval;
|
$$.type_enum = ECPGt_interval;
|
||||||
$$.type_str = make_str("Interval");
|
$$.type_str = make_str("interval");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
@ -4899,7 +4899,7 @@ var_type: common_type
|
|||||||
else if (strcmp($1, "datetime") == 0)
|
else if (strcmp($1, "datetime") == 0)
|
||||||
{
|
{
|
||||||
$$.type_enum = ECPGt_timestamp;
|
$$.type_enum = ECPGt_timestamp;
|
||||||
$$.type_str = make_str("Timestamp");
|
$$.type_str = make_str("timestamp");
|
||||||
$$.type_dimension = make_str("-1");
|
$$.type_dimension = make_str("-1");
|
||||||
$$.type_index = make_str("-1");
|
$$.type_index = make_str("-1");
|
||||||
$$.type_sizeof = NULL;
|
$$.type_sizeof = NULL;
|
||||||
|
@ -366,7 +366,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
|
|||||||
* we have to use a pointer here
|
* we have to use a pointer here
|
||||||
*/
|
*/
|
||||||
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
|
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
|
||||||
sprintf(offset, "sizeof(Numeric)");
|
sprintf(offset, "sizeof(numeric)");
|
||||||
break;
|
break;
|
||||||
case ECPGt_interval:
|
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
|
* we have to use a pointer here
|
||||||
*/
|
*/
|
||||||
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
|
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
|
||||||
sprintf(offset, "sizeof(Interval)");
|
sprintf(offset, "sizeof(interval)");
|
||||||
break;
|
break;
|
||||||
case ECPGt_date:
|
case ECPGt_date:
|
||||||
|
|
||||||
@ -383,7 +383,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
|
|||||||
* type
|
* type
|
||||||
*/
|
*/
|
||||||
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
|
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
|
||||||
sprintf(offset, "sizeof(Date)");
|
sprintf(offset, "sizeof(date)");
|
||||||
break;
|
break;
|
||||||
case ECPGt_timestamp:
|
case ECPGt_timestamp:
|
||||||
|
|
||||||
@ -392,7 +392,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
|
|||||||
* type
|
* type
|
||||||
*/
|
*/
|
||||||
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
|
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
|
||||||
sprintf(offset, "sizeof(Date)");
|
sprintf(offset, "sizeof(timestamp)");
|
||||||
break;
|
break;
|
||||||
case ECPGt_const:
|
case ECPGt_const:
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ main()
|
|||||||
interval iv1;
|
interval iv1;
|
||||||
char *text;
|
char *text;
|
||||||
exec sql end declare section;
|
exec sql end declare section;
|
||||||
Date date2;
|
date date2;
|
||||||
int mdy[3] = { 4, 19, 1998 };
|
int mdy[3] = { 4, 19, 1998 };
|
||||||
char *fmt, *out, *in;
|
char *fmt, *out, *in;
|
||||||
char *d1 = "Mon Jan 17 1966";
|
char *d1 = "Mon Jan 17 1966";
|
||||||
|
@ -6,7 +6,7 @@ int
|
|||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
char *text="error\n";
|
char *text="error\n";
|
||||||
Numeric *value1, *value2, *res;
|
numeric *value1, *value2, *res;
|
||||||
exec sql begin declare section;
|
exec sql begin declare section;
|
||||||
numeric(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
|
numeric(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
|
||||||
exec sql end declare section;
|
exec sql end declare section;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user