mirror of
https://github.com/postgres/postgres.git
synced 2025-05-14 00:03:46 -04:00
Added fixes from the coverity report send in by Joachim Wieland <joe@mcknight.de>
Added missing error handling in a few functions in ecpglib.
This commit is contained in:
parent
23623f05f0
commit
08f1973911
@ -209,13 +209,14 @@ 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;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|
||||||
rsetnull(CDECIMALTYPE, (char *) np);
|
rsetnull(CDECIMALTYPE, (char *) np);
|
||||||
if (risnull(CDOUBLETYPE, (char *) &dbl))
|
if (risnull(CDOUBLETYPE, (char *) &dbl))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
nres = PGTYPESnumeric_new();
|
||||||
if (nres == NULL)
|
if (nres == NULL)
|
||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@ -230,13 +231,14 @@ deccvdbl(double dbl, decimal *np)
|
|||||||
int
|
int
|
||||||
deccvint(int in, decimal *np)
|
deccvint(int in, decimal *np)
|
||||||
{
|
{
|
||||||
numeric *nres = PGTYPESnumeric_new();
|
numeric *nres;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|
||||||
rsetnull(CDECIMALTYPE, (char *) np);
|
rsetnull(CDECIMALTYPE, (char *) np);
|
||||||
if (risnull(CINTTYPE, (char *) &in))
|
if (risnull(CINTTYPE, (char *) &in))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
nres = PGTYPESnumeric_new();
|
||||||
if (nres == NULL)
|
if (nres == NULL)
|
||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@ -251,13 +253,14 @@ deccvint(int in, decimal *np)
|
|||||||
int
|
int
|
||||||
deccvlong(long lng, decimal *np)
|
deccvlong(long lng, decimal *np)
|
||||||
{
|
{
|
||||||
numeric *nres = PGTYPESnumeric_new();
|
numeric *nres;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|
||||||
rsetnull(CDECIMALTYPE, (char *) np);
|
rsetnull(CDECIMALTYPE, (char *) np);
|
||||||
if (risnull(CLONGTYPE, (char *) &lng))
|
if (risnull(CLONGTYPE, (char *) &lng))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
nres = PGTYPESnumeric_new();
|
||||||
if (nres == NULL)
|
if (nres == NULL)
|
||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@ -340,18 +343,22 @@ 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;
|
||||||
|
|
||||||
if (nres == NULL)
|
|
||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
rsetnull(CSTRINGTYPE, (char *) cp);
|
rsetnull(CSTRINGTYPE, (char *) cp);
|
||||||
if (risnull(CDECIMALTYPE, (char *) np))
|
if (risnull(CDECIMALTYPE, (char *) np))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
|
nres = PGTYPESnumeric_new();
|
||||||
|
if (nres == NULL)
|
||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
|
||||||
|
{
|
||||||
|
PGTYPESnumeric_free(nres);
|
||||||
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if (right >= 0)
|
if (right >= 0)
|
||||||
str = PGTYPESnumeric_to_asc(nres, right);
|
str = PGTYPESnumeric_to_asc(nres, right);
|
||||||
else
|
else
|
||||||
@ -374,14 +381,17 @@ 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();
|
|
||||||
int i;
|
int i;
|
||||||
|
numeric *nres = PGTYPESnumeric_new();
|
||||||
|
|
||||||
if (nres == NULL)
|
if (nres == NULL)
|
||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
|
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
|
||||||
|
{
|
||||||
|
PGTYPESnumeric_free(nres);
|
||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
i = PGTYPESnumeric_to_double(nres, dblp);
|
i = PGTYPESnumeric_to_double(nres, dblp);
|
||||||
PGTYPESnumeric_free(nres);
|
PGTYPESnumeric_free(nres);
|
||||||
@ -399,7 +409,10 @@ dectoint(decimal *np, int *ip)
|
|||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
|
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
|
||||||
|
{
|
||||||
|
PGTYPESnumeric_free(nres);
|
||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
ret = PGTYPESnumeric_to_int(nres, ip);
|
ret = PGTYPESnumeric_to_int(nres, ip);
|
||||||
|
|
||||||
@ -413,15 +426,19 @@ 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 ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
|
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
|
||||||
|
{
|
||||||
|
PGTYPESnumeric_free(nres);
|
||||||
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
return ECPG_INFORMIX_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
ret = PGTYPESnumeric_to_long(nres, lngp);
|
ret = PGTYPESnumeric_to_long(nres, lngp);
|
||||||
|
PGTYPESnumeric_free(nres);
|
||||||
|
|
||||||
if (ret == PGTYPES_NUM_OVERFLOW)
|
if (ret == PGTYPES_NUM_OVERFLOW)
|
||||||
ret = ECPG_INFORMIX_NUM_OVERFLOW;
|
ret = ECPG_INFORMIX_NUM_OVERFLOW;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26.2.2 2006/06/19 09:20:07 meskes Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26.2.3 2006/06/21 10:29:50 meskes Exp $ */
|
||||||
|
|
||||||
#define POSTGRES_ECPG_INTERNAL
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -403,6 +403,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
|
|||||||
ECPGfree(realname);
|
ECPGfree(realname);
|
||||||
if (dbname)
|
if (dbname)
|
||||||
ECPGfree(dbname);
|
ECPGfree(dbname);
|
||||||
|
ecpg_finish(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.29.2.1 2006/06/06 11:36:22 meskes Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.29.2.2 2006/06/21 10:29:50 meskes Exp $ */
|
||||||
|
|
||||||
#define POSTGRES_ECPG_INTERNAL
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -92,13 +92,17 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_MISSING_INDICATOR, ECPG_SQLSTATE_NULL_VALUE_NO_INDICATOR_PARAMETER, NULL);
|
ECPGraise(lineno, ECPG_MISSING_INDICATOR,
|
||||||
|
ECPG_SQLSTATE_NULL_VALUE_NO_INDICATOR_PARAMETER,
|
||||||
|
NULL);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ECPGraise(lineno, ECPG_UNSUPPORTED, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, ECPGtype_name(ind_type));
|
ECPGraise(lineno, ECPG_UNSUPPORTED,
|
||||||
|
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR,
|
||||||
|
ECPGtype_name(ind_type));
|
||||||
return (false);
|
return (false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -110,9 +114,10 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
/* let's check if it really is an array if it should be one */
|
/* let's check if it really is an array if it should be one */
|
||||||
if (isarray == ECPG_ARRAY_ARRAY)
|
if (isarray == ECPG_ARRAY_ARRAY)
|
||||||
{
|
{
|
||||||
if (*pval != '{')
|
if (!pval || *pval != '{')
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_DATA_NOT_ARRAY, ECPG_SQLSTATE_DATATYPE_MISMATCH, NULL);
|
ECPGraise(lineno, ECPG_DATA_NOT_ARRAY,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, NULL);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +155,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
res = strtol(pval, &scan_length, 10);
|
res = strtol(pval, &scan_length, 10);
|
||||||
if (garbage_left(isarray, scan_length, compat))
|
if (garbage_left(isarray, scan_length, compat))
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_INT_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
pval = scan_length;
|
pval = scan_length;
|
||||||
@ -183,7 +189,8 @@ 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 (garbage_left(isarray, scan_length, compat))
|
if (garbage_left(isarray, scan_length, compat))
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_UINT_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
pval = scan_length;
|
pval = scan_length;
|
||||||
@ -260,7 +267,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
|
|
||||||
if (garbage_left(isarray, scan_length, compat))
|
if (garbage_left(isarray, scan_length, compat))
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_FLOAT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_FLOAT_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
pval = scan_length;
|
pval = scan_length;
|
||||||
@ -292,7 +300,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
else if (offset == sizeof(int))
|
else if (offset == sizeof(int))
|
||||||
*((int *) (var + offset * act_tuple)) = false;
|
*((int *) (var + offset * act_tuple)) = false;
|
||||||
else
|
else
|
||||||
ECPGraise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, "different size");
|
ECPGraise(lineno, ECPG_CONVERT_BOOL,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH,
|
||||||
|
"different size");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (pval[0] == 't' && pval[1] == '\0')
|
else if (pval[0] == 't' && pval[1] == '\0')
|
||||||
@ -302,7 +312,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
else if (offset == sizeof(int))
|
else if (offset == sizeof(int))
|
||||||
*((int *) (var + offset * act_tuple)) = true;
|
*((int *) (var + offset * act_tuple)) = true;
|
||||||
else
|
else
|
||||||
ECPGraise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, "different size");
|
ECPGraise(lineno, ECPG_CONVERT_BOOL,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH,
|
||||||
|
"different size");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
|
else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
|
||||||
@ -312,7 +324,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ECPGraise(lineno, ECPG_CONVERT_BOOL, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_CONVERT_BOOL,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -419,7 +432,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
/* did we get an error? */
|
/* did we get an error? */
|
||||||
if (errno != 0)
|
if (errno != 0)
|
||||||
{
|
{
|
||||||
ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n", lineno, pval ? pval : "", errno);
|
ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n",
|
||||||
|
lineno, pval ? pval : "", errno);
|
||||||
|
|
||||||
if (INFORMIX_MODE(compat))
|
if (INFORMIX_MODE(compat))
|
||||||
{
|
{
|
||||||
@ -427,11 +441,20 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
* Informix wants its own NULL value here instead
|
* Informix wants its own NULL value here instead
|
||||||
* of an error
|
* of an error
|
||||||
*/
|
*/
|
||||||
|
nres = PGTYPESnumeric_new();
|
||||||
|
if (nres)
|
||||||
ECPGset_noind_null(ECPGt_numeric, nres);
|
ECPGset_noind_null(ECPGt_numeric, nres);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ECPGraise(lineno, ECPG_OUT_OF_MEMORY,
|
||||||
|
ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_NUMERIC_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -443,7 +466,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
if (garbage_left(isarray, scan_length, compat))
|
if (garbage_left(isarray, scan_length, compat))
|
||||||
{
|
{
|
||||||
free(nres);
|
free(nres);
|
||||||
ECPGraise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_NUMERIC_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -477,11 +501,16 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
* Informix wants its own NULL value here instead
|
* Informix wants its own NULL value here instead
|
||||||
* of an error
|
* of an error
|
||||||
*/
|
*/
|
||||||
|
ires = (interval *) ECPGalloc(sizeof(interval), lineno);
|
||||||
|
if (!ires)
|
||||||
|
return (false);
|
||||||
|
|
||||||
ECPGset_noind_null(ECPGt_interval, ires);
|
ECPGset_noind_null(ECPGt_interval, ires);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_INTERVAL_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_INTERVAL_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -493,7 +522,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
if (garbage_left(isarray, scan_length, compat))
|
if (garbage_left(isarray, scan_length, compat))
|
||||||
{
|
{
|
||||||
free(ires);
|
free(ires);
|
||||||
ECPGraise(lineno, ECPG_INTERVAL_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_INTERVAL_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -526,7 +556,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_DATE_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_DATE_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -537,7 +568,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
|
|
||||||
if (garbage_left(isarray, scan_length, compat))
|
if (garbage_left(isarray, scan_length, compat))
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_DATE_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_DATE_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -568,7 +600,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -579,7 +612,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
|
|
||||||
if (garbage_left(isarray, scan_length, compat))
|
if (garbage_left(isarray, scan_length, compat))
|
||||||
{
|
{
|
||||||
ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT,
|
||||||
|
ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -590,7 +624,9 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ECPGraise(lineno, ECPG_UNSUPPORTED, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, ECPGtype_name(type));
|
ECPGraise(lineno, ECPG_UNSUPPORTED,
|
||||||
|
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR,
|
||||||
|
ECPGtype_name(type));
|
||||||
return (false);
|
return (false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* dynamic SQL support routines
|
/* dynamic SQL support routines
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.12.6.2 2006/01/15 22:47:10 neilc Exp $
|
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.12.6.3 2006/06/21 10:29:50 meskes Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define POSTGRES_ECPG_INTERNAL
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
@ -352,7 +352,8 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
|
|||||||
if (arrsize == 0 && var != NULL && *(void **) var == NULL)
|
if (arrsize == 0 && var != NULL && *(void **) var == NULL)
|
||||||
{
|
{
|
||||||
void *mem = (void *) ECPGalloc(offset * ntuples, lineno);
|
void *mem = (void *) ECPGalloc(offset * ntuples, lineno);
|
||||||
|
if (!mem)
|
||||||
|
return false;
|
||||||
*(void **) var = mem;
|
*(void **) var = mem;
|
||||||
ECPGadd_mem(mem, lineno);
|
ECPGadd_mem(mem, lineno);
|
||||||
var = mem;
|
var = mem;
|
||||||
@ -413,7 +414,8 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
|
|||||||
if (data_var.ind_arrsize == 0 && data_var.ind_pointer != NULL && data_var.ind_value == NULL)
|
if (data_var.ind_arrsize == 0 && data_var.ind_pointer != NULL && data_var.ind_value == NULL)
|
||||||
{
|
{
|
||||||
void *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno);
|
void *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno);
|
||||||
|
if (!mem)
|
||||||
|
return false;
|
||||||
*(void **) data_var.ind_pointer = mem;
|
*(void **) data_var.ind_pointer = mem;
|
||||||
ECPGadd_mem(mem, lineno);
|
ECPGadd_mem(mem, lineno);
|
||||||
data_var.ind_value = mem;
|
data_var.ind_value = mem;
|
||||||
@ -480,6 +482,8 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
|
|||||||
if (desc_item == NULL)
|
if (desc_item == NULL)
|
||||||
{
|
{
|
||||||
desc_item = (struct descriptor_item *) ECPGalloc(sizeof(*desc_item), lineno);
|
desc_item = (struct descriptor_item *) ECPGalloc(sizeof(*desc_item), lineno);
|
||||||
|
if (!desc_item)
|
||||||
|
return false;
|
||||||
desc_item->num = index;
|
desc_item->num = index;
|
||||||
desc_item->next = desc->items;
|
desc_item->next = desc->items;
|
||||||
desc->items = desc_item;
|
desc->items = desc_item;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43.2.2 2006/04/24 09:45:44 meskes Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43.2.3 2006/06/21 10:29:50 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.
|
||||||
@ -245,16 +245,20 @@ next_insert(char *text)
|
|||||||
return (*ptr == '\0') ? NULL : ptr;
|
return (*ptr == '\0') ? NULL : ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
ECPGtypeinfocache_push(struct ECPGtype_information_cache ** cache, int oid, bool isarray, int lineno)
|
ECPGtypeinfocache_push(struct ECPGtype_information_cache ** cache, int oid, bool isarray, int lineno)
|
||||||
{
|
{
|
||||||
struct ECPGtype_information_cache *new_entry
|
struct ECPGtype_information_cache *new_entry
|
||||||
= (struct ECPGtype_information_cache *) ECPGalloc(sizeof(struct ECPGtype_information_cache), lineno);
|
= (struct ECPGtype_information_cache *) ECPGalloc(sizeof(struct ECPGtype_information_cache), lineno);
|
||||||
|
|
||||||
|
if (new_entry == NULL)
|
||||||
|
return (false);
|
||||||
|
|
||||||
new_entry->oid = oid;
|
new_entry->oid = oid;
|
||||||
new_entry->isarray = isarray;
|
new_entry->isarray = isarray;
|
||||||
new_entry->next = *cache;
|
new_entry->next = *cache;
|
||||||
*cache = new_entry;
|
*cache = new_entry;
|
||||||
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum ARRAY_TYPE
|
static enum ARRAY_TYPE
|
||||||
@ -274,48 +278,48 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia
|
|||||||
#define not_an_array_in_ecpg ECPG_ARRAY_NONE
|
#define not_an_array_in_ecpg ECPG_ARRAY_NONE
|
||||||
|
|
||||||
/* populate cache with well known types to speed things up */
|
/* populate cache with well known types to speed things up */
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOOLOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOOLOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), BYTEAOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BYTEAOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), CHAROID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CHAROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), NAMEOID, not_an_array_in_ecpg, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NAMEOID, not_an_array_in_ecpg, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT8OID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT8OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2OID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2VECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2VECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT4OID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT4OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), REGPROCOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), REGPROCOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), TEXTOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TEXTOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIDOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), XIDOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), XIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDVECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDVECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), POINTOID, ECPG_ARRAY_VECTOR, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POINTOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), LSEGOID, ECPG_ARRAY_VECTOR, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LSEGOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), PATHOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), PATHOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOXOID, ECPG_ARRAY_VECTOR, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOXOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), POLYGONOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POLYGONOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), LINEOID, ECPG_ARRAY_VECTOR, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LINEOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT4OID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT4OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT8OID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT8OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), ABSTIMEOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ABSTIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), RELTIMEOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), RELTIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), TINTERVALOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TINTERVALOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), UNKNOWNOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), UNKNOWNOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), CASHOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CASHOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDROID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), BPCHAROID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BPCHAROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARCHAROID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARCHAROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), DATEOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), DATEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMEOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPTZOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPTZOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), INTERVALOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INTERVALOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMETZOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMETZOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), ZPBITOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ZPBITOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARBITOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARBITOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
ECPGtypeinfocache_push(&(stmt->connection->cache_head), NUMERICOID, ECPG_ARRAY_NONE, stmt->lineno);
|
if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NUMERICOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cache_entry = (stmt->connection->cache_head); cache_entry != NULL; cache_entry = cache_entry->next)
|
for (cache_entry = (stmt->connection->cache_head); cache_entry != NULL; cache_entry = cache_entry->next)
|
||||||
@ -325,6 +329,9 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia
|
|||||||
}
|
}
|
||||||
|
|
||||||
array_query = (char *) ECPGalloc(strlen("select typlen from pg_type where oid= and typelem<>0") + 11, stmt->lineno);
|
array_query = (char *) ECPGalloc(strlen("select typlen from pg_type where oid= and typelem<>0") + 11, stmt->lineno);
|
||||||
|
if (array_query == NULL)
|
||||||
|
return (ECPG_ARRAY_ERROR);
|
||||||
|
|
||||||
sprintf(array_query, "select typlen from pg_type where oid=%d and typelem<>0", type);
|
sprintf(array_query, "select typlen from pg_type where oid=%d and typelem<>0", type);
|
||||||
query = PQexec(stmt->connection->connection, array_query);
|
query = PQexec(stmt->connection->connection, array_query);
|
||||||
ECPGfree(array_query);
|
ECPGfree(array_query);
|
||||||
@ -361,7 +368,11 @@ ECPGstore_result(const PGresult *results, int act_field,
|
|||||||
ntuples = PQntuples(results);
|
ntuples = PQntuples(results);
|
||||||
bool status = true;
|
bool status = true;
|
||||||
|
|
||||||
isarray = ECPGis_type_an_array(PQftype(results, act_field), stmt, var);
|
if ((isarray = ECPGis_type_an_array(PQftype(results, act_field), stmt, var)) == ECPG_ARRAY_ERROR)
|
||||||
|
{
|
||||||
|
ECPGraise(stmt->lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isarray == ECPG_ARRAY_NONE)
|
if (isarray == ECPG_ARRAY_NONE)
|
||||||
{
|
{
|
||||||
@ -433,6 +444,8 @@ ECPGstore_result(const PGresult *results, int act_field,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var->value = (char *) ECPGalloc(len, stmt->lineno);
|
var->value = (char *) ECPGalloc(len, stmt->lineno);
|
||||||
|
if (!var->value)
|
||||||
|
return false;
|
||||||
*((char **) var->pointer) = var->value;
|
*((char **) var->pointer) = var->value;
|
||||||
ECPGadd_mem(var->value, stmt->lineno);
|
ECPGadd_mem(var->value, stmt->lineno);
|
||||||
}
|
}
|
||||||
@ -443,6 +456,8 @@ ECPGstore_result(const PGresult *results, int act_field,
|
|||||||
int len = var->ind_offset * ntuples;
|
int len = var->ind_offset * ntuples;
|
||||||
|
|
||||||
var->ind_value = (char *) ECPGalloc(len, stmt->lineno);
|
var->ind_value = (char *) ECPGalloc(len, stmt->lineno);
|
||||||
|
if (!var->ind_value)
|
||||||
|
return false;
|
||||||
*((char **) var->ind_pointer) = var->ind_value;
|
*((char **) var->ind_pointer) = var->ind_value;
|
||||||
ECPGadd_mem(var->ind_value, stmt->lineno);
|
ECPGadd_mem(var->ind_value, stmt->lineno);
|
||||||
}
|
}
|
||||||
@ -858,6 +873,9 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
int slen;
|
int slen;
|
||||||
numeric *nval = PGTYPESnumeric_new();
|
numeric *nval = PGTYPESnumeric_new();
|
||||||
|
|
||||||
|
if (!nval)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (var->arrsize > 1)
|
if (var->arrsize > 1)
|
||||||
{
|
{
|
||||||
for (element = 0; element < var->arrsize; element++, nval = PGTYPESnumeric_new())
|
for (element = 0; element < var->arrsize; element++, nval = PGTYPESnumeric_new())
|
||||||
@ -872,7 +890,11 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
slen = strlen(str);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [] "), lineno)))
|
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [] "), lineno)))
|
||||||
|
{
|
||||||
|
PGTYPESnumeric_free(nval);
|
||||||
|
free(str);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!element)
|
if (!element)
|
||||||
strcpy(mallocedval, "array [");
|
strcpy(mallocedval, "array [");
|
||||||
@ -891,11 +913,14 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
|
|
||||||
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
|
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
|
||||||
|
|
||||||
PGTYPESnumeric_free(nval);
|
|
||||||
slen = strlen(str);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGalloc(slen + 1, lineno)))
|
if (!(mallocedval = ECPGalloc(slen + 1, lineno)))
|
||||||
|
{
|
||||||
|
PGTYPESnumeric_free(nval);
|
||||||
|
free(str);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(mallocedval, str, slen);
|
strncpy(mallocedval, str, slen);
|
||||||
mallocedval[slen] = '\0';
|
mallocedval[slen] = '\0';
|
||||||
@ -903,6 +928,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
|
|
||||||
*tobeinserted_p = mallocedval;
|
*tobeinserted_p = mallocedval;
|
||||||
*malloced_p = true;
|
*malloced_p = true;
|
||||||
|
PGTYPESnumeric_free(nval);
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -917,10 +943,15 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
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)), lineno);
|
str = quote_postgres(PGTYPESinterval_to_asc((interval *) ((var + var->offset * element)->value)), lineno);
|
||||||
|
if (!str)
|
||||||
|
return false;
|
||||||
slen = strlen(str);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],interval "), lineno)))
|
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],interval "), lineno)))
|
||||||
|
{
|
||||||
|
ECPGfree(str);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!element)
|
if (!element)
|
||||||
strcpy(mallocedval, "array [");
|
strcpy(mallocedval, "array [");
|
||||||
@ -934,10 +965,15 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
str = quote_postgres(PGTYPESinterval_to_asc((interval *) (var->value)), lineno);
|
str = quote_postgres(PGTYPESinterval_to_asc((interval *) (var->value)), lineno);
|
||||||
|
if (!str)
|
||||||
|
return false;
|
||||||
slen = strlen(str);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGalloc(slen + sizeof("interval ") + 1, lineno)))
|
if (!(mallocedval = ECPGalloc(slen + sizeof("interval ") + 1, lineno)))
|
||||||
|
{
|
||||||
|
ECPGfree(str);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(mallocedval, "interval ");
|
strcpy(mallocedval, "interval ");
|
||||||
/* also copy trailing '\0' */
|
/* also copy trailing '\0' */
|
||||||
@ -946,7 +982,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
|
|
||||||
*tobeinserted_p = mallocedval;
|
*tobeinserted_p = mallocedval;
|
||||||
*malloced_p = true;
|
*malloced_p = true;
|
||||||
free(str);
|
ECPGfree(str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -960,10 +996,15 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
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)), lineno);
|
str = quote_postgres(PGTYPESdate_to_asc(*(date *) ((var + var->offset * element)->value)), lineno);
|
||||||
|
if (!str)
|
||||||
|
return false;
|
||||||
slen = strlen(str);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],date "), lineno)))
|
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],date "), lineno)))
|
||||||
|
{
|
||||||
|
ECPGfree(str);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!element)
|
if (!element)
|
||||||
strcpy(mallocedval, "array [");
|
strcpy(mallocedval, "array [");
|
||||||
@ -977,10 +1018,15 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
str = quote_postgres(PGTYPESdate_to_asc(*(date *) (var->value)), lineno);
|
str = quote_postgres(PGTYPESdate_to_asc(*(date *) (var->value)), lineno);
|
||||||
|
if (!str)
|
||||||
|
return false;
|
||||||
slen = strlen(str);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGalloc(slen + sizeof("date ") + 1, lineno)))
|
if (!(mallocedval = ECPGalloc(slen + sizeof("date ") + 1, lineno)))
|
||||||
|
{
|
||||||
|
ECPGfree(str);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(mallocedval, "date ");
|
strcpy(mallocedval, "date ");
|
||||||
/* also copy trailing '\0' */
|
/* also copy trailing '\0' */
|
||||||
@ -989,7 +1035,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
|
|
||||||
*tobeinserted_p = mallocedval;
|
*tobeinserted_p = mallocedval;
|
||||||
*malloced_p = true;
|
*malloced_p = true;
|
||||||
free(str);
|
ECPGfree(str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1003,10 +1049,15 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
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)), lineno);
|
str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) ((var + var->offset * element)->value)), lineno);
|
||||||
|
if (!str)
|
||||||
|
return false;
|
||||||
slen = strlen(str);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [], timestamp "), lineno)))
|
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [], timestamp "), lineno)))
|
||||||
|
{
|
||||||
|
ECPGfree(str);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!element)
|
if (!element)
|
||||||
strcpy(mallocedval, "array [");
|
strcpy(mallocedval, "array [");
|
||||||
@ -1020,10 +1071,15 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) (var->value)), lineno);
|
str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) (var->value)), lineno);
|
||||||
|
if (!str)
|
||||||
|
return false;
|
||||||
slen = strlen(str);
|
slen = strlen(str);
|
||||||
|
|
||||||
if (!(mallocedval = ECPGalloc(slen + sizeof("timestamp") + 1, lineno)))
|
if (!(mallocedval = ECPGalloc(slen + sizeof("timestamp") + 1, lineno)))
|
||||||
|
{
|
||||||
|
ECPGfree(str);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(mallocedval, "timestamp ");
|
strcpy(mallocedval, "timestamp ");
|
||||||
/* also copy trailing '\0' */
|
/* also copy trailing '\0' */
|
||||||
@ -1032,7 +1088,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
|
|||||||
|
|
||||||
*tobeinserted_p = mallocedval;
|
*tobeinserted_p = mallocedval;
|
||||||
*malloced_p = true;
|
*malloced_p = true;
|
||||||
free(str);
|
ECPGfree(str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1157,8 +1213,13 @@ ECPGexecute(struct statement * stmt)
|
|||||||
* Now tobeinserted points to an area that is to be inserted at
|
* Now tobeinserted points to an area that is to be inserted at
|
||||||
* the first %s
|
* the first %s
|
||||||
*/
|
*/
|
||||||
if (!(newcopy = (char *) ECPGalloc(strlen(copiedquery) + strlen(tobeinserted) + 1, stmt->lineno)))
|
if (!(newcopy = (char *) ECPGalloc(strlen(copiedquery)
|
||||||
|
+ strlen(tobeinserted)
|
||||||
|
+ 1, stmt->lineno)))
|
||||||
|
{
|
||||||
|
ECPGfree(copiedquery);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(newcopy, copiedquery);
|
strcpy(newcopy, copiedquery);
|
||||||
if ((p = next_insert(newcopy + hostvarl)) == NULL)
|
if ((p = next_insert(newcopy + hostvarl)) == NULL)
|
||||||
@ -1167,7 +1228,11 @@ ECPGexecute(struct statement * stmt)
|
|||||||
* We have an argument but we dont have the matched up string
|
* We have an argument but we dont have the matched up string
|
||||||
* in the string
|
* in the string
|
||||||
*/
|
*/
|
||||||
ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS, NULL);
|
ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS,
|
||||||
|
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS,
|
||||||
|
NULL);
|
||||||
|
ECPGfree(copiedquery);
|
||||||
|
ECPGfree(newcopy);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1207,7 +1272,9 @@ ECPGexecute(struct statement * stmt)
|
|||||||
/* Check if there are unmatched things left. */
|
/* Check if there are unmatched things left. */
|
||||||
if (next_insert(copiedquery) != NULL)
|
if (next_insert(copiedquery) != NULL)
|
||||||
{
|
{
|
||||||
ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS, NULL);
|
ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS,
|
||||||
|
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS, NULL);
|
||||||
|
ECPGfree(copiedquery);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1217,7 +1284,9 @@ ECPGexecute(struct statement * stmt)
|
|||||||
{
|
{
|
||||||
if ((results = PQexec(stmt->connection->connection, "begin transaction")) == NULL)
|
if ((results = PQexec(stmt->connection->connection, "begin transaction")) == NULL)
|
||||||
{
|
{
|
||||||
ECPGraise(stmt->lineno, ECPG_TRANS, ECPG_SQLSTATE_TRANSACTION_RESOLUTION_UNKNOWN, NULL);
|
ECPGraise(stmt->lineno, ECPG_TRANS,
|
||||||
|
ECPG_SQLSTATE_TRANSACTION_RESOLUTION_UNKNOWN, NULL);
|
||||||
|
ECPGfree(copiedquery);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PQclear(results);
|
PQclear(results);
|
||||||
@ -1386,6 +1455,7 @@ ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name,
|
|||||||
{
|
{
|
||||||
setlocale(LC_NUMERIC, oldlocale);
|
setlocale(LC_NUMERIC, oldlocale);
|
||||||
ECPGfree(oldlocale);
|
ECPGfree(oldlocale);
|
||||||
|
free_statement(stmt);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
@ -14,7 +14,7 @@ enum COMPAT_MODE
|
|||||||
|
|
||||||
enum ARRAY_TYPE
|
enum ARRAY_TYPE
|
||||||
{
|
{
|
||||||
ECPG_ARRAY_NOT_SET, ECPG_ARRAY_ARRAY, ECPG_ARRAY_VECTOR, ECPG_ARRAY_NONE
|
ECPG_ARRAY_ERROR, ECPG_ARRAY_NOT_SET, ECPG_ARRAY_ARRAY, ECPG_ARRAY_VECTOR, ECPG_ARRAY_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Here are some methods used by the lib. */
|
/* Here are some methods used by the lib. */
|
||||||
|
@ -194,7 +194,6 @@ PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf)
|
|||||||
char *start_pattern;
|
char *start_pattern;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
/* XXX error handling ? */
|
|
||||||
/* copy the string over */
|
/* copy the string over */
|
||||||
strcpy(outbuf, fmtstring);
|
strcpy(outbuf, fmtstring);
|
||||||
|
|
||||||
@ -694,8 +693,6 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: DBCENTURY ? */
|
|
||||||
|
|
||||||
*d = date2j(tm.tm_year, tm.tm_mon, tm.tm_mday) - date2j(2000, 1, 1);
|
*d = date2j(tm.tm_year, tm.tm_mon, tm.tm_mday) - date2j(2000, 1, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1033,7 +1033,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn)
|
|||||||
*tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
|
*tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX FreeBSD man pages indicate that this should work - tgl 97/04/23
|
* FreeBSD man pages indicate that this should work - tgl 97/04/23
|
||||||
*/
|
*/
|
||||||
if (tzn != NULL)
|
if (tzn != NULL)
|
||||||
{
|
{
|
||||||
@ -2737,7 +2737,7 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* XXX Error: no match */
|
/* Error: no match */
|
||||||
err = 1;
|
err = 1;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,10 @@ PGTYPESnumeric_new(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (alloc_var(var, 0) < 0)
|
if (alloc_var(var, 0) < 0)
|
||||||
|
{
|
||||||
|
free(var);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
@ -479,7 +479,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
return -1;
|
return -1;
|
||||||
tmp[2] = *p;
|
tmp[2] = *p;
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* strftime's month is 0 based, ours is 1 based
|
* strftime's month is 0 based, ours is 1 based
|
||||||
@ -498,7 +497,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'G':
|
case 'G':
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
tm->tm_mon -= 1;
|
tm->tm_mon -= 1;
|
||||||
i = strftime(q, *pstr_len, "%G", tm);
|
i = strftime(q, *pstr_len, "%G", tm);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@ -512,7 +510,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
replace_type = PGTYPES_TYPE_NOTHING;
|
replace_type = PGTYPES_TYPE_NOTHING;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
{
|
{
|
||||||
char *fmt = "%g"; /* Keep compiler quiet about
|
char *fmt = "%g"; /* Keep compiler quiet about
|
||||||
* 2-digit year */
|
* 2-digit year */
|
||||||
@ -621,7 +618,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
replace_type = PGTYPES_TYPE_UINT;
|
replace_type = PGTYPES_TYPE_UINT;
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
tm->tm_mon -= 1;
|
tm->tm_mon -= 1;
|
||||||
i = strftime(q, *pstr_len, "%U", tm);
|
i = strftime(q, *pstr_len, "%U", tm);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@ -635,7 +631,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
replace_type = PGTYPES_TYPE_NOTHING;
|
replace_type = PGTYPES_TYPE_NOTHING;
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
i = strftime(q, *pstr_len, "%V", tm);
|
i = strftime(q, *pstr_len, "%V", tm);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -651,7 +646,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
replace_type = PGTYPES_TYPE_UINT;
|
replace_type = PGTYPES_TYPE_UINT;
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
tm->tm_mon -= 1;
|
tm->tm_mon -= 1;
|
||||||
i = strftime(q, *pstr_len, "%U", tm);
|
i = strftime(q, *pstr_len, "%U", tm);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@ -665,7 +659,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
replace_type = PGTYPES_TYPE_NOTHING;
|
replace_type = PGTYPES_TYPE_NOTHING;
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
{
|
{
|
||||||
char *fmt = "%x"; /* Keep compiler quiet about
|
char *fmt = "%x"; /* Keep compiler quiet about
|
||||||
* 2-digit year */
|
* 2-digit year */
|
||||||
@ -684,7 +677,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
tm->tm_mon -= 1;
|
tm->tm_mon -= 1;
|
||||||
i = strftime(q, *pstr_len, "%X", tm);
|
i = strftime(q, *pstr_len, "%X", tm);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@ -706,7 +698,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
replace_type = PGTYPES_TYPE_UINT;
|
replace_type = PGTYPES_TYPE_UINT;
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
tm->tm_mon -= 1;
|
tm->tm_mon -= 1;
|
||||||
i = strftime(q, *pstr_len, "%z", tm);
|
i = strftime(q, *pstr_len, "%z", tm);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@ -720,7 +711,6 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
|
|||||||
replace_type = PGTYPES_TYPE_NOTHING;
|
replace_type = PGTYPES_TYPE_NOTHING;
|
||||||
break;
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
/* XXX: fall back to strftime */
|
|
||||||
tm->tm_mon -= 1;
|
tm->tm_mon -= 1;
|
||||||
i = strftime(q, *pstr_len, "%Z", tm);
|
i = strftime(q, *pstr_len, "%Z", tm);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
|
@ -38,12 +38,15 @@ main(void)
|
|||||||
|
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf ("Date: %s\n", text);
|
printf ("Date: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf ("timestamp: %s\n", text);
|
printf ("timestamp: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
text = PGTYPESinterval_to_asc(&iv1);
|
text = PGTYPESinterval_to_asc(&iv1);
|
||||||
printf ("interval: %s\n", text);
|
printf ("interval: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
PGTYPESdate_mdyjul(mdy, &date2);
|
PGTYPESdate_mdyjul(mdy, &date2);
|
||||||
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
|
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
|
||||||
@ -59,10 +62,12 @@ main(void)
|
|||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
|
|
||||||
printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(ts1));
|
printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(ts1));
|
||||||
|
free(text);
|
||||||
|
|
||||||
PGTYPESdate_today(&date1);
|
PGTYPESdate_today(&date1);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("today is %s\n", text);
|
printf("today is %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "(ddd), mmm. dd, yyyy, repeat: (ddd), mmm. dd, yyyy. end";
|
fmt = "(ddd), mmm. dd, yyyy, repeat: (ddd), mmm. dd, yyyy. end";
|
||||||
out = (char*) malloc(strlen(fmt) + 1);
|
out = (char*) malloc(strlen(fmt) + 1);
|
||||||
@ -82,6 +87,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc1: %s\n", text);
|
printf("date_defmt_asc1: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmmm. dd. yyyy";
|
fmt = "mmmm. dd. yyyy";
|
||||||
@ -89,6 +95,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc2: %s\n", text);
|
printf("date_defmt_asc2: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "yy/mm/dd";
|
fmt = "yy/mm/dd";
|
||||||
@ -96,6 +103,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc3: %s\n", text);
|
printf("date_defmt_asc3: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "yy/mm/dd";
|
fmt = "yy/mm/dd";
|
||||||
@ -103,6 +111,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc4: %s\n", text);
|
printf("date_defmt_asc4: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "dd-mm-yy";
|
fmt = "dd-mm-yy";
|
||||||
@ -110,6 +119,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc5: %s\n", text);
|
printf("date_defmt_asc5: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmddyy";
|
fmt = "mmddyy";
|
||||||
@ -117,6 +127,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc6: %s\n", text);
|
printf("date_defmt_asc6: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmm. dd. yyyy";
|
fmt = "mmm. dd. yyyy";
|
||||||
@ -124,6 +135,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc7: %s\n", text);
|
printf("date_defmt_asc7: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmm. dd. yyyy";
|
fmt = "mmm. dd. yyyy";
|
||||||
@ -131,6 +143,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc8: %s\n", text);
|
printf("date_defmt_asc8: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mm yy dd.";
|
fmt = "mm yy dd.";
|
||||||
@ -138,6 +151,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc9: %s\n", text);
|
printf("date_defmt_asc9: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "yyyy fierj mm dd.";
|
fmt = "yyyy fierj mm dd.";
|
||||||
@ -145,6 +159,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc10: %s\n", text);
|
printf("date_defmt_asc10: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mm/dd/yy";
|
fmt = "mm/dd/yy";
|
||||||
@ -152,22 +167,27 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc12: %s\n", text);
|
printf("date_defmt_asc12: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
PGTYPEStimestamp_current(&ts1);
|
PGTYPEStimestamp_current(&ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_current: Now: %s\n", text);
|
printf("timestamp_current: Now: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
|
ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_to_asc1: %s\n", text);
|
printf("timestamp_to_asc1: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
|
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_to_asc2: %s\n", text);
|
printf("timestamp_to_asc2: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
|
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_to_asc3: %s\n", text);
|
printf("timestamp_to_asc3: %s\n", text);
|
||||||
|
free(text);
|
||||||
|
|
||||||
/* abc-03:10:35-def-02/11/94-gh */
|
/* abc-03:10:35-def-02/11/94-gh */
|
||||||
/* 12345678901234567890123456789 */
|
/* 12345678901234567890123456789 */
|
||||||
@ -175,138 +195,161 @@ main(void)
|
|||||||
out = (char*) malloc(32);
|
out = (char*) malloc(32);
|
||||||
i = PGTYPEStimestamp_fmt_asc(&ts1, out, 31, "abc-%X-def-%x-ghi%%");
|
i = PGTYPEStimestamp_fmt_asc(&ts1, out, 31, "abc-%X-def-%x-ghi%%");
|
||||||
printf("timestamp_fmt_asc: %d: %s\n", i, out);
|
printf("timestamp_fmt_asc: %d: %s\n", i, out);
|
||||||
|
free(out);
|
||||||
|
|
||||||
fmt = "This is a %m/%d/%y %H-%Ml%Stest";
|
fmt = "This is a %m/%d/%y %H-%Ml%Stest";
|
||||||
in = "This is a 4/12/80 3-39l12test";
|
in = "This is a 4/12/80 3-39l12test";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 2000";
|
in = "Tue Feb 29 17:28:44 +0200 2000";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 1900";
|
in = "Tue Feb 29 17:28:44 +0200 1900";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 1996";
|
in = "Tue Feb 29 17:28:44 +0200 1996";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%b %d %H:%M:%S %z %Y";
|
fmt = "%b %d %H:%M:%S %z %Y";
|
||||||
in = " Jul 31 17:28:44 +0200 1996";
|
in = " Jul 31 17:28:44 +0200 1996";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%b %d %H:%M:%S %z %Y";
|
fmt = "%b %d %H:%M:%S %z %Y";
|
||||||
in = " Jul 32 17:28:44 +0200 1996";
|
in = " Jul 32 17:28:44 +0200 1996";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 1997";
|
in = "Tue Feb 29 17:28:44 +0200 1997";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%";
|
fmt = "%";
|
||||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "a %";
|
fmt = "a %";
|
||||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%b, %d %H_%M`%S %z %Y";
|
fmt = "%b, %d %H_%M`%S %z %Y";
|
||||||
in = " Jul, 22 17_28 `44 +0200 2003 ";
|
in = " Jul, 22 17_28 `44 +0200 2003 ";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
||||||
in = "Tue Jul %22 17:28:44 CEST 2003";
|
in = "Tue Jul %22 17:28:44 CEST 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
||||||
in = "Tue Jul %22 17:28:44 CEST 2003";
|
in = "Tue Jul %22 17:28:44 CEST 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
|
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
|
||||||
in = "abc\n 19 October %22 17:28:44 CEST 2003";
|
in = "abc\n 19 October %22 17:28:44 CEST 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
|
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
|
||||||
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "";
|
fmt = "";
|
||||||
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = NULL;
|
fmt = NULL;
|
||||||
in = "1980-04-12 3:49:44 ";
|
in = "1980-04-12 3:49:44 ";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
fmt = "%B %d, %Y. Time: %I:%M%p";
|
fmt = "%B %d, %Y. Time: %I:%M%p";
|
||||||
in = "July 14, 1988. Time: 9:15am";
|
in = "July 14, 1988. Time: 9:15am";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
in = "September 6 at 01:30 pm in the year 1983";
|
in = "September 6 at 01:30 pm in the year 1983";
|
||||||
fmt = "%B %d at %I:%M %p in the year %Y";
|
fmt = "%B %d at %I:%M %p in the year %Y";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
in = " 1976, July 14. Time: 9:15am";
|
in = " 1976, July 14. Time: 9:15am";
|
||||||
fmt = "%Y, %B %d. Time: %I:%M %p";
|
fmt = "%Y, %B %d. Time: %I:%M %p";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
in = " 1976, July 14. Time: 9:15 am";
|
in = " 1976, July 14. Time: 9:15 am";
|
||||||
fmt = "%Y, %B %d. Time: %I:%M%p";
|
fmt = "%Y, %B %d. Time: %I:%M%p";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
|
|
||||||
in = " 1976, P.M. July 14. Time: 9:15";
|
in = " 1976, P.M. July 14. Time: 9:15";
|
||||||
fmt = "%Y, %P %B %d. Time: %I:%M";
|
fmt = "%Y, %P %B %d. Time: %I:%M";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
|
free(text);
|
||||||
exec sql rollback;
|
exec sql rollback;
|
||||||
exec sql disconnect;
|
exec sql disconnect;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user