-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.86 2009/08/07 10:51:20 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.87 2009/09/03 10:24:48 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
char *newcopy = NULL;
/*
- * arrays are not possible unless the attribute is an array too FIXME: we
- * do not know if the attribute is an array here
+ * arrays are not possible unless the attribute is an array too
+ * FIXME: we do not know if the attribute is an array here
*/
#if 0
if (var->arrsize > 1 &&...)
if (var->arrsize > 1)
{
+ if (!(mallocedval = ecpg_strdup("array [", lineno)))
+ return false;
+
for (element = 0; element < var->arrsize; element++)
{
nval = PGTYPESnumeric_new();
slen = strlen(str);
PGTYPESnumeric_free(nval);
- if (!(mallocedval = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [] "), lineno)))
+ if (!(mallocedval = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(str);
return false;
}
- if (!element)
- strcpy(mallocedval, "array [");
-
strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
if (var->arrsize > 1)
{
+ if (!(mallocedval = ecpg_strdup("array [", lineno)))
+ return false;
+
for (element = 0; element < var->arrsize; element++)
{
str = quote_postgres(PGTYPESinterval_to_asc((interval *) ((var + var->offset * element)->value)), quote, lineno);
return false;
slen = strlen(str);
- if (!(mallocedval = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],interval "), lineno)))
+ if (!(mallocedval = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(str);
return false;
}
- if (!element)
- strcpy(mallocedval, "array [");
-
strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
if (var->arrsize > 1)
{
+ if (!(mallocedval = ecpg_strdup("array [", lineno)))
+ return false;
+
for (element = 0; element < var->arrsize; element++)
{
str = quote_postgres(PGTYPESdate_to_asc(*(date *) ((var + var->offset * element)->value)), quote, lineno);
return false;
slen = strlen(str);
- if (!(mallocedval = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [],date "), lineno)))
+ if (!(mallocedval = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(str);
return false;
}
- if (!element)
- strcpy(mallocedval, "array [");
-
strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
if (var->arrsize > 1)
{
+ if (!(mallocedval = ecpg_strdup("array [", lineno)))
+ return false;
+
for (element = 0; element < var->arrsize; element++)
{
str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) ((var + var->offset * element)->value)), quote, lineno);
slen = strlen(str);
- if (!(mallocedval = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [], timestamp "), lineno)))
+ if (!(mallocedval = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
{
ecpg_free(str);
return false;
}
- if (!element)
- strcpy(mallocedval, "array [");
-
strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);