@@ -450,9 +450,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
450
450
451
451
%type <ival> Iconst SignedIconst
452
452
%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
454
454
%type <list> var_list
455
455
%type <str> ColId ColLabel var_name type_function_name param_name
456
+ %type <str> NonReservedWord NonReservedWord_or_Sconst
456
457
%type <node> var_value zone_value
457
458
458
459
%type <keyword> unreserved_keyword type_func_name_keyword
@@ -1402,15 +1403,15 @@ set_rest_more: /* Generic SET syntaxes: */
1402
1403
n->kind = VAR_SET_DEFAULT;
1403
1404
$$ = n;
1404
1405
}
1405
- | ROLE ColId_or_Sconst
1406
+ | ROLE NonReservedWord_or_Sconst
1406
1407
{
1407
1408
VariableSetStmt *n = makeNode(VariableSetStmt);
1408
1409
n->kind = VAR_SET_VALUE;
1409
1410
n->name = " role" ;
1410
1411
n->args = list_make1(makeStringConst($2 , @2 ));
1411
1412
$$ = n;
1412
1413
}
1413
- | SESSION AUTHORIZATION ColId_or_Sconst
1414
+ | SESSION AUTHORIZATION NonReservedWord_or_Sconst
1414
1415
{
1415
1416
VariableSetStmt *n = makeNode(VariableSetStmt);
1416
1417
n->kind = VAR_SET_VALUE;
@@ -1473,11 +1474,11 @@ opt_boolean_or_string:
1473
1474
| FALSE_P { $$ = " false" ; }
1474
1475
| ON { $$ = " on" ; }
1475
1476
/*
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
1478
1479
* is the same, so we don't need to distinguish them here.
1479
1480
*/
1480
- | ColId_or_Sconst { $$ = $1 ; }
1481
+ | NonReservedWord_or_Sconst { $$ = $1 ; }
1481
1482
;
1482
1483
1483
1484
/* Timezone values can be:
@@ -1546,8 +1547,8 @@ opt_encoding:
1546
1547
| /* EMPTY*/ { $$ = NULL ; }
1547
1548
;
1548
1549
1549
- ColId_or_Sconst :
1550
- ColId { $$ = $1 ; }
1550
+ NonReservedWord_or_Sconst :
1551
+ NonReservedWord { $$ = $1 ; }
1551
1552
| Sconst { $$ = $1 ; }
1552
1553
;
1553
1554
@@ -3418,7 +3419,7 @@ NumericOnly_list: NumericOnly { $$ = list_make1($1); }
3418
3419
*****************************************************************************/
3419
3420
3420
3421
CreatePLangStmt :
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
3422
3423
{
3423
3424
CreatePLangStmt *n = makeNode(CreatePLangStmt);
3424
3425
n->replace = $2 ;
@@ -3430,7 +3431,7 @@ CreatePLangStmt:
3430
3431
n->pltrusted = false ;
3431
3432
$$ = (Node *)n;
3432
3433
}
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
3434
3435
HANDLER handler_name opt_inline_handler opt_validator
3435
3436
{
3436
3437
CreatePLangStmt *n = makeNode(CreatePLangStmt);
@@ -3474,7 +3475,7 @@ opt_validator:
3474
3475
;
3475
3476
3476
3477
DropPLangStmt :
3477
- DROP opt_procedural LANGUAGE ColId_or_Sconst opt_drop_behavior
3478
+ DROP opt_procedural LANGUAGE NonReservedWord_or_Sconst opt_drop_behavior
3478
3479
{
3479
3480
DropStmt *n = makeNode(DropStmt);
3480
3481
n->removeType = OBJECT_LANGUAGE;
@@ -3485,7 +3486,7 @@ DropPLangStmt:
3485
3486
n->concurrent = false ;
3486
3487
$$ = (Node *)n;
3487
3488
}
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
3489
3490
{
3490
3491
DropStmt *n = makeNode(DropStmt);
3491
3492
n->removeType = OBJECT_LANGUAGE;
@@ -3587,11 +3588,11 @@ create_extension_opt_item:
3587
3588
{
3588
3589
$$ = makeDefElem(" schema" , (Node *)makeString($2 ));
3589
3590
}
3590
- | VERSION_P ColId_or_Sconst
3591
+ | VERSION_P NonReservedWord_or_Sconst
3591
3592
{
3592
3593
$$ = makeDefElem(" new_version" , (Node *)makeString($2 ));
3593
3594
}
3594
- | FROM ColId_or_Sconst
3595
+ | FROM NonReservedWord_or_Sconst
3595
3596
{
3596
3597
$$ = makeDefElem(" old_version" , (Node *)makeString($2 ));
3597
3598
}
@@ -3620,7 +3621,7 @@ alter_extension_opt_list:
3620
3621
;
3621
3622
3622
3623
alter_extension_opt_item :
3623
- TO ColId_or_Sconst
3624
+ TO NonReservedWord_or_Sconst
3624
3625
{
3625
3626
$$ = makeDefElem(" new_version" , (Node *)makeString($2 ));
3626
3627
}
@@ -5428,8 +5429,8 @@ SecLabelStmt:
5428
5429
}
5429
5430
;
5430
5431
5431
- opt_provider : FOR ColId_or_Sconst { $$ = $2 ; }
5432
- | /* empty */ { $$ = NULL ; }
5432
+ opt_provider : FOR NonReservedWord_or_Sconst { $$ = $2 ; }
5433
+ | /* empty */ { $$ = NULL ; }
5433
5434
;
5434
5435
5435
5436
security_label_type :
@@ -6455,7 +6456,7 @@ createfunc_opt_item:
6455
6456
{
6456
6457
$$ = makeDefElem(" as" , (Node *)$2 );
6457
6458
}
6458
- | LANGUAGE ColId_or_Sconst
6459
+ | LANGUAGE NonReservedWord_or_Sconst
6459
6460
{
6460
6461
$$ = makeDefElem(" language" , (Node *)makeString($2 ));
6461
6462
}
@@ -6670,7 +6671,7 @@ dostmt_opt_item:
6670
6671
{
6671
6672
$$ = makeDefElem(" as" , (Node *)makeString($1 ));
6672
6673
}
6673
- | LANGUAGE ColId_or_Sconst
6674
+ | LANGUAGE NonReservedWord_or_Sconst
6674
6675
{
6675
6676
$$ = makeDefElem(" language" , (Node *)makeString($2 ));
6676
6677
}
@@ -8667,9 +8668,7 @@ explain_option_elem:
8667
8668
;
8668
8669
8669
8670
explain_option_name :
8670
- ColId { $$ = $1 ; }
8671
- | analyze_keyword { $$ = " analyze" ; }
8672
- | VERBOSE { $$ = " verbose" ; }
8671
+ NonReservedWord { $$ = $1 ; }
8673
8672
;
8674
8673
8675
8674
explain_option_arg :
@@ -12580,7 +12579,7 @@ AexprConst: Iconst
12580
12579
12581
12580
Iconst: ICONST { $$ = $1 ; };
12582
12581
Sconst: SCONST { $$ = $1 ; };
12583
- RoleId: ColId { $$ = $1 ; };
12582
+ RoleId: NonReservedWord { $$ = $1 ; };
12584
12583
12585
12584
SignedIconst: Iconst { $$ = $1 ; }
12586
12585
| ' +' Iconst { $$ = + $2 ; }
@@ -12612,6 +12611,14 @@ type_function_name: IDENT { $$ = $1; }
12612
12611
| type_func_name_keyword { $$ = pstrdup ($1 ); }
12613
12612
;
12614
12613
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
+
12615
12622
/* Column label --- allowed labels in "AS" clauses.
12616
12623
* This presently includes *all* Postgres keywords.
12617
12624
*/
0 commit comments