Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2c92eda

Browse files
committed
Allow type_func_name_keywords in some places where they weren't before.
This change makes type_func_name_keywords less reserved than they werebefore, by allowing them for role names, language names, EXPLAIN and COPYoptions, and SET values for GUCs; which are all places where few if anyactual keywords could appear instead, so no new ambiguities are introduced.The main driver for this change is to allow "COPY ... (FORMAT BINARY)"to work without quoting the word "binary". That is an inconsistency thathas been complained of repeatedly over the years (at least by Pavel Golub,Kurt Lidl, and Simon Riggs); but we hadn't thought of any non-ugly solutionuntil now.Back-patch to 9.0 where the COPY (FORMAT BINARY) syntax was introduced.
1 parent22b3641 commit2c92eda

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

‎src/backend/parser/gram.y

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
450450

451451
%type<ival>IconstSignedIconst
452452
%type<str>Sconstcomment_textnotify_payload
453-
%type<str>RoleIdopt_granted_byopt_boolean_or_stringColId_or_Sconst
453+
%type<str>RoleIdopt_granted_byopt_boolean_or_string
454454
%type<list>var_list
455455
%type<str>ColIdColLabelvar_nametype_function_nameparam_name
456+
%type<str>NonReservedWordNonReservedWord_or_Sconst
456457
%type<node>var_valuezone_value
457458

458459
%type<keyword>unreserved_keywordtype_func_name_keyword
@@ -1402,15 +1403,15 @@ set_rest_more:/* Generic SET syntaxes: */
14021403
n->kind = VAR_SET_DEFAULT;
14031404
$$ = n;
14041405
}
1405-
|ROLEColId_or_Sconst
1406+
|ROLENonReservedWord_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-
|SESSIONAUTHORIZATIONColId_or_Sconst
1414+
|SESSIONAUTHORIZATIONNonReservedWord_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-
*bytheColId rule below. The action for booleans and strings
1477+
* OFF is also accepted as a boolean value, but is handled by
1478+
* theNonReservedWord 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

34203421
CreatePLangStmt:
3421-
CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGEColId_or_Sconst
3422+
CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGENonReservedWord_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-
|CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGEColId_or_Sconst
3434+
|CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGENonReservedWord_or_Sconst
34343435
HANDLERhandler_nameopt_inline_handleropt_validator
34353436
{
34363437
CreatePLangStmt *n = makeNode(CreatePLangStmt);
@@ -3474,7 +3475,7 @@ opt_validator:
34743475
;
34753476

34763477
DropPLangStmt:
3477-
DROPopt_proceduralLANGUAGEColId_or_Sconstopt_drop_behavior
3478+
DROPopt_proceduralLANGUAGENonReservedWord_or_Sconstopt_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-
|DROPopt_proceduralLANGUAGEIF_PEXISTSColId_or_Sconstopt_drop_behavior
3489+
|DROPopt_proceduralLANGUAGEIF_PEXISTSNonReservedWord_or_Sconstopt_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_PColId_or_Sconst
3591+
|VERSION_PNonReservedWord_or_Sconst
35913592
{
35923593
$$ = makeDefElem("new_version", (Node *)makeString($2));
35933594
}
3594-
|FROMColId_or_Sconst
3595+
|FROMNonReservedWord_or_Sconst
35953596
{
35963597
$$ = makeDefElem("old_version", (Node *)makeString($2));
35973598
}
@@ -3620,7 +3621,7 @@ alter_extension_opt_list:
36203621
;
36213622

36223623
alter_extension_opt_item:
3623-
TOColId_or_Sconst
3624+
TONonReservedWord_or_Sconst
36243625
{
36253626
$$ = makeDefElem("new_version", (Node *)makeString($2));
36263627
}
@@ -5428,8 +5429,8 @@ SecLabelStmt:
54285429
}
54295430
;
54305431

5431-
opt_provider:FORColId_or_Sconst{$$ =$2; }
5432-
|/* empty*/{$$ =NULL; }
5432+
opt_provider:FORNonReservedWord_or_Sconst{$$ =$2; }
5433+
|/* empty*/{$$ =NULL; }
54335434
;
54345435

54355436
security_label_type:
@@ -6455,7 +6456,7 @@ createfunc_opt_item:
64556456
{
64566457
$$ = makeDefElem("as", (Node *)$2);
64576458
}
6458-
|LANGUAGEColId_or_Sconst
6459+
|LANGUAGENonReservedWord_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-
|LANGUAGEColId_or_Sconst
6674+
|LANGUAGENonReservedWord_or_Sconst
66746675
{
66756676
$$ = makeDefElem("language", (Node *)makeString($2));
66766677
}
@@ -8667,9 +8668,7 @@ explain_option_elem:
86678668
;
86688669

86698670
explain_option_name:
8670-
ColId{$$ =$1; }
8671-
|analyze_keyword{$$ ="analyze"; }
8672-
|VERBOSE{$$ ="verbose"; }
8671+
NonReservedWord{$$ =$1; }
86738672
;
86748673

86758674
explain_option_arg:
@@ -12580,7 +12579,7 @@ AexprConst: Iconst
1258012579

1258112580
Iconst:ICONST{ $$ = $1; };
1258212581
Sconst:SCONST{ $$ = $1; };
12583-
RoleId:ColId{ $$ = $1; };
12582+
RoleId:NonReservedWord{ $$ = $1; };
1258412583

1258512584
SignedIconst: 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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp