- Check for NULL before checking whether argument is an array.
authorMichael Meskes <[email protected]>
Wed, 24 Aug 2005 10:35:54 +0000 (10:35 +0000)
committerMichael Meskes <[email protected]>
Wed, 24 Aug 2005 10:35:54 +0000 (10:35 +0000)
- Removed stray character from string quoting.
- Fixed check to report missing varchar pointer implementation.

src/interfaces/ecpg/ecpglib/data.c
src/interfaces/ecpg/preproc/preproc.y

index def53f3f40ab1332e9b36b09ab17abc710f8673e..43292a505e8a4192648f7d09b595a161acb8e0b8 100644 (file)
@@ -46,29 +46,6 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 
        ECPGlog("ECPGget_data line %d: RESULT: %s offset: %ld array: %d\n", lineno, pval ? pval : "", offset, isarray);
 
-       /* 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 */
 
        /*
@@ -125,6 +102,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)
index 10bff68c5d2f826f9afae55246882cc254580ed2..7d9e07213799a8947140598e205c425f3b9aeef5 100644 (file)
@@ -5121,7 +5121,8 @@ variable: opt_pointer ECPGColLabelCommon 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)