@@ -3886,7 +3886,6 @@ connection_target: database_name opt_server opt_port
3886
3886
| db_prefix ' :' server opt_port ' /' database_name opt_options
3887
3887
{
3888
3888
/* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
3889
- printf (" %s\n " , $1 );
3890
3889
if (strncmp($1 , " unix:postgresql" , strlen(" unix:postgresql" )) != 0 && strncmp($1 , " tcp:postgresql" , strlen(" tcp:postgresql" )) != 0 )
3891
3890
{
3892
3891
sprintf (errortext, " only protocols 'tcp' and 'unix' and database type 'postgresql' are supported" );
@@ -4271,10 +4270,6 @@ s_struct: SQL_STRUCT opt_symbol
4271
4270
if (struct_level >= STRUCT_DEPTH)
4272
4271
mmerror (ET_ERROR, " Too many levels in nested structure definition" );
4273
4272
4274
- /* reset this variable so we see if there was */
4275
- /* an initializer specified */
4276
- initializer = 0 ;
4277
-
4278
4273
$$ = cat2_str(make_str(" struct" ), $2 );
4279
4274
};
4280
4275
@@ -4284,10 +4279,6 @@ s_union: UNION opt_symbol
4284
4279
if (struct_level >= STRUCT_DEPTH)
4285
4280
mmerror (ET_ERROR, " Too many levels in nested structure definition" );
4286
4281
4287
- /* reset this variable so we see if there was */
4288
- /* an initializer specified */
4289
- initializer = 0 ;
4290
-
4291
4282
$$ = cat2_str(make_str(" union" ), $2 );
4292
4283
};
4293
4284
@@ -4661,52 +4652,62 @@ ECPGSetConnection: SET SQL_CONNECTION to_equal connection_object
4661
4652
/*
4662
4653
* define a new type for embedded SQL
4663
4654
*/
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
4665
4662
{
4666
4663
/* add entry to list */
4667
4664
struct typedefs *ptr, *this ;
4668
- int dimension = $5 .index1;
4669
- int length = $5 .index2;
4665
+ int dimension = $6 .index1;
4666
+ int length = $6 .index2;
4670
4667
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) &&
4673
4670
initializer == 1 )
4671
+ {
4674
4672
mmerror (ET_ERROR, " Initializer not allowed in EXEC SQL VAR command" );
4675
-
4676
- for (ptr = types; ptr != NULL ; ptr = ptr->next)
4673
+ }
4674
+ else
4677
4675
{
4678
- if (strcmp( $2 , ptr->name) == 0 )
4676
+ for (ptr = types; ptr != NULL ; ptr = ptr->next )
4679
4677
{
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
+ }
4685
4685
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 );
4687
4687
4688
- this = (struct typedefs *) mm_alloc(sizeof (struct typedefs ));
4688
+ this = (struct typedefs *) mm_alloc(sizeof (struct typedefs ));
4689
4689
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 ;
4700
4700
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" );
4706
4706
4707
- types = this ;
4707
+ types = this ;
4708
+ }
4708
4709
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(" */" ));
4710
4711
};
4711
4712
4712
4713
opt_type_array_bounds : ' [' ' ]' opt_type_array_bounds
@@ -4754,60 +4755,70 @@ opt_reference: SQL_REFERENCE { $$ = make_str("reference"); }
4754
4755
/*
4755
4756
* define the type of one variable for embedded SQL
4756
4757
*/
4757
- ECPGVar : SQL_VAR ColLabel IS type opt_type_array_bounds opt_reference
4758
+ ECPGVar : SQL_VAR
4758
4759
{
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;
4762
4769
struct ECPGtype * type;
4763
4770
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) &&
4766
4773
initializer == 1 )
4774
+ {
4767
4775
mmerror (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
4772
4778
{
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 );
4798
4780
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
+ }
4809
4820
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(" */" ));
4811
4822
};
4812
4823
4813
4824
/*
0 commit comments