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 $*/
22
33/* Copyright comment*/
44%{
@@ -541,6 +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
544545
545546%type <struct_union> s_struct_union_symbol
546547
@@ -550,7 +551,7 @@ add_additional_variables(char *name, bool insert)
550551
551552%type <dtype_enum> descriptor_item desc_header_item
552553
553- %type <type> var_type common_type single_vt_type
554+ %type <type> var_type single_vt_type
554555
555556%type <action> action
556557
@@ -4459,7 +4460,7 @@ ecpg_interval:opt_interval{ $$ = $1; }
44594460| MONTH_P TO MONTH_P {$$ = make_str(" month to month" ); }
44604461;
44614462
4462- single_vt_type :common_type
4463+ single_vt_type :var_type
44634464| DOUBLE_P
44644465{
44654466$$ .type_enum = ECPGt_double;
@@ -4468,124 +4469,6 @@ single_vt_type: common_type
44684469$$ .type_index = make_str(" -1" );
44694470$$ .type_sizeof =NULL ;
44704471}
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- }
45894472;
45904473
45914474/*
@@ -4740,7 +4623,7 @@ storage_modifier : S_CONST{ $$ = make_str("const"); }
47404623| S_VOLATILE {$$ = make_str(" volatile" ); }
47414624;
47424625
4743- common_type : simple_type
4626+ var_type : simple_type
47444627{
47454628$$ .type_enum =$1 ;
47464629$$ .type_str = mm_strdup(ECPGtype_name($1 ));
@@ -4796,10 +4679,7 @@ common_type: simple_type
47964679$$ .type_index = make_str(" -1" );
47974680$$ .type_sizeof =NULL ;
47984681}
4799- ;
4800-
4801- var_type :common_type
4802- | ECPGColLabel ecpg_interval
4682+ | ECPGColLabelCommon ecpg_interval
48034683{
48044684if (strlen($2 ) !=0 && strcmp ($1 ," datetime" ) !=0 && strcmp ($1 ," interval" ) !=0 )
48054685mmerror (PARSE_ERROR, ET_ERROR," Interval specification not allowed here" );
@@ -5092,7 +4972,7 @@ variable_list: variable
50924972{$$ = cat_str(3 ,$1 , make_str(" ," ),$3 ); }
50934973;
50944974
5095- variable :opt_pointer ECPGColLabelCommon opt_array_bounds opt_initializer
4975+ variable :opt_pointer ECPGColLabel opt_array_bounds opt_initializer
50964976{
50974977struct ECPGtype * type;
50984978char *dimension =$3 .index1;/* dimension of array*/
@@ -5466,7 +5346,7 @@ ECPGTypedef: TYPE_P
54665346/* an initializer specified*/
54675347initializer =0 ;
54685348}
5469- ColLabel IS var_type opt_array_bounds opt_reference
5349+ ECPGColLabelCommon IS var_type opt_array_bounds opt_reference
54705350{
54715351/* add entry to list*/
54725352struct typedefs *ptr, *this ;
@@ -5778,7 +5658,9 @@ ColLabel: ECPGColLabel{ $$ = $1; }
57785658| INPUT_P {$$ = make_str(" input" ); }
57795659| INT_P {$$ = make_str(" int" ); }
57805660| UNION {$$ = make_str(" union" ); }
5661+ | TO {$$ = make_str(" to" ); }
57815662| ECPGCKeywords {$$ =$1 ; }
5663+ | ECPGunreserved_interval {$$ =$1 ; }
57825664;
57835665
57845666ECPGColLabelCommon :ident {$$ =$1 ; }
@@ -5788,8 +5670,8 @@ ECPGColLabelCommon: ident { $$ = $1; }
57885670 ;
57895671
57905672ECPGColLabel :ECPGColLabelCommon {$$ =$1 ; }
5791- | unreserved_keyword {$$ =$1 ; }
57925673| reserved_keyword {$$ =$1 ; }
5674+ | ECPGunreserved {$$ =$1 ; }
57935675| ECPGKeywords_rest {$$ =$1 ; }
57945676;
57955677
@@ -5800,7 +5682,7 @@ ECPGCKeywords: S_AUTO{ $$ = make_str("auto"); }
58005682| S_STATIC {$$ = make_str(" static" ); }
58015683| S_TYPEDEF {$$ = make_str(" typedef" ); }
58025684;
5803-
5685+
58045686/*
58055687 * Keyword classification lists. Generally, every keyword present in
58065688 * the Postgres grammar should appear in exactly one of these lists.
@@ -5812,8 +5694,21 @@ ECPGCKeywords: S_AUTO{ $$ = make_str("auto"); }
58125694
58135695/* "Unreserved" keywords --- available for use as any kind of name.
58145696*/
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" ); }
58175712| ABSOLUTE_P {$$ = make_str(" absolute" ); }
58185713| ACCESS {$$ = make_str(" access" ); }
58195714| ACTION {$$ = make_str(" action" ); }
@@ -5847,7 +5742,7 @@ unreserved_keyword:
58475742| CURSOR {$$ = make_str(" cursor" ); }
58485743| CYCLE {$$ = make_str(" cycle" ); }
58495744| DATABASE {$$ = make_str(" database" ); }
5850- | DAY_P {$$ = make_str(" day" ); }
5745+ /* | DAY_P{ $$ = make_str("day"); }*/
58515746| DEALLOCATE {$$ = make_str(" deallocate" ); }
58525747| DECLARE {$$ = make_str(" declare" ); }
58535748| DEFAULTS {$$ = make_str(" defaults" ); }
@@ -5874,7 +5769,7 @@ unreserved_keyword:
58745769| GLOBAL {$$ = make_str(" global" ); }
58755770| HANDLER {$$ = make_str(" handler" ); }
58765771| HOLD {$$ = make_str(" hold" ); }
5877- | HOUR_P {$$ = make_str(" hour" ); }
5772+ /* | HOUR_P{ $$ = make_str("hour"); }*/
58785773| IMMEDIATE {$$ = make_str(" immediate" ); }
58795774| IMMUTABLE {$$ = make_str(" immutable" ); }
58805775| IMPLICIT_P {$$ = make_str(" implicit" ); }
@@ -5899,10 +5794,10 @@ unreserved_keyword:
58995794| LOCK_P {$$ = make_str(" lock" ); }
59005795| MATCH {$$ = make_str(" match" ); }
59015796| MAXVALUE {$$ = make_str(" maxvalue" ); }
5902- | MINUTE_P {$$ = make_str(" minute" ); }
5797+ /* | MINUTE_P{ $$ = make_str("minute"); }*/
59035798| MINVALUE {$$ = make_str(" minvalue" ); }
59045799| MODE {$$ = make_str(" mode" ); }
5905- | MONTH_P {$$ = make_str(" month" ); }
5800+ /* | MONTH_P{ $$ = make_str("month"); }*/
59065801| MOVE {$$ = make_str(" move" ); }
59075802| NAMES {$$ = make_str(" names" ); }
59085803| NATIONAL {$$ = make_str(" national" ); }
@@ -5945,7 +5840,7 @@ unreserved_keyword:
59455840| RULE {$$ = make_str(" rule" ); }
59465841| SCHEMA {$$ = make_str(" schema" ); }
59475842| SCROLL {$$ = make_str(" scroll" ); }
5948- | SECOND_P {$$ = make_str(" second" ); }
5843+ /* | SECOND_P{ $$ = make_str("second"); }*/
59495844| SEQUENCE {$$ = make_str(" sequence" ); }
59505845| SERIALIZABLE {$$ = make_str(" serializable" ); }
59515846| SESSION {$$ = make_str(" session" ); }
@@ -5987,7 +5882,7 @@ unreserved_keyword:
59875882| WITHOUT {$$ = make_str(" without" ); }
59885883| WORK {$$ = make_str(" work" ); }
59895884| WRITE {$$ = make_str(" write" ); }
5990- | YEAR_P {$$ = make_str(" year" ); }
5885+ /* | YEAR_P{ $$ = make_str("year"); }*/
59915886| ZONE {$$ = make_str(" zone" ); }
59925887;
59935888
@@ -6135,7 +6030,9 @@ reserved_keyword:
61356030| SOME {$$ = make_str(" some" ); }
61366031| TABLE {$$ = make_str(" table" ); }
61376032| THEN {$$ = make_str(" then" ); }
6033+ /* TO must be excluded from ECPGColLabel because of a conflict in variable name parsing
61386034| TO{ $$ = make_str("to"); }
6035+ */
61396036| TRAILING {$$ = make_str(" trailing" ); }
61406037| TRUE_P {$$ = make_str(" true" ); }
61416038/* UNION must be excluded from ECPGColLabel because of conflict with s_union