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

Commit805730d

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 parent1b192fc commit805730d

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

‎src/backend/parser/gram.y‎

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,10 @@ static TypeName *TableFuncTypeName(List *columns);
401401

402402
%type<ival>IconstSignedIconst
403403
%type<str>Sconstcomment_textnotify_payload
404-
%type<str>RoleIdopt_granted_byopt_boolean_or_stringColId_or_Sconst
404+
%type<str>RoleIdopt_granted_byopt_boolean_or_string
405405
%type<list>var_list
406406
%type<str>ColIdColLabelvar_nametype_function_nameparam_name
407+
%type<str>NonReservedWordNonReservedWord_or_Sconst
407408
%type<node>var_valuezone_value
408409

409410
%type<keyword>unreserved_keywordtype_func_name_keyword
@@ -1275,15 +1276,15 @@ set_rest:/* Generic SET syntaxes: */
12751276
n->kind = VAR_SET_DEFAULT;
12761277
$$ = n;
12771278
}
1278-
|ROLEColId_or_Sconst
1279+
|ROLENonReservedWord_or_Sconst
12791280
{
12801281
VariableSetStmt *n = makeNode(VariableSetStmt);
12811282
n->kind = VAR_SET_VALUE;
12821283
n->name ="role";
12831284
n->args = list_make1(makeStringConst($2,@2));
12841285
$$ = n;
12851286
}
1286-
|SESSIONAUTHORIZATIONColId_or_Sconst
1287+
|SESSIONAUTHORIZATIONNonReservedWord_or_Sconst
12871288
{
12881289
VariableSetStmt *n = makeNode(VariableSetStmt);
12891290
n->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-
*bytheColId 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

28962897
CreatePLangStmt:
2897-
CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGEColId_or_Sconst
2898+
CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGENonReservedWord_or_Sconst
28982899
{
28992900
CreatePLangStmt *n = makeNode(CreatePLangStmt);
29002901
n->replace =$2;
@@ -2906,7 +2907,7 @@ CreatePLangStmt:
29062907
n->pltrusted =false;
29072908
$$ = (Node *)n;
29082909
}
2909-
|CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGEColId_or_Sconst
2910+
|CREATEopt_or_replaceopt_trustedopt_proceduralLANGUAGENonReservedWord_or_Sconst
29102911
HANDLERhandler_nameopt_inline_handleropt_validator
29112912
{
29122913
CreatePLangStmt *n = makeNode(CreatePLangStmt);
@@ -2950,15 +2951,15 @@ opt_validator:
29502951
;
29512952

29522953
DropPLangStmt:
2953-
DROPopt_proceduralLANGUAGEColId_or_Sconstopt_drop_behavior
2954+
DROPopt_proceduralLANGUAGENonReservedWord_or_Sconstopt_drop_behavior
29542955
{
29552956
DropPLangStmt *n = makeNode(DropPLangStmt);
29562957
n->plname =$4;
29572958
n->behavior =$5;
29582959
n->missing_ok =false;
29592960
$$ = (Node *)n;
29602961
}
2961-
|DROPopt_proceduralLANGUAGEIF_PEXISTSColId_or_Sconstopt_drop_behavior
2962+
|DROPopt_proceduralLANGUAGEIF_PEXISTSNonReservedWord_or_Sconstopt_drop_behavior
29622963
{
29632964
DropPLangStmt *n = makeNode(DropPLangStmt);
29642965
n->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

69806981
explain_option_name:
6981-
ColId{$$ =$1; }
6982-
| analyze_keyword{$$ ="analyze"; }
6983-
| VERBOSE{$$ ="verbose"; }
6982+
NonReservedWord{$$ =$1; }
69846983
;
69856984

69866985
explain_option_arg:
@@ -10776,7 +10775,7 @@ AexprConst: Iconst
1077610775

1077710776
Iconst:ICONST{ $$ = $1; };
1077810777
Sconst:SCONST{ $$ = $1; };
10779-
RoleId:ColId{ $$ = $1; };
10778+
RoleId:NonReservedWord{ $$ = $1; };
1078010779

1078110780
SignedIconst: 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
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp