Commit 100e7f0c authored by Tom Lane's avatar Tom Lane

Once again, Michael has overwritten someone else's patch ...

parent aff53b27
...@@ -279,7 +279,7 @@ make_name(void) ...@@ -279,7 +279,7 @@ make_name(void)
%type <str> key_match ColLabel SpecialRuleRelation ColId columnDef %type <str> key_match ColLabel SpecialRuleRelation ColId columnDef
%type <str> ColConstraint ColConstraintElem drop_type Bitconst %type <str> ColConstraint ColConstraintElem drop_type Bitconst
%type <str> OptTableElementList OptTableElement TableConstraint %type <str> OptTableElementList OptTableElement TableConstraint
%type <str> ConstraintElem key_actions ColQualList TypeFuncId DropSchemaStmt %type <str> ConstraintElem key_actions ColQualList type_name DropSchemaStmt
%type <str> target_list target_el update_target_list alias_clause %type <str> target_list target_el update_target_list alias_clause
%type <str> update_target_el opt_id relation_name database_name %type <str> update_target_el opt_id relation_name database_name
%type <str> access_method attr_name class index_name name func_name %type <str> access_method attr_name class index_name name func_name
...@@ -357,7 +357,9 @@ make_name(void) ...@@ -357,7 +357,9 @@ make_name(void)
%type <str> struct_type s_struct declaration declarations variable_declarations %type <str> struct_type s_struct declaration declarations variable_declarations
%type <str> s_union union_type ECPGSetAutocommit on_off %type <str> s_union union_type ECPGSetAutocommit on_off
%type <str> ECPGAllocateDescr ECPGDeallocateDescr symbol opt_symbol %type <str> ECPGAllocateDescr ECPGDeallocateDescr symbol opt_symbol
%type <str> ECPGGetDescriptorHeader ECPGTypeFuncId ECPGColId ECPGColLabel %type <str> ECPGGetDescriptorHeader ECPGColLabel
%type <str> reserved_keyword unreserved_keyword
%type <str> col_name_keyword func_name_keyword
%type <str> ECPGTypeName variablelist cvariable %type <str> ECPGTypeName variablelist cvariable
%type <descriptor> ECPGGetDescriptor %type <descriptor> ECPGGetDescriptor
...@@ -1964,7 +1966,7 @@ func_type: Typename ...@@ -1964,7 +1966,7 @@ func_type: Typename
{ {
$$ = $1; $$ = $1;
} }
| TypeFuncId '.' ColId '%' TYPE_P | type_name '.' ColId '%' TYPE_P
{ {
$$ = cat_str(4, $1, make_str("."), $3, make_str("% type")); $$ = cat_str(4, $1, make_str("."), $3, make_str("% type"));
} }
...@@ -2978,8 +2980,7 @@ ConstTypename: Generic { $$ = $1; } ...@@ -2978,8 +2980,7 @@ ConstTypename: Generic { $$ = $1; }
| Character { $$ = $1; } | Character { $$ = $1; }
; ;
Generic: TypeFuncId { $$ = $1; } Generic: type_name { $$ = $1; }
| ECPGTypeName { $$ = $1; }
; ;
/* SQL92 numeric data types /* SQL92 numeric data types
...@@ -4875,7 +4876,7 @@ action : SQL_CONTINUE ...@@ -4875,7 +4876,7 @@ action : SQL_CONTINUE
/* some other stuff for ecpg */ /* some other stuff for ecpg */
/* additional ColId entries */ /* additional unreserved keywords */
ECPGKeywords: SQL_BREAK { $$ = make_str("break"); } ECPGKeywords: SQL_BREAK { $$ = make_str("break"); }
| SQL_CALL { $$ = make_str("call"); } | SQL_CALL { $$ = make_str("call"); }
| SQL_CARDINALITY { $$ = make_str("cardinality"); } | SQL_CARDINALITY { $$ = make_str("cardinality"); }
...@@ -4910,9 +4911,9 @@ ECPGKeywords: SQL_BREAK { $$ = make_str("break"); } ...@@ -4910,9 +4911,9 @@ ECPGKeywords: SQL_BREAK { $$ = make_str("break"); }
| SQL_STOP { $$ = make_str("stop"); } | SQL_STOP { $$ = make_str("stop"); }
| SQL_VAR { $$ = make_str("var"); } | SQL_VAR { $$ = make_str("var"); }
| SQL_WHENEVER { $$ = make_str("whenever"); } | SQL_WHENEVER { $$ = make_str("whenever"); }
/* | ECPGTypeName { $$ = $1 }*/
; ;
/* additional keywords that can be SQL type names (but not ECPGColLabels) */
ECPGTypeName: SQL_BOOL { $$ = make_str("bool"); } ECPGTypeName: SQL_BOOL { $$ = make_str("bool"); }
| SQL_INT { $$ = make_str("int"); } | SQL_INT { $$ = make_str("int"); }
| SQL_LONG { $$ = make_str("long"); } | SQL_LONG { $$ = make_str("long"); }
...@@ -4929,25 +4930,72 @@ opt_symbol: symbol { $$ = $1; } ...@@ -4929,25 +4930,72 @@ opt_symbol: symbol { $$ = $1; }
symbol: ColLabel { $$ = $1; }; symbol: ColLabel { $$ = $1; };
/* /*
* Keyword classification lists. Generally, every keyword present in * Name classification hierarchy.
* the Postgres grammar should be in one of these lists. (Presently, *
* "AS" is the sole exception: it is our only completely-reserved word.) * IDENT is the lexeme returned by the lexer for identifiers that match
* * no known keyword. In most cases, we can accept certain keywords as
* Put a new keyword into the earliest list (of TypeFuncId, ColId, ColLabel) * names, not only IDENTs. We prefer to accept as many such keywords
* that it can go into without creating shift or reduce conflicts. The * as possible to minimize the impact of "reserved words" on programmers.
* earlier lists define "less reserved" categories of keywords. Notice that * So, we divide names into several possible classes. The classification
* each list includes by reference the ones before it. * is chosen in part to make keywords acceptable as names wherever possible.
*/ */
/* Type/func identifier --- names that can be type and function names /* Column identifier --- names that can be column, table, etc names.
* (as well as ColIds --- ie, these are completely unreserved keywords).
*/ */
TypeFuncId: ECPGTypeFuncId { $$ = $1; } ColId: ident { $$ = $1; }
| unreserved_keyword { $$ = $1; }
| col_name_keyword { $$ = $1; }
| ECPGKeywords { $$ = $1; } | ECPGKeywords { $$ = $1; }
| CHAR { $$ = make_str("char"); }
; ;
ECPGTypeFuncId: ident { $$ = $1; } /* Type identifier --- names that can be type names.
| ABORT_TRANS { $$ = make_str("abort"); } */
type_name: ident { $$ = $1; }
| unreserved_keyword { $$ = $1; }
| ECPGKeywords { $$ = $1; }
| ECPGTypeName { $$ = $1; }
;
/* Function identifier --- names that can be function names.
*/
func_name: ident { $$ = $1; }
| unreserved_keyword { $$ = $1; }
| func_name_keyword { $$ = $1; }
| ECPGKeywords { $$ = $1; }
;
/* Column label --- allowed labels in "AS" clauses.
* This presently includes *all* Postgres keywords.
*/
ColLabel: ECPGColLabel { $$ = $1; }
| ECPGTypeName { $$ = $1; }
| CHAR { $$ = make_str("char"); }
| UNION { $$ = make_str("union"); }
;
ECPGColLabel: ident { $$ = $1; }
| unreserved_keyword { $$ = $1; }
| col_name_keyword { $$ = $1; }
| func_name_keyword { $$ = $1; }
| reserved_keyword { $$ = $1; }
| ECPGKeywords { $$ = $1; }
;
/*
* Keyword classification lists. Generally, every keyword present in
* the Postgres grammar should appear in exactly one of these lists.
*
* Put a new keyword into the first list that it can go into without causing
* shift or reduce conflicts. The earlier lists define "less reserved"
* categories of keywords.
*/
/* "Unreserved" keywords --- available for use as any kind of name.
*/
unreserved_keyword:
ABORT_TRANS { $$ = make_str("abort"); }
| ABSOLUTE { $$ = make_str("absolute"); } | ABSOLUTE { $$ = make_str("absolute"); }
| ACCESS { $$ = make_str("access"); } | ACCESS { $$ = make_str("access"); }
| ACTION { $$ = make_str("action"); } | ACTION { $$ = make_str("action"); }
...@@ -5103,69 +5151,96 @@ ECPGTypeFuncId: ident { $$ = $1; } ...@@ -5103,69 +5151,96 @@ ECPGTypeFuncId: ident { $$ = $1; }
| ZONE { $$ = make_str("zone"); } | ZONE { $$ = make_str("zone"); }
; ;
/* Column identifier --- names that can be column, table, etc names. /* Column identifier --- keywords that can be column, table, etc names.
* *
* This contains the TypeFuncId list plus those keywords that conflict * Many of these keywords will in fact be recognized as type or function
* only with typename productions, not with other uses. Note that * names too; but they have special productions for the purpose, and so
* most of these keywords will in fact be recognized as type names too; * can't be treated as "generic" type or function names.
* they just have to have special productions for the purpose.
* *
* Most of these cannot be in TypeFuncId (ie, are not also usable as function * The type names appearing here are not usable as function names
* names) because they can be followed by '(' in typename productions, which * because they can be followed by '(' in typename productions, which
* looks too much like a function call for a LALR(1) parser. * looks too much like a function call for an LR(1) parser.
*/ */
ColId: ECPGColId { $$ = $1; } col_name_keyword:
| CHAR { $$ = make_str("char"); } BIT { $$ = make_str("bit"); }
;
ECPGColId: TypeFuncId { $$ = $1; }
| BIT { $$ = make_str("bit"); }
/* CHAR must be excluded from ECPGColLabel because of conflict with UNSIGNED /* CHAR must be excluded from ECPGColLabel because of conflict with UNSIGNED
| CHAR { $$ = make_str("char"); } | CHAR { $$ = make_str("char"); }
*/ */
| CHARACTER { $$ = make_str("character"); } | CHARACTER { $$ = make_str("character"); }
| COALESCE { $$ = make_str("coalesce"); }
| DEC { $$ = make_str("dec"); } | DEC { $$ = make_str("dec"); }
| DECIMAL { $$ = make_str("decimal"); } | DECIMAL { $$ = make_str("decimal"); }
| EXISTS { $$ = make_str("exists"); }
| EXTRACT { $$ = make_str("extract"); }
| FLOAT { $$ = make_str("float"); } | FLOAT { $$ = make_str("float"); }
| INTERVAL { $$ = make_str("interval"); } | INTERVAL { $$ = make_str("interval"); }
| NCHAR { $$ = make_str("nchar"); } | NCHAR { $$ = make_str("nchar"); }
| NONE { $$ = make_str("none"); } | NONE { $$ = make_str("none"); }
| NULLIF { $$ = make_str("nullif"); }
| NUMERIC { $$ = make_str("numeric"); } | NUMERIC { $$ = make_str("numeric"); }
| POSITION { $$ = make_str("position"); }
| SETOF { $$ = make_str("setof"); } | SETOF { $$ = make_str("setof"); }
| SUBSTRING { $$ = make_str("substring"); }
| TIME { $$ = make_str("time"); } | TIME { $$ = make_str("time"); }
| TIMESTAMP { $$ = make_str("timestamp"); } | TIMESTAMP { $$ = make_str("timestamp"); }
| TRIM { $$ = make_str("trim"); }
| VARCHAR { $$ = make_str("varchar"); } | VARCHAR { $$ = make_str("varchar"); }
; ;
/* Column label --- allowed labels in "AS" clauses. /* Function identifier --- keywords that can be function names.
* *
* Keywords appear here if they could not be distinguished from variable, * Most of these are keywords that are used as operators in expressions;
* type, or function names in some contexts. * in general such keywords can't be column names because they would be
* When adding a ColLabel, consider whether it can be added to func_name. * ambiguous with variables, but they are unambiguous as function identifiers.
*
* Do not include POSITION, SUBSTRING, etc here since they have explicit
* productions in a_expr to support the goofy SQL9x argument syntax.
* - thomas 2000-11-28
*/ */
ColLabel: ECPGColLabel { $$ = $1; } func_name_keyword:
| CHAR { $$ = make_str("char"); } BETWEEN { $$ = make_str("between"); }
| UNION { $$ = make_str("union"); } | BINARY { $$ = make_str("binary"); }
| CROSS { $$ = make_str("cross"); }
| FREEZE { $$ = make_str("freeze"); }
| FULL { $$ = make_str("full"); }
| ILIKE { $$ = make_str("ilike"); }
| IN { $$ = make_str("in"); }
| INNER_P { $$ = make_str("inner"); }
| IS { $$ = make_str("is"); }
| ISNULL { $$ = make_str("isnull"); }
| JOIN { $$ = make_str("join"); }
| LEFT { $$ = make_str("left"); }
| LIKE { $$ = make_str("like"); }
| NATURAL { $$ = make_str("natural"); }
| NOTNULL { $$ = make_str("notnull"); }
| OUTER_P { $$ = make_str("outer"); }
| OVERLAPS { $$ = make_str("overlaps"); }
| PUBLIC { $$ = make_str("public"); }
| RIGHT { $$ = make_str("right"); }
| VERBOSE { $$ = make_str("verbose"); }
; ;
ECPGColLabel: ECPGColId { $$ = $1; } /* Reserved keyword --- these keywords are usable only as a ColLabel.
| ALL { $$ = make_str("all"); } *
* Keywords appear here if they could not be distinguished from variable,
* type, or function names in some contexts. Don't put things here unless
* forced to.
*/
reserved_keyword:
ALL { $$ = make_str("all"); }
| ANALYSE { $$ = make_str("analyse"); } /* British */ | ANALYSE { $$ = make_str("analyse"); } /* British */
| ANALYZE { $$ = make_str("analyze"); } | ANALYZE { $$ = make_str("analyze"); }
| AND { $$ = make_str("and"); } | AND { $$ = make_str("and"); }
| ANY { $$ = make_str("any"); } | ANY { $$ = make_str("any"); }
| AS { $$ = make_str("as"); }
| ASC { $$ = make_str("asc"); } | ASC { $$ = make_str("asc"); }
| BETWEEN { $$ = make_str("between"); }
| BINARY { $$ = make_str("binary"); }
| BOTH { $$ = make_str("both"); } | BOTH { $$ = make_str("both"); }
| CASE { $$ = make_str("case"); } | CASE { $$ = make_str("case"); }
| CAST { $$ = make_str("cast"); } | CAST { $$ = make_str("cast"); }
| CHECK { $$ = make_str("check"); } | CHECK { $$ = make_str("check"); }
| COALESCE { $$ = make_str("coalesce"); }
| COLLATE { $$ = make_str("collate"); } | COLLATE { $$ = make_str("collate"); }
| COLUMN { $$ = make_str("column"); } | COLUMN { $$ = make_str("column"); }
| CONSTRAINT { $$ = make_str("constraint"); } | CONSTRAINT { $$ = make_str("constraint"); }
| CROSS { $$ = make_str("cross"); }
| CURRENT_DATE { $$ = make_str("current_date"); } | CURRENT_DATE { $$ = make_str("current_date"); }
| CURRENT_TIME { $$ = make_str("current_time"); } | CURRENT_TIME { $$ = make_str("current_time"); }
| CURRENT_TIMESTAMP { $$ = make_str("current_timestamp"); } | CURRENT_TIMESTAMP { $$ = make_str("current_timestamp"); }
...@@ -5178,34 +5253,19 @@ ECPGColLabel: ECPGColId { $$ = $1; } ...@@ -5178,34 +5253,19 @@ ECPGColLabel: ECPGColId { $$ = $1; }
| ELSE { $$ = make_str("else"); } | ELSE { $$ = make_str("else"); }
| END_TRANS { $$ = make_str("end"); } | END_TRANS { $$ = make_str("end"); }
| EXCEPT { $$ = make_str("except"); } | EXCEPT { $$ = make_str("except"); }
| EXISTS { $$ = make_str("exists"); }
| EXTRACT { $$ = make_str("extract"); }
| FALSE_P { $$ = make_str("false"); } | FALSE_P { $$ = make_str("false"); }
| FOR { $$ = make_str("for"); } | FOR { $$ = make_str("for"); }
| FOREIGN { $$ = make_str("foreign"); } | FOREIGN { $$ = make_str("foreign"); }
| FREEZE { $$ = make_str("freeze"); }
| FROM { $$ = make_str("from"); } | FROM { $$ = make_str("from"); }
| FULL { $$ = make_str("full"); }
| GROUP { $$ = make_str("group"); } | GROUP { $$ = make_str("group"); }
| HAVING { $$ = make_str("having"); } | HAVING { $$ = make_str("having"); }
| ILIKE { $$ = make_str("ilike"); }
| IN { $$ = make_str("in"); }
| INITIALLY { $$ = make_str("initially"); } | INITIALLY { $$ = make_str("initially"); }
| INNER_P { $$ = make_str("inner"); }
| INTERSECT { $$ = make_str("intersect"); } | INTERSECT { $$ = make_str("intersect"); }
| INTO { $$ = make_str("into"); } | INTO { $$ = make_str("into"); }
| IS { $$ = make_str("is"); }
| ISNULL { $$ = make_str("isnull"); }
| JOIN { $$ = make_str("join"); }
| LEADING { $$ = make_str("leading"); } | LEADING { $$ = make_str("leading"); }
| LEFT { $$ = make_str("left"); }
| LIKE { $$ = make_str("like"); }
| LIMIT { $$ = make_str("limit"); } | LIMIT { $$ = make_str("limit"); }
| NATURAL { $$ = make_str("natural"); }
| NEW { $$ = make_str("new"); } | NEW { $$ = make_str("new"); }
| NOT { $$ = make_str("not"); } | NOT { $$ = make_str("not"); }
| NOTNULL { $$ = make_str("notnull"); }
| NULLIF { $$ = make_str("nullif"); }
| NULL_P { $$ = make_str("null"); } | NULL_P { $$ = make_str("null"); }
| OFF { $$ = make_str("off"); } | OFF { $$ = make_str("off"); }
| OFFSET { $$ = make_str("offset"); } | OFFSET { $$ = make_str("offset"); }
...@@ -5214,22 +5274,15 @@ ECPGColLabel: ECPGColId { $$ = $1; } ...@@ -5214,22 +5274,15 @@ ECPGColLabel: ECPGColId { $$ = $1; }
| ONLY { $$ = make_str("only"); } | ONLY { $$ = make_str("only"); }
| OR { $$ = make_str("or"); } | OR { $$ = make_str("or"); }
| ORDER { $$ = make_str("order"); } | ORDER { $$ = make_str("order"); }
| OUTER_P { $$ = make_str("outer"); }
| OVERLAPS { $$ = make_str("overlaps"); }
| POSITION { $$ = make_str("position"); }
| PRIMARY { $$ = make_str("primary"); } | PRIMARY { $$ = make_str("primary"); }
| PUBLIC { $$ = make_str("public"); }
| REFERENCES { $$ = make_str("references"); } | REFERENCES { $$ = make_str("references"); }
| RIGHT { $$ = make_str("right"); }
| SELECT { $$ = make_str("select"); } | SELECT { $$ = make_str("select"); }
| SESSION_USER { $$ = make_str("session_user"); } | SESSION_USER { $$ = make_str("session_user"); }
| SOME { $$ = make_str("some"); } | SOME { $$ = make_str("some"); }
| SUBSTRING { $$ = make_str("substring"); }
| TABLE { $$ = make_str("table"); } | TABLE { $$ = make_str("table"); }
| THEN { $$ = make_str("then"); } | THEN { $$ = make_str("then"); }
| TO { $$ = make_str("to"); } | TO { $$ = make_str("to"); }
| TRAILING { $$ = make_str("trailing"); } | TRAILING { $$ = make_str("trailing"); }
| TRIM { $$ = make_str("trim"); }
| TRUE_P { $$ = make_str("true"); } | TRUE_P { $$ = make_str("true"); }
/* UNION must be excluded from ECPGColLabel because of conflict with s_union /* UNION must be excluded from ECPGColLabel because of conflict with s_union
| UNION { $$ = make_str("union"); } | UNION { $$ = make_str("union"); }
...@@ -5237,44 +5290,10 @@ ECPGColLabel: ECPGColId { $$ = $1; } ...@@ -5237,44 +5290,10 @@ ECPGColLabel: ECPGColId { $$ = $1; }
| UNIQUE { $$ = make_str("unique"); } | UNIQUE { $$ = make_str("unique"); }
| USER { $$ = make_str("user"); } | USER { $$ = make_str("user"); }
| USING { $$ = make_str("using"); } | USING { $$ = make_str("using"); }
| VERBOSE { $$ = make_str("verbose"); }
| WHEN { $$ = make_str("when"); } | WHEN { $$ = make_str("when"); }
| WHERE { $$ = make_str("where"); } | WHERE { $$ = make_str("where"); }
; ;
/* Function identifier --- names that can be function names.
*
* This contains the TypeFuncId list plus some ColLabel keywords
* that are used as operators in expressions; in general such keywords
* can't be ColId because they would be ambiguous with variable names,
* but they are unambiguous as function identifiers.
*
* Do not include POSITION, SUBSTRING, etc here since they have explicit
* productions in a_expr to support the goofy SQL9x argument syntax.
* - thomas 2000-11-28
*/
func_name: TypeFuncId { $$ = $1; }
| BETWEEN { $$ = make_str("between"); }
| BINARY { $$ = make_str("binary"); }
| CROSS { $$ = make_str("cross"); }
| FREEZE { $$ = make_str("freeze"); }
| FULL { $$ = make_str("full"); }
| ILIKE { $$ = make_str("ilike"); }
| IN { $$ = make_str("in"); }
| INNER_P { $$ = make_str("inner"); }
| IS { $$ = make_str("is"); }
| ISNULL { $$ = make_str("isnull"); }
| JOIN { $$ = make_str("join"); }
| LEFT { $$ = make_str("left"); }
| LIKE { $$ = make_str("like"); }
| NATURAL { $$ = make_str("natural"); }
| NOTNULL { $$ = make_str("notnull"); }
| OUTER_P { $$ = make_str("outer"); }
| OVERLAPS { $$ = make_str("overlaps"); }
| PUBLIC { $$ = make_str("public"); }
| RIGHT { $$ = make_str("right"); }
| VERBOSE { $$ = make_str("verbose"); }
;
into_list : coutputvariable | into_list ',' coutputvariable; into_list : coutputvariable | into_list ',' coutputvariable;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment