From: Michael Meskes Date: Wed, 24 Aug 2005 10:34:19 +0000 (+0000) Subject: - Check for NULL before checking whether argument is an array. X-Git-Tag: REL9_0_0~9425 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f417ebf03a71c9ca1043850ad99d46675c60d2b0;p=pg-rex%2Fsyncrep.git - Check for NULL before checking whether argument is an array. - Remove stary character from string quoting. - Fixed check to report missing varchar pointer implementation. --- diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog index 20ace619de..dcb8d4242e 100644 --- a/src/interfaces/ecpg/ChangeLog +++ b/src/interfaces/ecpg/ChangeLog @@ -1929,6 +1929,12 @@ Thu Jun 2 14:22:32 CEST 2005 - Fixed memory leak in ecpglib by adding some missing free() commands. - Added patch by Gavin Scott for Intel 64bit hardware. + +Wed Aug 24 12:17:48 CEST 2005 + + - Check for NULL before checking whether argument is an array. + - Removed stray character from string quoting. + - Fixed check to report missing varchar pointer implementation. - Set ecpg library version to 5.1. - Set ecpg version to 4.1.1. diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c index 25738796fb..252fbae355 100644 --- a/src/interfaces/ecpg/ecpglib/data.c +++ b/src/interfaces/ecpg/ecpglib/data.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.27 2004/08/29 05:06:59 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.28 2005/08/24 10:34:19 meskes Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -50,29 +50,6 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, ECPGlog("ECPGget_data line %d: RESULT: %s offset: %ld array: %s\n", lineno, pval ? pval : "", offset, isarray ? "Yes" : "No"); - /* pval is a pointer to the value */ - /* let's check if it really is an array if it should be one */ - if (isarray == ECPG_ARRAY_ARRAY) - { - if (*pval != '{') - { - ECPGraise(lineno, ECPG_DATA_NOT_ARRAY, ECPG_SQLSTATE_DATATYPE_MISMATCH, NULL); - return (false); - } - - switch (type) - { - case ECPGt_char: - case ECPGt_unsigned_char: - case ECPGt_varchar: - break; - - default: - pval++; - break; - } - } - /* We will have to decode the value */ /* @@ -129,6 +106,29 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, if (value_for_indicator == -1) return (true); + /* pval is a pointer to the value */ + /* let's check if it really is an array if it should be one */ + if (isarray == ECPG_ARRAY_ARRAY) + { + if (*pval != '{') + { + ECPGraise(lineno, ECPG_DATA_NOT_ARRAY, ECPG_SQLSTATE_DATATYPE_MISMATCH, NULL); + return (false); + } + + switch (type) + { + case ECPGt_char: + case ECPGt_unsigned_char: + case ECPGt_varchar: + break; + + default: + pval++; + break; + } + } + do { switch (type) diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index acd734ad06..7e55ea1d98 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.309 2005/08/22 20:25:03 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.310 2005/08/24 10:34:19 meskes Exp $ */ /* Copyright comment */ %{ @@ -5144,7 +5144,8 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_initializer *dim = '\0'; else sprintf(dim, "[%s]", dimension); - if (strcmp(length, "0") == 0) + /* if (strcmp(length, "0") == 0)*/ + if (atoi(length) <= 0) mmerror(PARSE_ERROR, ET_ERROR, "pointer to varchar are not implemented"); if (strcmp(dimension, "0") == 0)