@@ -3886,7 +3886,6 @@ connection_target: database_name opt_server opt_port
38863886| db_prefix ' :' server opt_port ' /' database_name opt_options
38873887 {
38883888/* new style: <tcp|unix>:postgresql://server[:port][/dbname]*/
3889- printf (" %s\n " , $1 );
38903889if (strncmp($1 ," unix:postgresql" , strlen(" unix:postgresql" )) !=0 && strncmp($1 ," tcp:postgresql" , strlen(" tcp:postgresql" )) !=0 )
38913890 {
38923891sprintf (errortext," only protocols 'tcp' and 'unix' and database type 'postgresql' are supported" );
@@ -4271,10 +4270,6 @@ s_struct: SQL_STRUCT opt_symbol
42714270if (struct_level >= STRUCT_DEPTH)
42724271mmerror (ET_ERROR," Too many levels in nested structure definition" );
42734272
4274- /* reset this variable so we see if there was*/
4275- /* an initializer specified*/
4276- initializer =0 ;
4277-
42784273$$ = cat2_str(make_str(" struct" ),$2 );
42794274};
42804275
@@ -4284,10 +4279,6 @@ s_union: UNION opt_symbol
42844279if (struct_level >= STRUCT_DEPTH)
42854280mmerror (ET_ERROR," Too many levels in nested structure definition" );
42864281
4287- /* reset this variable so we see if there was*/
4288- /* an initializer specified*/
4289- initializer =0 ;
4290-
42914282$$ = cat2_str(make_str(" union" ),$2 );
42924283};
42934284
@@ -4661,52 +4652,62 @@ ECPGSetConnection: SET SQL_CONNECTION to_equal connection_object
46614652/*
46624653 * define a new type for embedded SQL
46634654*/
4664- ECPGTypedef :TYPE_P ColLabel IS type opt_type_array_bounds opt_reference
4655+ ECPGTypedef :TYPE_P
4656+ {
4657+ /* reset this variable so we see if there was*/
4658+ /* an initializer specified*/
4659+ initializer =0 ;
4660+ }
4661+ ColLabel IS type opt_type_array_bounds opt_reference
46654662{
46664663/* add entry to list*/
46674664struct typedefs *ptr, *this ;
4668- int dimension =$5 .index1;
4669- int length =$5 .index2;
4665+ int dimension =$6 .index1;
4666+ int length =$6 .index2;
46704667
4671- if (($4 .type_enum == ECPGt_struct ||
4672- $4 .type_enum == ECPGt_union) &&
4668+ if (($5 .type_enum == ECPGt_struct ||
4669+ $5 .type_enum == ECPGt_union) &&
46734670 initializer ==1 )
4671+ {
46744672mmerror (ET_ERROR," Initializer not allowed in EXEC SQL VAR command" );
4675-
4676- for (ptr = types; ptr != NULL ; ptr = ptr->next)
4673+ }
4674+ else
46774675{
4678- if (strcmp( $2 , ptr->name) == 0 )
4676+ for (ptr = types; ptr != NULL ; ptr = ptr->next )
46794677{
4680- /* re-definition is a bug*/
4681- sprintf (errortext," Type %s already defined" , $2 );
4682- mmerror (ET_ERROR, errortext);
4683- }
4684- }
4678+ if (strcmp($3 , ptr->name) ==0 )
4679+ {
4680+ /* re-definition is a bug*/
4681+ sprintf (errortext," Type %s already defined" , $3 );
4682+ mmerror (ET_ERROR, errortext);
4683+ }
4684+ }
46854685
4686- adjust_array ($4 .type_enum, &dimension, &length, $4 .type_dimension, $4 .type_index, *$6 ?1 :0 );
4686+ adjust_array ($5 .type_enum, &dimension, &length, $5 .type_dimension, $5 .type_index, *$7 ?1 :0 );
46874687
4688- this = (struct typedefs *) mm_alloc(sizeof (struct typedefs ));
4688+ this = (struct typedefs *) mm_alloc(sizeof (struct typedefs ));
46894689
4690- /* initial definition*/
4691- this ->next = types;
4692- this ->name =$2 ;
4693- this ->type = (struct this_type *) mm_alloc(sizeof (struct this_type ));
4694- this ->type->type_enum =$4 .type_enum;
4695- this ->type->type_str = mm_strdup($2 );
4696- this ->type->type_dimension = dimension;/* dimension of array*/
4697- this ->type->type_index = length;/* lenght of string*/
4698- this ->struct_member_list = ($4 .type_enum == ECPGt_struct ||$4 .type_enum == ECPGt_union) ?
4699- struct_member_list[struct_level] :NULL ;
4690+ /* initial definition*/
4691+ this ->next = types;
4692+ this ->name =$3 ;
4693+ this ->type = (struct this_type *) mm_alloc(sizeof (struct this_type ));
4694+ this ->type->type_enum =$5 .type_enum;
4695+ this ->type->type_str = mm_strdup($3 );
4696+ this ->type->type_dimension = dimension;/* dimension of array*/
4697+ this ->type->type_index = length;/* lenght of string*/
4698+ this ->struct_member_list = ($5 .type_enum == ECPGt_struct ||$5 .type_enum == ECPGt_union) ?
4699+ struct_member_list[struct_level] :NULL ;
47004700
4701- if ($4 .type_enum != ECPGt_varchar &&
4702- $4 .type_enum != ECPGt_char &&
4703- $4 .type_enum != ECPGt_unsigned_char &&
4704- this ->type->type_index >=0 )
4705- mmerror (ET_ERROR," No multi-dimensional array support for simple data types" );
4701+ if ($5 .type_enum != ECPGt_varchar &&
4702+ $5 .type_enum != ECPGt_char &&
4703+ $5 .type_enum != ECPGt_unsigned_char &&
4704+ this ->type->type_index >=0 )
4705+ mmerror (ET_ERROR," No multi-dimensional array support for simple data types" );
47064706
4707- types =this ;
4707+ types =this ;
4708+ }
47084709
4709- $$ = cat_str(7 , make_str(" /* exec sql type" ), mm_strdup($2 ), make_str(" is" ), mm_strdup($4 .type_str), mm_strdup($5 .str),$6 , make_str(" */" ));
4710+ $$ = cat_str(7 , make_str(" /* exec sql type" ), mm_strdup($3 ), make_str(" is" ), mm_strdup($5 .type_str), mm_strdup($6 .str),$7 , make_str(" */" ));
47104711};
47114712
47124713opt_type_array_bounds :' [' ' ]' opt_type_array_bounds
@@ -4754,60 +4755,70 @@ opt_reference: SQL_REFERENCE { $$ = make_str("reference"); }
47544755/*
47554756 * define the type of one variable for embedded SQL
47564757*/
4757- ECPGVar :SQL_VAR ColLabel IS type opt_type_array_bounds opt_reference
4758+ ECPGVar :SQL_VAR
47584759{
4759- struct variable *p = find_variable($2 );
4760- int dimension =$5 .index1;
4761- int length =$5 .index2;
4760+ /* reset this variable so we see if there was*/
4761+ /* an initializer specified*/
4762+ initializer =0 ;
4763+ }
4764+ ColLabel IS type opt_type_array_bounds opt_reference
4765+ {
4766+ struct variable *p = find_variable($3 );
4767+ int dimension =$6 .index1;
4768+ int length =$6 .index2;
47624769struct ECPGtype * type;
47634770
4764- if (($4 .type_enum == ECPGt_struct ||
4765- $4 .type_enum == ECPGt_union) &&
4771+ if (($5 .type_enum == ECPGt_struct ||
4772+ $5 .type_enum == ECPGt_union) &&
47664773 initializer ==1 )
4774+ {
47674775mmerror (ET_ERROR," Initializer not allowed in EXEC SQL VAR command" );
4768-
4769- adjust_array ($4 .type_enum, &dimension, &length, $4 .type_dimension, $4 .type_index, *$6 ?1 :0 );
4770-
4771- switch ($4 .type_enum)
4776+ }
4777+ else
47724778{
4773- case ECPGt_struct:
4774- case ECPGt_union:
4775- if (dimension <0 )
4776- type = ECPGmake_struct_type(struct_member_list[struct_level],$4 .type_enum);
4777- else
4778- type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],$4 .type_enum), dimension);
4779- break ;
4780- case ECPGt_varchar:
4781- if (dimension == -1 )
4782- type = ECPGmake_simple_type($4 .type_enum, length);
4783- else
4784- type = ECPGmake_array_type(ECPGmake_simple_type($4 .type_enum, length), dimension);
4785-
4786- break ;
4787- case ECPGt_char:
4788- case ECPGt_unsigned_char:
4789- if (dimension == -1 )
4790- type = ECPGmake_simple_type($4 .type_enum, length);
4791- else
4792- type = ECPGmake_array_type(ECPGmake_simple_type($4 .type_enum, length), dimension);
4793-
4794- break ;
4795- default :
4796- if (length >=0 )
4797- mmerror (ET_ERROR," No multi-dimensional array support for simple data types" );
4779+ adjust_array ($5 .type_enum, &dimension, &length, $5 .type_dimension, $5 .type_index, *$7 ?1 :0 );
47984780
4799- if (dimension <0 )
4800- type = ECPGmake_simple_type($4 .type_enum,1 );
4801- else
4802- type = ECPGmake_array_type(ECPGmake_simple_type($4 .type_enum,1 ), dimension);
4803-
4804- break ;
4805- }
4806-
4807- ECPGfree_type (p->type);
4808- p->type = type;
4781+ switch ($5 .type_enum)
4782+ {
4783+ case ECPGt_struct:
4784+ case ECPGt_union:
4785+ if (dimension <0 )
4786+ type = ECPGmake_struct_type(struct_member_list[struct_level],$5 .type_enum);
4787+ else
4788+ type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level],$5 .type_enum), dimension);
4789+ break ;
4790+ case ECPGt_varchar:
4791+ if (dimension == -1 )
4792+ type = ECPGmake_simple_type($5 .type_enum, length);
4793+ else
4794+ type = ECPGmake_array_type(ECPGmake_simple_type($5 .type_enum, length), dimension);
4795+
4796+ break ;
4797+ case ECPGt_char:
4798+ case ECPGt_unsigned_char:
4799+ if (dimension == -1 )
4800+ type = ECPGmake_simple_type($5 .type_enum, length);
4801+ else
4802+ type = ECPGmake_array_type(ECPGmake_simple_type($5 .type_enum, length), dimension);
4803+
4804+ break ;
4805+ default :
4806+ if (length >=0 )
4807+ mmerror (ET_ERROR," No multi-dimensional array support for simple data types" );
4808+
4809+ if (dimension <0 )
4810+ type = ECPGmake_simple_type($5 .type_enum,1 );
4811+ else
4812+ type = ECPGmake_array_type(ECPGmake_simple_type($5 .type_enum,1 ), dimension);
4813+
4814+ break ;
4815+ }
4816+
4817+ ECPGfree_type (p->type);
4818+ p->type = type;
4819+ }
48094820
4810- $$ = cat_str(7 , make_str(" /* exec sql var" ), mm_strdup($2 ), make_str(" is" ), mm_strdup($4 .type_str), mm_strdup($5 .str),$6 , make_str(" */" ));
4821+ $$ = cat_str(7 , make_str(" /* exec sql var" ), mm_strdup($3 ), make_str(" is" ), mm_strdup($5 .type_str), mm_strdup($6 .str),$7 , make_str(" */" ));
48114822};
48124823
48134824/*