@@ -401,9 +401,10 @@ static TypeName *TableFuncTypeName(List *columns);
401401
402402%type <ival> Iconst SignedIconst
403403%type <str> Sconst comment_text notify_payload
404- %type <str> RoleId opt_granted_by opt_boolean_or_string ColId_or_Sconst
404+ %type <str> RoleId opt_granted_by opt_boolean_or_string
405405%type <list> var_list
406406%type <str> ColId ColLabel var_name type_function_name param_name
407+ %type <str> NonReservedWord NonReservedWord_or_Sconst
407408%type <node> var_value zone_value
408409
409410%type <keyword> unreserved_keyword type_func_name_keyword
@@ -1275,15 +1276,15 @@ set_rest:/* Generic SET syntaxes: */
12751276n->kind = VAR_SET_DEFAULT;
12761277$$ = n;
12771278}
1278- | ROLE ColId_or_Sconst
1279+ | ROLE NonReservedWord_or_Sconst
12791280{
12801281VariableSetStmt *n = makeNode(VariableSetStmt);
12811282n->kind = VAR_SET_VALUE;
12821283n->name =" role" ;
12831284n->args = list_make1(makeStringConst($2 ,@2 ));
12841285$$ = n;
12851286}
1286- | SESSION AUTHORIZATION ColId_or_Sconst
1287+ | SESSION AUTHORIZATION NonReservedWord_or_Sconst
12871288{
12881289VariableSetStmt *n = makeNode(VariableSetStmt);
12891290n->kind = VAR_SET_VALUE;
@@ -1337,11 +1338,11 @@ opt_boolean_or_string:
13371338| FALSE_P {$$ =" false" ; }
13381339| ON {$$ =" on" ; }
13391340/*
1340- * OFF is also accepted as a boolean value, but is handled
1341- *by theColId rule below. The action for booleans and strings
1341+ * OFF is also accepted as a boolean value, but is handled by
1342+ * theNonReservedWord rule. The action for booleans and strings
13421343 * is the same, so we don't need to distinguish them here.
13431344*/
1344- | ColId_or_Sconst {$$ =$1 ; }
1345+ | NonReservedWord_or_Sconst {$$ =$1 ; }
13451346;
13461347
13471348/* Timezone values can be:
@@ -1410,8 +1411,8 @@ opt_encoding:
14101411| /* EMPTY*/ {$$ =NULL ; }
14111412;
14121413
1413- ColId_or_Sconst :
1414- ColId {$$ =$1 ; }
1414+ NonReservedWord_or_Sconst :
1415+ NonReservedWord {$$ =$1 ; }
14151416| Sconst {$$ =$1 ; }
14161417;
14171418
@@ -2894,7 +2895,7 @@ NumericOnly_list:NumericOnly{ $$ = list_make1($1); }
28942895 *****************************************************************************/
28952896
28962897CreatePLangStmt :
2897- CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE ColId_or_Sconst
2898+ CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst
28982899{
28992900CreatePLangStmt *n = makeNode(CreatePLangStmt);
29002901n->replace =$2 ;
@@ -2906,7 +2907,7 @@ CreatePLangStmt:
29062907n->pltrusted =false ;
29072908$$ = (Node *)n;
29082909}
2909- | CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE ColId_or_Sconst
2910+ | CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst
29102911HANDLER handler_name opt_inline_handler opt_validator
29112912{
29122913CreatePLangStmt *n = makeNode(CreatePLangStmt);
@@ -2950,15 +2951,15 @@ opt_validator:
29502951;
29512952
29522953DropPLangStmt :
2953- DROP opt_procedural LANGUAGE ColId_or_Sconst opt_drop_behavior
2954+ DROP opt_procedural LANGUAGE NonReservedWord_or_Sconst opt_drop_behavior
29542955{
29552956DropPLangStmt *n = makeNode(DropPLangStmt);
29562957n->plname =$4 ;
29572958n->behavior =$5 ;
29582959n->missing_ok =false ;
29592960$$ = (Node *)n;
29602961}
2961- | DROP opt_procedural LANGUAGE IF_P EXISTS ColId_or_Sconst opt_drop_behavior
2962+ | DROP opt_procedural LANGUAGE IF_P EXISTS NonReservedWord_or_Sconst opt_drop_behavior
29622963{
29632964DropPLangStmt *n = makeNode(DropPLangStmt);
29642965n->plname =$6 ;
@@ -5256,7 +5257,7 @@ createfunc_opt_item:
52565257{
52575258$$ = makeDefElem(" as" , (Node *)$2 );
52585259}
5259- | LANGUAGEColId_or_Sconst
5260+ | LANGUAGENonReservedWord_or_Sconst
52605261{
52615262$$ = makeDefElem(" language" , (Node *)makeString($2 ));
52625263}
@@ -5465,7 +5466,7 @@ dostmt_opt_item:
54655466{
54665467$$ = makeDefElem(" as" , (Node *)makeString($1 ));
54675468}
5468- | LANGUAGEColId_or_Sconst
5469+ | LANGUAGENonReservedWord_or_Sconst
54695470{
54705471$$ = makeDefElem(" language" , (Node *)makeString($2 ));
54715472}
@@ -6978,9 +6979,7 @@ explain_option_elem:
69786979;
69796980
69806981explain_option_name:
6981- ColId{$$ =$1 ; }
6982- | analyze_keyword{$$ =" analyze" ; }
6983- | VERBOSE{$$ =" verbose" ; }
6982+ NonReservedWord{$$ =$1 ; }
69846983;
69856984
69866985explain_option_arg:
@@ -10776,7 +10775,7 @@ AexprConst: Iconst
1077610775
1077710776Iconst:ICONST{ $$ = $1 ; };
1077810777Sconst:SCONST{ $$ = $1 ; };
10779- RoleId:ColId { $$ = $1 ; };
10778+ RoleId:NonReservedWord { $$ = $1 ; };
1078010779
1078110780SignedIconst: Iconst{ $$ = $1 ; }
1078210781|' +' Iconst{ $$ = + $2 ; }
@@ -10808,6 +10807,14 @@ type_function_name:IDENT{ $$ = $1; }
1080810807| type_func_name_keyword{ $$ =pstrdup ($1 ); }
1080910808;
1081010809
10810+ /* Any not-fully-reserved word --- these names can be, eg, role names.
10811+ */
10812+ NonReservedWord:IDENT{ $$ = $1 ; }
10813+ | unreserved_keyword{ $$ =pstrdup ($1 ); }
10814+ | col_name_keyword{ $$ =pstrdup ($1 ); }
10815+ | type_func_name_keyword{ $$ =pstrdup ($1 ); }
10816+ ;
10817+
1081110818/* Column label --- allowed labels in "AS" clauses.
1081210819 * This presently includes *all* Postgres keywords.
1081310820*/