1- /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.276 2004/03/02 06:45:05 meskes Exp $*/
1+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.277 2004/03/04 07:32:01 meskes Exp $*/
22
33/* Copyright comment*/
44%{
@@ -541,7 +541,7 @@ add_additional_variables(char *name, bool insert)
541541%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst
542542%type <str> inf_val_list inf_col_list using_descriptor into_descriptor
543543%type <str> ecpg_into_using prepared_name struct_union_type_with_symbol
544- %type <str> ECPGunreserved ECPGunreserved_interval
544+ %type <str> ECPGunreserved ECPGunreserved_interval cvariable
545545
546546%type <struct_union> s_struct_union_symbol
547547
@@ -4220,7 +4220,7 @@ connection_target: database_name opt_server opt_port
42204220}
42214221;
42224222
4223- db_prefix :ident CVARIABLE
4223+ db_prefix :ident cvariable
42244224{
42254225if (strcmp($2 ," postgresql" ) !=0 && strcmp($2 ," postgres" ) !=0 )
42264226{
@@ -4311,7 +4311,7 @@ user_name: UserId
43114311}
43124312;
43134313
4314- char_variable :CVARIABLE
4314+ char_variable :cvariable
43154315{
43164316/* check if we have a char variable*/
43174317struct variable *p = find_variable($1 );
@@ -5241,14 +5241,14 @@ ECPGAllocateDescr:SQL_ALLOCATE SQL_DESCRIPTOR quoted_ident_stringvar
52415241 * read from descriptor
52425242*/
52435243
5244- ECPGGetDescHeaderItem :CVARIABLE ' =' desc_header_item
5244+ ECPGGetDescHeaderItem :cvariable ' =' desc_header_item
52455245{ push_assignment($1 ,$3 ); }
52465246;
52475247
52485248desc_header_item :SQL_COUNT {$$ = ECPGd_count; }
52495249;
52505250
5251- ECPGGetDescItem :CVARIABLE ' =' descriptor_item { push_assignment($1 ,$3 ); };
5251+ ECPGGetDescItem :cvariable ' =' descriptor_item { push_assignment($1 ,$3 ); };
52525252
52535253descriptor_item :SQL_CARDINALITY {$$ = ECPGd_cardinality; }
52545254| SQL_DATA {$$ = ECPGd_data; }
@@ -5280,7 +5280,7 @@ ECPGGetDescriptorHeader:GET SQL_DESCRIPTOR quoted_ident_stringvar
52805280{$$ =$3 ; }
52815281;
52825282
5283- ECPGGetDescriptor :GET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE CVARIABLE ECPGGetDescItems
5283+ ECPGGetDescriptor :GET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE cvariable ECPGGetDescItems
52845284{$$ .str =$5 ;$$ .name =$3 ; }
52855285| GET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE Iconst ECPGGetDescItems
52865286{$$ .str =$5 ;$$ .name =$3 ; }
@@ -6047,14 +6047,14 @@ c_args: /*EMPTY*/{ $$ = EMPTY; }
60476047| c_list {$$ =$1 ; }
60486048;
60496049
6050- coutputvariable :CVARIABLE indicator
6050+ coutputvariable :cvariable indicator
60516051{ add_variable_to_head(&argsresult, find_variable($1 ), find_variable($2 )); }
6052- | CVARIABLE
6052+ | cvariable
60536053{ add_variable_to_head(&argsresult, find_variable($1 ), &no_indicator); }
60546054;
60556055
60566056
6057- civarind :CVARIABLE indicator
6057+ civarind :cvariable indicator
60586058{
60596059if (find_variable($2 )->type->type == ECPGt_array)
60606060mmerror (PARSE_ERROR, ET_ERROR," arrays of indicators are not allowed on input" );
@@ -6064,18 +6064,47 @@ civarind: CVARIABLE indicator
60646064}
60656065;
60666066
6067- civar :CVARIABLE
6067+ civar :cvariable
60686068{
60696069add_variable_to_head (&argsinsert, find_variable($1 ), &no_indicator);
60706070$$ = create_questionmarks($1 ,false );
60716071}
60726072;
60736073
6074- indicator :CVARIABLE { check_indicator((find_variable($1 ))->type);$$ =$1 ; }
6075- | SQL_INDICATOR CVARIABLE { check_indicator((find_variable($2 ))->type);$$ =$2 ; }
6074+ indicator :cvariable { check_indicator((find_variable($1 ))->type);$$ =$1 ; }
6075+ | SQL_INDICATOR cvariable { check_indicator((find_variable($2 ))->type);$$ =$2 ; }
60766076| SQL_INDICATOR name { check_indicator((find_variable($2 ))->type);$$ =$2 ; }
60776077;
60786078
6079+ cvariable :CVARIABLE
6080+ {
6081+ /* As long as multidimensional arrays are not implemented we have to check for those here*/
6082+ char *ptr =$1 ;
6083+ int brace_open=0 , brace =false ;
6084+
6085+ for (; *ptr; ptr++)
6086+ {
6087+ switch (*ptr)
6088+ {
6089+ case ' [' :if (brace)
6090+ {
6091+ mmerror (PARSE_ERROR, ET_FATAL," No multidimensional array support for simple data types" );
6092+ }
6093+ brace_open++;
6094+ break ;
6095+ case ' ]' : brace_open--;
6096+ if (brace_open ==0 ) brace =true ;
6097+ break ;
6098+ case ' \t ' :
6099+ case ' ' :break ;
6100+ default :if (brace_open ==0 ) brace =false ;
6101+ break ;
6102+ }
6103+ }
6104+
6105+ $$ =$1 ;
6106+ }
6107+ ;
60796108ident :IDENT {$$ =$1 ; }
60806109| CSTRING {$$ = make3_str(make_str(" \" " ),$1 , make_str(" \" " )); }
60816110;