-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.35 2010/02/02 16:09:12 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.36 2010/08/17 09:36:04 meskes Exp $ */
#include "postgres_fe.h"
#include <ctype.h>
ret = set_var_from_str(str, ptr, value);
if (ret)
{
- free(value);
+ PGTYPESnumeric_free(value);
return (NULL);
}
errno = 0;
*lp = strtol(s, &endptr, 10);
if (endptr == s)
+ {
/* this should not happen actually */
+ free(s);
return -1;
+ }
+ free(s);
if (errno == ERANGE)
{
if (*lp == LONG_MIN)
errno = PGTYPES_NUM_OVERFLOW;
return -1;
}
- free(s);
return 0;
}
{
check_errno();
printf("dec[%d,0]: r: %d\n", i, r);
+ PGTYPESdecimal_free(dec);
continue;
}
decarr = realloc(decarr, sizeof(decimal *) * (count + 1));
{
dectoasc(decarr[i], buf, BUFSIZE-1, -1);
printf("%d: %s\n", i, buf);
+
+ PGTYPESdecimal_free(decarr[i]);
}
+ free(decarr);
return (0);
}
{
check_errno();
printf("dec[%d,0]: r: %d\n", i, r);
+ PGTYPESdecimal_free(dec);
continue;
}
decarr = realloc(decarr, sizeof(decimal *) * (count + 1));
{
dectoasc(decarr[i], buf, BUFSIZE-1, -1);
printf("%d: %s\n", i, buf);
+
+ PGTYPESdecimal_free(decarr[i]);
}
+ free(decarr);
return (0);
}
PGTYPESinterval_copy(iv1, &iv2);
text = PGTYPESinterval_to_asc(&iv2);
printf ("interval: %s\n", text);
+ PGTYPESinterval_free(iv1);
free(text);
PGTYPESdate_mdyjul(mdy, &date2);
free(text);
{ ECPGtrans(__LINE__, NULL, "rollback");
-#line 358 "dt_test.pgc"
+#line 359 "dt_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 358 "dt_test.pgc"
+#line 359 "dt_test.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
-#line 359 "dt_test.pgc"
+#line 360 "dt_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 359 "dt_test.pgc"
+#line 360 "dt_test.pgc"
return (0);
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 38: RESULT: 2000-07-12 17:34:29 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans on line 358: action "rollback"; connection "regress1"
+[NO_PID]: ECPGtrans on line 359: action "rollback"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection regress1 closed
[NO_PID]: sqlca: code: 0, state: 00000
printf("TS[%d,%d]: %s\n",
i, j, errno ? "-" : text);
free(text);
+ free(t);
}
}
}
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
free(text);
PGTYPESinterval_free(ic);
+ PGTYPESinterval_free(i1);
}
return (0);
#line 84 "nan_test.pgc"
+ PGTYPESnumeric_free(num);
+
{ ECPGtrans(__LINE__, NULL, "rollback");
-#line 86 "nan_test.pgc"
+#line 88 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 86 "nan_test.pgc"
+#line 88 "nan_test.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
-#line 87 "nan_test.pgc"
+#line 89 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 87 "nan_test.pgc"
+#line 89 "nan_test.pgc"
return (0);
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 84: OK: CLOSE CURSOR
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans on line 86: action "rollback"; connection "regress1"
+[NO_PID]: ECPGtrans on line 88: action "rollback"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection regress1 closed
[NO_PID]: sqlca: code: 0, state: 00000
PGTYPESnumeric_to_double(res, &d);
printf("div = %s %e\n", text, d);
+ PGTYPESnumeric_free(value1);
+ PGTYPESnumeric_free(value2);
+
value1 = PGTYPESnumeric_from_asc("2E7", NULL);
value2 = PGTYPESnumeric_from_asc("14", NULL);
i = PGTYPESnumeric_to_long(value1, &l1) | PGTYPESnumeric_to_long(value2, &l2);
PGTYPESnumeric_free(res);
{ ECPGtrans(__LINE__, NULL, "rollback");
-#line 90 "num_test.pgc"
+#line 93 "num_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 90 "num_test.pgc"
+#line 93 "num_test.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
-#line 91 "num_test.pgc"
+#line 94 "num_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
-#line 91 "num_test.pgc"
+#line 94 "num_test.pgc"
return (0);
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 66: RESULT: 2369.7000000 offset: -1; array: no
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGtrans on line 90: action "rollback"; connection "regress1"
+[NO_PID]: ECPGtrans on line 93: action "rollback"; connection "regress1"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection regress1 closed
[NO_PID]: sqlca: code: 0, state: 00000
printf("num[d,%d,%d]: %s\n", i, j, text);
free(text);
}
+
+ PGTYPESnumeric_free(a);
+ PGTYPESnumeric_free(s);
+ PGTYPESnumeric_free(m);
+ PGTYPESnumeric_free(d);
}
}
text = PGTYPESnumeric_to_asc(numarr[i], -1);
printf("%d: %s\n", i, text);
free(text);
+ PGTYPESnumeric_free(numarr[i]);
}
+ free(numarr);
return (0);
}
#line 74 "array.pgc"
+ free(t);
+
return (0);
}
PGTYPESinterval_copy(iv1, &iv2);
text = PGTYPESinterval_to_asc(&iv2);
printf ("interval: %s\n", text);
+ PGTYPESinterval_free(iv1);
free(text);
PGTYPESdate_mdyjul(mdy, &date2);
printf("TS[%d,%d]: %s\n",
i, j, errno ? "-" : text);
free(text);
+ free(t);
}
}
}
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
free(text);
PGTYPESinterval_free(ic);
+ PGTYPESinterval_free(i1);
}
return (0);
}
exec sql close cur1;
+ PGTYPESnumeric_free(num);
+
exec sql rollback;
exec sql disconnect;
PGTYPESnumeric_to_double(res, &d);
printf("div = %s %e\n", text, d);
+ PGTYPESnumeric_free(value1);
+ PGTYPESnumeric_free(value2);
+
value1 = PGTYPESnumeric_from_asc("2E7", NULL);
value2 = PGTYPESnumeric_from_asc("14", NULL);
i = PGTYPESnumeric_to_long(value1, &l1) | PGTYPESnumeric_to_long(value2, &l2);
printf("num[d,%d,%d]: %s\n", i, j, text);
free(text);
}
+
+ PGTYPESnumeric_free(a);
+ PGTYPESnumeric_free(s);
+ PGTYPESnumeric_free(m);
+ PGTYPESnumeric_free(d);
}
}
text = PGTYPESnumeric_to_asc(numarr[i], -1);
printf("%d: %s\n", i, text);
free(text);
+ PGTYPESnumeric_free(numarr[i]);
}
+ free(numarr);
return (0);
}
EXEC SQL DISCONNECT;
+ free(t);
+
return (0);
}