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

Commit17a22a7

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 parent47ebaba commit17a22a7

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
@@ -425,9 +425,10 @@ static void processCASbits(int cas_bits, int location, const char *constrType,
425425

426426
%type<ival>IconstSignedIconst
427427
%type<str>Sconstcomment_textnotify_payload
428-
%type<str>RoleIdopt_granted_byopt_boolean_or_stringColId_or_Sconst
428+
%type<str>RoleIdopt_granted_byopt_boolean_or_string
429429
%type<list>var_list
430430
%type<str>ColIdColLabelvar_nametype_function_nameparam_name
431+
%type<str>NonReservedWordNonReservedWord_or_Sconst
431432
%type<node>var_valuezone_value
432433

433434
%type<keyword>unreserved_keywordtype_func_name_keyword
@@ -1324,15 +1325,15 @@ set_rest_more:/* Generic SET syntaxes: */
13241325
n->kind = VAR_SET_DEFAULT;
13251326
$$ = n;
13261327
}
1327-
|ROLEColId_or_Sconst
1328+
|ROLENonReservedWord_or_Sconst
13281329
{
13291330
VariableSetStmt *n = makeNode(VariableSetStmt);
13301331
n->kind = VAR_SET_VALUE;
13311332
n->name ="role";
13321333
n->args = list_make1(makeStringConst($2,@2));
13331334
$$ = n;
13341335
}
1335-
|SESSIONAUTHORIZATIONColId_or_Sconst
1336+
|SESSIONAUTHORIZATIONNonReservedWord_or_Sconst
13361337
{
13371338
VariableSetStmt *n = makeNode(VariableSetStmt);
13381339
n->kind = VAR_SET_VALUE;
@@ -1395,11 +1396,11 @@ opt_boolean_or_string:
13951396
|FALSE_P{$$ ="false"; }
13961397
|ON{$$ ="on"; }
13971398
/*
1398-
* OFF is also accepted as a boolean value, but is handled
1399-
*bytheColId rule below. The action for booleans and strings
1399+
* OFF is also accepted as a boolean value, but is handled by
1400+
* theNonReservedWord rule. The action for booleans and strings
14001401
* is the same, so we don't need to distinguish them here.
14011402
*/
1402-
|ColId_or_Sconst{$$ =$1; }
1403+
|NonReservedWord_or_Sconst{$$ =$1; }
14031404
;
14041405

14051406
/* Timezone values can be:
@@ -1468,8 +1469,8 @@ opt_encoding:
14681469
|/*EMPTY*/{$$ =NULL; }
14691470
;
14701471

1471-
ColId_or_Sconst:
1472-
ColId{$$ =$1; }
1472+
NonReservedWord_or_Sconst:
1473+
NonReservedWord{$$ =$1; }
14731474
|Sconst{$$ =$1; }
14741475
;
14751476

@@ -3234,7 +3235,7 @@ NumericOnly_list:NumericOnly{ $$ = list_make1($1); }
32343235
*****************************************************************************/
32353236

32363237
CreatePLangStmt:
3237-
CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGEColId_or_Sconst
3238+
CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGENonReservedWord_or_Sconst
32383239
{
32393240
CreatePLangStmt *n = makeNode(CreatePLangStmt);
32403241
n->replace =$2;
@@ -3246,7 +3247,7 @@ CreatePLangStmt:
32463247
n->pltrusted =false;
32473248
$$ = (Node *)n;
32483249
}
3249-
|CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGEColId_or_Sconst
3250+
|CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGENonReservedWord_or_Sconst
32503251
HANDLERhandler_nameopt_inline_handleropt_validator
32513252
{
32523253
CreatePLangStmt *n = makeNode(CreatePLangStmt);
@@ -3290,7 +3291,7 @@ opt_validator:
32903291
;
32913292

32923293
DropPLangStmt:
3293-
DROPopt_proceduralLANGUAGEColId_or_Sconstopt_drop_behavior
3294+
DROPopt_proceduralLANGUAGENonReservedWord_or_Sconstopt_drop_behavior
32943295
{
32953296
DropStmt *n = makeNode(DropStmt);
32963297
n->removeType = OBJECT_LANGUAGE;
@@ -3301,7 +3302,7 @@ DropPLangStmt:
33013302
n->concurrent =false;
33023303
$$ = (Node *)n;
33033304
}
3304-
|DROPopt_proceduralLANGUAGEIF_PEXISTSColId_or_Sconstopt_drop_behavior
3305+
|DROPopt_proceduralLANGUAGEIF_PEXISTSNonReservedWord_or_Sconstopt_drop_behavior
33053306
{
33063307
DropStmt *n = makeNode(DropStmt);
33073308
n->removeType = OBJECT_LANGUAGE;
@@ -3403,11 +3404,11 @@ create_extension_opt_item:
34033404
{
34043405
$$ = makeDefElem("schema", (Node *)makeString($2));
34053406
}
3406-
|VERSION_PColId_or_Sconst
3407+
|VERSION_PNonReservedWord_or_Sconst
34073408
{
34083409
$$ = makeDefElem("new_version", (Node *)makeString($2));
34093410
}
3410-
|FROMColId_or_Sconst
3411+
|FROMNonReservedWord_or_Sconst
34113412
{
34123413
$$ = makeDefElem("old_version", (Node *)makeString($2));
34133414
}
@@ -3436,7 +3437,7 @@ alter_extension_opt_list:
34363437
;
34373438

34383439
alter_extension_opt_item:
3439-
TOColId_or_Sconst
3440+
TONonReservedWord_or_Sconst
34403441
{
34413442
$$ = makeDefElem("new_version", (Node *)makeString($2));
34423443
}
@@ -5189,8 +5190,8 @@ SecLabelStmt:
51895190
}
51905191
;
51915192

5192-
opt_provider:FORColId_or_Sconst{$$ =$2; }
5193-
|/* empty*/{$$ =NULL; }
5193+
opt_provider:FORNonReservedWord_or_Sconst{$$ =$2; }
5194+
|/* empty*/{$$ =NULL; }
51945195
;
51955196

51965197
security_label_type:
@@ -6214,7 +6215,7 @@ createfunc_opt_item:
62146215
{
62156216
$$ = makeDefElem("as", (Node *)$2);
62166217
}
6217-
|LANGUAGEColId_or_Sconst
6218+
|LANGUAGENonReservedWord_or_Sconst
62186219
{
62196220
$$ = makeDefElem("language", (Node *)makeString($2));
62206221
}
@@ -6429,7 +6430,7 @@ dostmt_opt_item:
64296430
{
64306431
$$ = makeDefElem("as", (Node *)makeString($1));
64316432
}
6432-
|LANGUAGEColId_or_Sconst
6433+
|LANGUAGENonReservedWord_or_Sconst
64336434
{
64346435
$$ = makeDefElem("language", (Node *)makeString($2));
64356436
}
@@ -8314,9 +8315,7 @@ explain_option_elem:
83148315
;
83158316

83168317
explain_option_name:
8317-
ColId{$$ =$1; }
8318-
|analyze_keyword{$$ ="analyze"; }
8319-
|VERBOSE{$$ ="verbose"; }
8318+
NonReservedWord{$$ =$1; }
83208319
;
83218320

83228321
explain_option_arg:
@@ -12197,7 +12196,7 @@ AexprConst: Iconst
1219712196

1219812197
Iconst:ICONST{ $$ = $1; };
1219912198
Sconst:SCONST{ $$ = $1; };
12200-
RoleId:ColId{ $$ = $1; };
12199+
RoleId:NonReservedWord{ $$ = $1; };
1220112200

1220212201
SignedIconst: Iconst{ $$ = $1; }
1220312202
|'+' Iconst{ $$ = + $2; }
@@ -12229,6 +12228,14 @@ type_function_name:IDENT{ $$ = $1; }
1222912228
| type_func_name_keyword{ $$ =pstrdup($1); }
1223012229
;
1223112230

12231+
/* Any not-fully-reserved word --- these names can be, eg, role names.
12232+
*/
12233+
NonReservedWord:IDENT{ $$ = $1; }
12234+
| unreserved_keyword{ $$ =pstrdup($1); }
12235+
| col_name_keyword{ $$ =pstrdup($1); }
12236+
| type_func_name_keyword{ $$ =pstrdup($1); }
12237+
;
12238+
1223212239
/* Column label --- allowed labels in "AS" clauses.
1223312240
* This presently includes *all* Postgres keywords.
1223412241
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp