-/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.45 2006/06/25 01:45:32 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.46 2006/06/26 09:20:09 meskes Exp $ */
#include <stdlib.h>
#include <string.h>
}
ret = PGTYPESnumeric_to_int(nres, ip);
+ PGTYPESnumeric_free(nres);
if (ret == PGTYPES_NUM_OVERFLOW)
ret = ECPG_INFORMIX_NUM_OVERFLOW;
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.49 2006/06/25 09:38:39 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.50 2006/06/26 09:20:09 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
case ECPGt_numeric:
{
char *str = NULL;
- int slen;
+ int slen;
numeric *nval = PGTYPESnumeric_new();
- if (!nval)
- return false;
-
if (var->arrsize > 1)
{
for (element = 0; element < var->arrsize; element++, nval = PGTYPESnumeric_new())
{
+ if (!nval)
+ return false;
+
if (var->type == ECPGt_numeric)
PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);
else
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
slen = strlen(str);
+ PGTYPESnumeric_free(nval);
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [] "), lineno)))
{
- PGTYPESnumeric_free(nval);
ECPGfree(str);
return false;
}
strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ECPGfree(str);
- PGTYPESnumeric_free(nval);
}
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
}
else
{
+ if (!nval)
+ return false;
+
if (var->type == ECPGt_numeric)
PGTYPESnumeric_copy((numeric *) (var->value), nval);
else
PGTYPESnumeric_from_decimal((decimal *) (var->value), nval);
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
-
slen = strlen(str);
+ PGTYPESnumeric_free(nval);
if (!(mallocedval = ECPGalloc(slen + 1, lineno)))
{
- PGTYPESnumeric_free(nval);
free(str);
return false;
}
strncpy(mallocedval, str, slen);
mallocedval[slen] = '\0';
ECPGfree(str);
- PGTYPESnumeric_free(nval);
}
*tobeinserted_p = mallocedval;