1
- /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.273 2004/02/15 15:38:20 meskes Exp $*/
1
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.274 2004/02/16 07:41:54 meskes Exp $*/
2
2
3
3
/* Copyright comment*/
4
4
%{
@@ -541,6 +541,7 @@ add_additional_variables(char *name, bool insert)
541
541
%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst
542
542
%type <str> inf_val_list inf_col_list using_descriptor into_descriptor
543
543
%type <str> ecpg_into_using prepared_name struct_union_type_with_symbol
544
+ %type <str> ECPGunreserved ECPGunreserved_interval
544
545
545
546
%type <struct_union> s_struct_union_symbol
546
547
@@ -550,7 +551,7 @@ add_additional_variables(char *name, bool insert)
550
551
551
552
%type <dtype_enum> descriptor_item desc_header_item
552
553
553
- %type <type> var_type common_type single_vt_type
554
+ %type <type> var_type single_vt_type
554
555
555
556
%type <action> action
556
557
@@ -4459,7 +4460,7 @@ ecpg_interval:opt_interval{ $$ = $1; }
4459
4460
| MONTH_P TO MONTH_P {$$ = make_str(" month to month" ); }
4460
4461
;
4461
4462
4462
- single_vt_type :common_type
4463
+ single_vt_type :var_type
4463
4464
| DOUBLE_P
4464
4465
{
4465
4466
$$ .type_enum = ECPGt_double;
@@ -4468,124 +4469,6 @@ single_vt_type: common_type
4468
4469
$$ .type_index = make_str(" -1" );
4469
4470
$$ .type_sizeof =NULL ;
4470
4471
}
4471
- | ECPGColLabelCommon ecpg_interval
4472
- {
4473
- if (strlen($2 ) !=0 && strcmp ($1 ," datetime" ) !=0 && strcmp ($1 ," interval" ) !=0 )
4474
- mmerror (PARSE_ERROR, ET_ERROR," Interval specification not allowed here" );
4475
-
4476
- /*
4477
- * Check for type names that the SQL grammar treats as
4478
- * unreserved keywords
4479
- */
4480
- if (strcmp($1 ," varchar" ) ==0 )
4481
- {
4482
- $$ .type_enum = ECPGt_varchar;
4483
- $$ .type_str = EMPTY;
4484
- $$ .type_dimension = make_str(" -1" );
4485
- $$ .type_index = make_str(" -1" );
4486
- $$ .type_sizeof =NULL ;
4487
- }
4488
- else if (strcmp($1 ," float" ) ==0 )
4489
- {
4490
- $$ .type_enum = ECPGt_float;
4491
- $$ .type_str = make_str(" float" );
4492
- $$ .type_dimension = make_str(" -1" );
4493
- $$ .type_index = make_str(" -1" );
4494
- $$ .type_sizeof =NULL ;
4495
- }
4496
- else if (strcmp($1 ," numeric" ) ==0 )
4497
- {
4498
- $$ .type_enum = ECPGt_numeric;
4499
- $$ .type_str = make_str(" numeric" );
4500
- $$ .type_dimension = make_str(" -1" );
4501
- $$ .type_index = make_str(" -1" );
4502
- $$ .type_sizeof =NULL ;
4503
- }
4504
- else if (strcmp($1 ," decimal" ) ==0 )
4505
- {
4506
- $$ .type_enum = ECPGt_decimal;
4507
- $$ .type_str = make_str(" decimal" );
4508
- $$ .type_dimension = make_str(" -1" );
4509
- $$ .type_index = make_str(" -1" );
4510
- $$ .type_sizeof =NULL ;
4511
- }
4512
- else if (strcmp($1 ," date" ) ==0 )
4513
- {
4514
- $$ .type_enum = ECPGt_date;
4515
- $$ .type_str = make_str(" date" );
4516
- $$ .type_dimension = make_str(" -1" );
4517
- $$ .type_index = make_str(" -1" );
4518
- $$ .type_sizeof =NULL ;
4519
- }
4520
- else if (strcmp($1 ," timestamp" ) ==0 )
4521
- {
4522
- $$ .type_enum = ECPGt_timestamp;
4523
- $$ .type_str = make_str(" timestamp" );
4524
- $$ .type_dimension = make_str(" -1" );
4525
- $$ .type_index = make_str(" -1" );
4526
- $$ .type_sizeof =NULL ;
4527
- }
4528
- else if (strcmp($1 ," datetime" ) ==0 )
4529
- {
4530
- $$ .type_enum = ECPGt_timestamp;
4531
- $$ .type_str = make_str(" timestamp" );
4532
- $$ .type_dimension = make_str(" -1" );
4533
- $$ .type_index = make_str(" -1" );
4534
- $$ .type_sizeof =NULL ;
4535
- }
4536
- else if (strcmp($1 ," interval" ) ==0 )
4537
- {
4538
- $$ .type_enum = ECPGt_interval;
4539
- $$ .type_str = make_str(" interval" );
4540
- $$ .type_dimension = make_str(" -1" );
4541
- $$ .type_index = make_str(" -1" );
4542
- $$ .type_sizeof =NULL ;
4543
- }
4544
- else
4545
- {
4546
- /* this is for typedef'ed types*/
4547
- struct typedefs *this = get_typedef($1 );
4548
-
4549
- $$ .type_str = (this ->type->type_enum == ECPGt_varchar) ? EMPTY : mm_strdup(this ->name);
4550
- $$ .type_enum =this ->type->type_enum;
4551
- $$ .type_dimension =this ->type->type_dimension;
4552
- $$ .type_index =this ->type->type_index;
4553
- $$ .type_sizeof =this ->type->type_sizeof;
4554
- struct_member_list[struct_level] = ECPGstruct_member_dup(this ->struct_member_list);
4555
- }
4556
- }
4557
- | s_struct_union_symbol
4558
- {
4559
- /* this is for named structs/unions*/
4560
- char *name;
4561
- struct typedefs *this ;
4562
- bool forward = (forward_name !=NULL && strcmp($1 .symbol, forward_name) ==0 && strcmp($1 .su," struct" ) ==0 );
4563
-
4564
- name = cat2_str($1 .su,$1 .symbol);
4565
- /* Do we have a forward definition?*/
4566
- if (!forward)
4567
- {
4568
- /* No*/
4569
-
4570
- this = get_typedef(name);
4571
- $$ .type_str = mm_strdup(this ->name);
4572
- $$ .type_enum =this ->type->type_enum;
4573
- $$ .type_dimension =this ->type->type_dimension;
4574
- $$ .type_index =this ->type->type_index;
4575
- $$ .type_sizeof =this ->type->type_sizeof;
4576
- struct_member_list[struct_level] = ECPGstruct_member_dup(this ->struct_member_list);
4577
- free (name);
4578
- }
4579
- else
4580
- {
4581
- $$ .type_str = name;
4582
- $$ .type_enum = ECPGt_long;
4583
- $$ .type_dimension = make_str(" -1" );
4584
- $$ .type_index = make_str(" -1" );
4585
- $$ .type_sizeof = make_str(" " );
4586
- struct_member_list[struct_level] =NULL ;
4587
- }
4588
- }
4589
4472
;
4590
4473
4591
4474
/*
@@ -4740,7 +4623,7 @@ storage_modifier : S_CONST{ $$ = make_str("const"); }
4740
4623
| S_VOLATILE {$$ = make_str(" volatile" ); }
4741
4624
;
4742
4625
4743
- common_type : simple_type
4626
+ var_type : simple_type
4744
4627
{
4745
4628
$$ .type_enum =$1 ;
4746
4629
$$ .type_str = mm_strdup(ECPGtype_name($1 ));
@@ -4796,10 +4679,7 @@ common_type: simple_type
4796
4679
$$ .type_index = make_str(" -1" );
4797
4680
$$ .type_sizeof =NULL ;
4798
4681
}
4799
- ;
4800
-
4801
- var_type :common_type
4802
- | ECPGColLabel ecpg_interval
4682
+ | ECPGColLabelCommon ecpg_interval
4803
4683
{
4804
4684
if (strlen($2 ) !=0 && strcmp ($1 ," datetime" ) !=0 && strcmp ($1 ," interval" ) !=0 )
4805
4685
mmerror (PARSE_ERROR, ET_ERROR," Interval specification not allowed here" );
@@ -5092,7 +4972,7 @@ variable_list: variable
5092
4972
{$$ = cat_str(3 ,$1 , make_str(" ," ),$3 ); }
5093
4973
;
5094
4974
5095
- variable :opt_pointer ECPGColLabelCommon opt_array_bounds opt_initializer
4975
+ variable :opt_pointer ECPGColLabel opt_array_bounds opt_initializer
5096
4976
{
5097
4977
struct ECPGtype * type;
5098
4978
char *dimension =$3 .index1;/* dimension of array*/
@@ -5466,7 +5346,7 @@ ECPGTypedef: TYPE_P
5466
5346
/* an initializer specified*/
5467
5347
initializer =0 ;
5468
5348
}
5469
- ColLabel IS var_type opt_array_bounds opt_reference
5349
+ ECPGColLabelCommon IS var_type opt_array_bounds opt_reference
5470
5350
{
5471
5351
/* add entry to list*/
5472
5352
struct typedefs *ptr, *this ;
@@ -5778,7 +5658,9 @@ ColLabel: ECPGColLabel{ $$ = $1; }
5778
5658
| INPUT_P {$$ = make_str(" input" ); }
5779
5659
| INT_P {$$ = make_str(" int" ); }
5780
5660
| UNION {$$ = make_str(" union" ); }
5661
+ | TO {$$ = make_str(" to" ); }
5781
5662
| ECPGCKeywords {$$ =$1 ; }
5663
+ | ECPGunreserved_interval {$$ =$1 ; }
5782
5664
;
5783
5665
5784
5666
ECPGColLabelCommon :ident {$$ =$1 ; }
@@ -5788,8 +5670,8 @@ ECPGColLabelCommon: ident { $$ = $1; }
5788
5670
;
5789
5671
5790
5672
ECPGColLabel :ECPGColLabelCommon {$$ =$1 ; }
5791
- | unreserved_keyword {$$ =$1 ; }
5792
5673
| reserved_keyword {$$ =$1 ; }
5674
+ | ECPGunreserved {$$ =$1 ; }
5793
5675
| ECPGKeywords_rest {$$ =$1 ; }
5794
5676
;
5795
5677
@@ -5800,7 +5682,7 @@ ECPGCKeywords: S_AUTO{ $$ = make_str("auto"); }
5800
5682
| S_STATIC {$$ = make_str(" static" ); }
5801
5683
| S_TYPEDEF {$$ = make_str(" typedef" ); }
5802
5684
;
5803
-
5685
+
5804
5686
/*
5805
5687
* Keyword classification lists. Generally, every keyword present in
5806
5688
* the Postgres grammar should appear in exactly one of these lists.
@@ -5812,8 +5694,21 @@ ECPGCKeywords: S_AUTO{ $$ = make_str("auto"); }
5812
5694
5813
5695
/* "Unreserved" keywords --- available for use as any kind of name.
5814
5696
*/
5815
- unreserved_keyword :
5816
- ABORT_P {$$ = make_str(" abort" ); }
5697
+ /* The following symbols must be excluded from ECPGColLabel and directly included into ColLabel
5698
+ to enable C variables to get names from ECPGColLabel:
5699
+ DAY_P, HOUR_P, MINUTE_P, MONTH_P, SECOND_P, YEAR_P
5700
+ */
5701
+ unreserved_keyword :ECPGunreserved_interval | ECPGunreserved ;
5702
+
5703
+ ECPGunreserved_interval :DAY_P {$$ = make_str(" day" ); }
5704
+ | HOUR_P {$$ = make_str(" hour" ); }
5705
+ | MINUTE_P {$$ = make_str(" minute" ); }
5706
+ | MONTH_P {$$ = make_str(" month" ); }
5707
+ | SECOND_P {$$ = make_str(" second" ); }
5708
+ | YEAR_P {$$ = make_str(" year" ); }
5709
+ ;
5710
+
5711
+ ECPGunreserved :ABORT_P {$$ = make_str(" abort" ); }
5817
5712
| ABSOLUTE_P {$$ = make_str(" absolute" ); }
5818
5713
| ACCESS {$$ = make_str(" access" ); }
5819
5714
| ACTION {$$ = make_str(" action" ); }
@@ -5847,7 +5742,7 @@ unreserved_keyword:
5847
5742
| CURSOR {$$ = make_str(" cursor" ); }
5848
5743
| CYCLE {$$ = make_str(" cycle" ); }
5849
5744
| DATABASE {$$ = make_str(" database" ); }
5850
- | DAY_P {$$ = make_str(" day" ); }
5745
+ /* | DAY_P{ $$ = make_str("day"); }*/
5851
5746
| DEALLOCATE {$$ = make_str(" deallocate" ); }
5852
5747
| DECLARE {$$ = make_str(" declare" ); }
5853
5748
| DEFAULTS {$$ = make_str(" defaults" ); }
@@ -5874,7 +5769,7 @@ unreserved_keyword:
5874
5769
| GLOBAL {$$ = make_str(" global" ); }
5875
5770
| HANDLER {$$ = make_str(" handler" ); }
5876
5771
| HOLD {$$ = make_str(" hold" ); }
5877
- | HOUR_P {$$ = make_str(" hour" ); }
5772
+ /* | HOUR_P{ $$ = make_str("hour"); }*/
5878
5773
| IMMEDIATE {$$ = make_str(" immediate" ); }
5879
5774
| IMMUTABLE {$$ = make_str(" immutable" ); }
5880
5775
| IMPLICIT_P {$$ = make_str(" implicit" ); }
@@ -5899,10 +5794,10 @@ unreserved_keyword:
5899
5794
| LOCK_P {$$ = make_str(" lock" ); }
5900
5795
| MATCH {$$ = make_str(" match" ); }
5901
5796
| MAXVALUE {$$ = make_str(" maxvalue" ); }
5902
- | MINUTE_P {$$ = make_str(" minute" ); }
5797
+ /* | MINUTE_P{ $$ = make_str("minute"); }*/
5903
5798
| MINVALUE {$$ = make_str(" minvalue" ); }
5904
5799
| MODE {$$ = make_str(" mode" ); }
5905
- | MONTH_P {$$ = make_str(" month" ); }
5800
+ /* | MONTH_P{ $$ = make_str("month"); }*/
5906
5801
| MOVE {$$ = make_str(" move" ); }
5907
5802
| NAMES {$$ = make_str(" names" ); }
5908
5803
| NATIONAL {$$ = make_str(" national" ); }
@@ -5945,7 +5840,7 @@ unreserved_keyword:
5945
5840
| RULE {$$ = make_str(" rule" ); }
5946
5841
| SCHEMA {$$ = make_str(" schema" ); }
5947
5842
| SCROLL {$$ = make_str(" scroll" ); }
5948
- | SECOND_P {$$ = make_str(" second" ); }
5843
+ /* | SECOND_P{ $$ = make_str("second"); }*/
5949
5844
| SEQUENCE {$$ = make_str(" sequence" ); }
5950
5845
| SERIALIZABLE {$$ = make_str(" serializable" ); }
5951
5846
| SESSION {$$ = make_str(" session" ); }
@@ -5987,7 +5882,7 @@ unreserved_keyword:
5987
5882
| WITHOUT {$$ = make_str(" without" ); }
5988
5883
| WORK {$$ = make_str(" work" ); }
5989
5884
| WRITE {$$ = make_str(" write" ); }
5990
- | YEAR_P {$$ = make_str(" year" ); }
5885
+ /* | YEAR_P{ $$ = make_str("year"); }*/
5991
5886
| ZONE {$$ = make_str(" zone" ); }
5992
5887
;
5993
5888
@@ -6135,7 +6030,9 @@ reserved_keyword:
6135
6030
| SOME {$$ = make_str(" some" ); }
6136
6031
| TABLE {$$ = make_str(" table" ); }
6137
6032
| THEN {$$ = make_str(" then" ); }
6033
+ /* TO must be excluded from ECPGColLabel because of a conflict in variable name parsing
6138
6034
| TO{ $$ = make_str("to"); }
6035
+ */
6139
6036
| TRAILING {$$ = make_str(" trailing" ); }
6140
6037
| TRUE_P {$$ = make_str(" true" ); }
6141
6038
/* UNION must be excluded from ECPGColLabel because of conflict with s_union