diff options
author | Michael Meskes <meskes@postgresql.org> | 2011-01-08 18:35:37 +0100 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2011-01-08 23:02:23 +0100 |
commit | 1b2b96c4231f11313f14ded55e25640fb239de31 (patch) | |
tree | 145f2d97041e3c59b383a4ae8aa12d9b406fb75f | |
parent | e445f9f8b5509198abe3a27fe2cd92ba3a22379a (diff) | |
download | postgresql-1b2b96c4231f11313f14ded55e25640fb239de31.tar.gz postgresql-1b2b96c4231f11313f14ded55e25640fb239de31.zip |
In ecpg's parser removed a fixed length limit for constants defining an array dimension.
-rw-r--r-- | src/interfaces/ecpg/preproc/ecpg.trailer | 8 | ||||
-rw-r--r-- | src/interfaces/ecpg/test/expected/preproc-array_of_struct.c | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer index 59fc26c0ddc..56d1c60bd94 100644 --- a/src/interfaces/ecpg/preproc/ecpg.trailer +++ b/src/interfaces/ecpg/preproc/ecpg.trailer @@ -839,7 +839,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize struct ECPGtype * type; char *dimension = $3.index1; /* dimension of array */ char *length = $3.index2; /* length of string */ - char dim[14L]; + char *dim_str; char *vcn; 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); @@ -863,9 +863,9 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter), dimension); if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1) - *dim = '\0'; + dim_str=make_str(""); else - sprintf(dim, "[%s]", dimension); + dim_str=cat_str(3, make_str("["), mm_strdup(dimension), make_str("]")); /* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */ if (atoi(length) < 0 || strcmp(length, "0") == 0) mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented"); @@ -876,7 +876,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize if (strcmp(dimension, "0") == 0) $$ = cat_str(7, make2_str(make_str(" struct varchar_"), vcn), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } *"), mm_strdup($2), $4, $5); else - $$ = cat_str(8, make2_str(make_str(" struct varchar_"), vcn), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } "), mm_strdup($2), mm_strdup(dim), $4, $5); + $$ = cat_str(8, make2_str(make_str(" struct varchar_"), vcn), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } "), mm_strdup($2), dim_str, $4, $5); varchar_counter++; break; diff --git a/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c b/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c index 91c8ad55fe8..bdb5c7cb847 100644 --- a/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c +++ b/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c @@ -114,7 +114,7 @@ int main() int r ; #line 45 "array_of_struct.pgc" - struct varchar_onlyname_5 { int len; char arr[ 50 ]; } onlyname [2] ; + struct varchar_onlyname_5 { int len; char arr[ 50 ]; } onlyname [ 2 ] ; /* exec sql end declare section */ #line 46 "array_of_struct.pgc" |