]> granicus.if.org Git - postgresql/commitdiff
- Fixed bug that reversed string length in typedefs.
authorMichael Meskes <meskes@postgresql.org>
Fri, 7 May 2004 13:43:29 +0000 (13:43 +0000)
committerMichael Meskes <meskes@postgresql.org>
Fri, 7 May 2004 13:43:29 +0000 (13:43 +0000)
src/interfaces/ecpg/preproc/extern.h
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/variable.c

index 4ff8298e7199c16cc1dbf3cbf907f281addab09d..3383682fc46620f1499f4ac7f2259f590b6d34c0 100644 (file)
@@ -79,7 +79,7 @@ extern void add_variable_to_head(struct arguments **, struct variable *, struct
 extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
 extern void dump_variables(struct arguments *, int);
 extern struct typedefs *get_typedef(char *);
-extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int);
+extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int, bool);
 extern void reset_variables(void);
 extern void check_indicator(struct ECPGtype *);
 extern void remove_variables(int);
index 85ba9473e6a0941add1fb74eca989c118bfe319d..51a6824a79f50b84ba88a46c93c93d2ba6bc51cf 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.263.2.11 2004/05/05 15:06:21 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.263.2.12 2004/05/07 13:43:29 meskes Exp $ */
 
 /* Copyright comment */
 %{
@@ -4649,8 +4649,7 @@ type_declaration: S_TYPEDEF
                                        mmerror(PARSE_ERROR, ET_ERROR, errortext);
                                }
                        }
-
-                       adjust_array($3.type_enum, &dimension, &length, $3.type_dimension, $3.type_index, *$4?1:0);
+                       adjust_array($3.type_enum, &dimension, &length, $3.type_dimension, $3.type_index, *$4?1:0, true);
 
                        this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
 
@@ -5098,7 +5097,7 @@ variable: opt_pointer ECPGColLabelCommon opt_array_bounds opt_initializer
                        char *length = $3.index2;    /* length of string */
                        char dim[14L];
 
-                       adjust_array(actual_type[struct_level].type_enum, &dimension, &length, actual_type[struct_level].type_dimension, actual_type[struct_level].type_index, strlen($1));
+                       adjust_array(actual_type[struct_level].type_enum, &dimension, &length, actual_type[struct_level].type_dimension, actual_type[struct_level].type_index, strlen($1), false);
 
                        switch (actual_type[struct_level].type_enum)
                        {
@@ -5488,7 +5487,7 @@ ECPGTypedef: TYPE_P
                                        }
                                }
 
-                               adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0);
+                               adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0, false);
 
                                this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
 
@@ -5546,7 +5545,7 @@ ECPGVar: SQL_VAR
                                mmerror(PARSE_ERROR, ET_ERROR, "Initializer not allowed in EXEC SQL VAR command");
                        else
                        {
-                               adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0);
+                               adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0, false);
 
                                switch ($5.type_enum)
                                {
index c4dfbb0f188766000f1fa03a0320c9c4517fd0f4..9663e29ef03efbf353e2a80404f54ad57694437e 100644 (file)
@@ -459,7 +459,7 @@ get_typedef(char *name)
 }
 
 void
-adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *type_dimension, char *type_index, int pointer_len)
+adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *type_dimension, char *type_index, int pointer_len, bool type_definition)
 {
        if (atoi(type_index) >= 0)
        {
@@ -484,7 +484,6 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
        {
                snprintf(errortext, sizeof(errortext), "No multilevel (more than 2) pointer supported %d", pointer_len);
                mmerror(PARSE_ERROR, ET_FATAL, errortext);
-/*             mmerror(PARSE_ERROR, ET_FATAL, "No multilevel (more than 2) pointer supported %d",pointer_len);*/
        }
 
        if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char)
@@ -544,7 +543,11 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
                                 * make sure we return length = -1 for arrays without
                                 * given bounds
                                 */
-                               if (atoi(*dimension) < 0)
+                               if (atoi(*dimension) < 0 && !type_definition)
+                                       /*
+                                        * do not change this for typedefs 
+                                        * since it will be changed later on when the variable is defined
+                                        */
                                        *length = make_str("1");
                                else if (atoi(*dimension) == 0)
                                        *length = make_str("-1");