@@ -450,9 +450,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
450450
451451%type <ival> Iconst SignedIconst
452452%type <str> Sconst comment_text notify_payload
453- %type <str> RoleId opt_granted_by opt_boolean_or_string ColId_or_Sconst
453+ %type <str> RoleId opt_granted_by opt_boolean_or_string
454454%type <list> var_list
455455%type <str> ColId ColLabel var_name type_function_name param_name
456+ %type <str> NonReservedWord NonReservedWord_or_Sconst
456457%type <node> var_value zone_value
457458
458459%type <keyword> unreserved_keyword type_func_name_keyword
@@ -1402,15 +1403,15 @@ set_rest_more: /* Generic SET syntaxes: */
14021403 n->kind = VAR_SET_DEFAULT;
14031404 $$ = n;
14041405 }
1405- | ROLE ColId_or_Sconst
1406+ | ROLE NonReservedWord_or_Sconst
14061407 {
14071408 VariableSetStmt *n = makeNode(VariableSetStmt);
14081409 n->kind = VAR_SET_VALUE;
14091410 n->name = " role" ;
14101411 n->args = list_make1(makeStringConst($2 , @2 ));
14111412 $$ = n;
14121413 }
1413- | SESSION AUTHORIZATION ColId_or_Sconst
1414+ | SESSION AUTHORIZATION NonReservedWord_or_Sconst
14141415 {
14151416 VariableSetStmt *n = makeNode(VariableSetStmt);
14161417 n->kind = VAR_SET_VALUE;
@@ -1473,11 +1474,11 @@ opt_boolean_or_string:
14731474 | FALSE_P { $$ = " false" ; }
14741475 | ON { $$ = " on" ; }
14751476 /*
1476- * OFF is also accepted as a boolean value, but is handled
1477- * by the ColId rule below. The action for booleans and strings
1477+ * OFF is also accepted as a boolean value, but is handled by
1478+ * the NonReservedWord rule. The action for booleans and strings
14781479 * is the same, so we don't need to distinguish them here.
14791480 */
1480- | ColId_or_Sconst { $$ = $1 ; }
1481+ | NonReservedWord_or_Sconst { $$ = $1 ; }
14811482 ;
14821483
14831484/* Timezone values can be:
@@ -1546,8 +1547,8 @@ opt_encoding:
15461547 | /* EMPTY*/ { $$ = NULL ; }
15471548 ;
15481549
1549- ColId_or_Sconst :
1550- ColId { $$ = $1 ; }
1550+ NonReservedWord_or_Sconst :
1551+ NonReservedWord { $$ = $1 ; }
15511552 | Sconst { $$ = $1 ; }
15521553 ;
15531554
@@ -3418,7 +3419,7 @@ NumericOnly_list: NumericOnly { $$ = list_make1($1); }
34183419 *****************************************************************************/
34193420
34203421CreatePLangStmt :
3421- CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE ColId_or_Sconst
3422+ CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst
34223423 {
34233424 CreatePLangStmt *n = makeNode(CreatePLangStmt);
34243425 n->replace = $2 ;
@@ -3430,7 +3431,7 @@ CreatePLangStmt:
34303431 n->pltrusted = false ;
34313432 $$ = (Node *)n;
34323433 }
3433- | CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE ColId_or_Sconst
3434+ | CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE NonReservedWord_or_Sconst
34343435 HANDLER handler_name opt_inline_handler opt_validator
34353436 {
34363437 CreatePLangStmt *n = makeNode(CreatePLangStmt);
@@ -3474,7 +3475,7 @@ opt_validator:
34743475 ;
34753476
34763477DropPLangStmt :
3477- DROP opt_procedural LANGUAGE ColId_or_Sconst opt_drop_behavior
3478+ DROP opt_procedural LANGUAGE NonReservedWord_or_Sconst opt_drop_behavior
34783479 {
34793480 DropStmt *n = makeNode(DropStmt);
34803481 n->removeType = OBJECT_LANGUAGE;
@@ -3485,7 +3486,7 @@ DropPLangStmt:
34853486 n->concurrent = false ;
34863487 $$ = (Node *)n;
34873488 }
3488- | DROP opt_procedural LANGUAGE IF_P EXISTS ColId_or_Sconst opt_drop_behavior
3489+ | DROP opt_procedural LANGUAGE IF_P EXISTS NonReservedWord_or_Sconst opt_drop_behavior
34893490 {
34903491 DropStmt *n = makeNode(DropStmt);
34913492 n->removeType = OBJECT_LANGUAGE;
@@ -3587,11 +3588,11 @@ create_extension_opt_item:
35873588 {
35883589 $$ = makeDefElem(" schema" , (Node *)makeString($2 ));
35893590 }
3590- | VERSION_P ColId_or_Sconst
3591+ | VERSION_P NonReservedWord_or_Sconst
35913592 {
35923593 $$ = makeDefElem(" new_version" , (Node *)makeString($2 ));
35933594 }
3594- | FROM ColId_or_Sconst
3595+ | FROM NonReservedWord_or_Sconst
35953596 {
35963597 $$ = makeDefElem(" old_version" , (Node *)makeString($2 ));
35973598 }
@@ -3620,7 +3621,7 @@ alter_extension_opt_list:
36203621 ;
36213622
36223623alter_extension_opt_item :
3623- TO ColId_or_Sconst
3624+ TO NonReservedWord_or_Sconst
36243625 {
36253626 $$ = makeDefElem(" new_version" , (Node *)makeString($2 ));
36263627 }
@@ -5428,8 +5429,8 @@ SecLabelStmt:
54285429 }
54295430 ;
54305431
5431- opt_provider : FOR ColId_or_Sconst { $$ = $2 ; }
5432- | /* empty */ { $$ = NULL ; }
5432+ opt_provider : FOR NonReservedWord_or_Sconst { $$ = $2 ; }
5433+ | /* empty */ { $$ = NULL ; }
54335434 ;
54345435
54355436security_label_type :
@@ -6455,7 +6456,7 @@ createfunc_opt_item:
64556456 {
64566457 $$ = makeDefElem(" as" , (Node *)$2 );
64576458 }
6458- | LANGUAGE ColId_or_Sconst
6459+ | LANGUAGE NonReservedWord_or_Sconst
64596460 {
64606461 $$ = makeDefElem(" language" , (Node *)makeString($2 ));
64616462 }
@@ -6670,7 +6671,7 @@ dostmt_opt_item:
66706671 {
66716672 $$ = makeDefElem(" as" , (Node *)makeString($1 ));
66726673 }
6673- | LANGUAGE ColId_or_Sconst
6674+ | LANGUAGE NonReservedWord_or_Sconst
66746675 {
66756676 $$ = makeDefElem(" language" , (Node *)makeString($2 ));
66766677 }
@@ -8667,9 +8668,7 @@ explain_option_elem:
86678668 ;
86688669
86698670explain_option_name :
8670- ColId { $$ = $1 ; }
8671- | analyze_keyword { $$ = " analyze" ; }
8672- | VERBOSE { $$ = " verbose" ; }
8671+ NonReservedWord { $$ = $1 ; }
86738672 ;
86748673
86758674explain_option_arg :
@@ -12580,7 +12579,7 @@ AexprConst: Iconst
1258012579
1258112580Iconst: ICONST { $$ = $1 ; };
1258212581Sconst: SCONST { $$ = $1 ; };
12583- RoleId: ColId { $$ = $1 ; };
12582+ RoleId: NonReservedWord { $$ = $1 ; };
1258412583
1258512584SignedIconst: Iconst { $$ = $1 ; }
1258612585 | ' +' Iconst { $$ = + $2 ; }
@@ -12612,6 +12611,14 @@ type_function_name: IDENT { $$ = $1; }
1261212611 | type_func_name_keyword { $$ = pstrdup ($1 ); }
1261312612 ;
1261412613
12614+ /* Any not-fully-reserved word --- these names can be, eg, role names.
12615+ */
12616+ NonReservedWord: IDENT { $$ = $1 ; }
12617+ | unreserved_keyword { $$ = pstrdup ($1 ); }
12618+ | col_name_keyword { $$ = pstrdup ($1 ); }
12619+ | type_func_name_keyword { $$ = pstrdup ($1 ); }
12620+ ;
12621+
1261512622/* Column label --- allowed labels in "AS" clauses.
1261612623 * This presently includes *all* Postgres keywords.
1261712624 */
0 commit comments