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

Commit5c84fe4

Browse files
committed
Make OFF keyword unreserved. It's not hard to imagine wanting to use 'off'
as a variable or column name, and it's not reserved in recent versions ofthe SQL spec either. This became particularly annoying in 9.0, before thatPL/pgSQL replaced variable names in queries with parameter markers, soit was possible to use OFF and many other backend parser keywords asvariable names. Because of that, backpatch to 9.0.
1 parent71be8db commit5c84fe4

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

‎src/backend/parser/gram.y

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static RangeVar *makeRangeVarFromAnyName(List *names, int position, core_yyscan_
402402

403403
%type<ival>IconstSignedIconst
404404
%type<str>Sconstcomment_textnotify_payload
405-
%type<str>RoleIdopt_granted_byopt_booleanColId_or_Sconst
405+
%type<str>RoleIdopt_granted_byopt_boolean_or_stringColId_or_Sconst
406406
%type<list>var_list
407407
%type<str>ColIdColLabelvar_nametype_function_nameparam_name
408408
%type<node>var_valuezone_value
@@ -1326,9 +1326,7 @@ var_list:var_value{ $$ = list_make1($1); }
13261326
|var_list','var_value{$$ = lappend($1,$3); }
13271327
;
13281328

1329-
var_value:opt_boolean
1330-
{$$ = makeStringConst($1,@1); }
1331-
|ColId_or_Sconst
1329+
var_value:opt_boolean_or_string
13321330
{$$ = makeStringConst($1,@1); }
13331331
|NumericOnly
13341332
{$$ = makeAConst($1,@1); }
@@ -1340,11 +1338,16 @@ iso_level:READ UNCOMMITTED{ $$ = "read uncommitted"; }
13401338
|SERIALIZABLE{$$ ="serializable"; }
13411339
;
13421340

1343-
opt_boolean:
1341+
opt_boolean_or_string:
13441342
TRUE_P{$$ ="true"; }
13451343
|FALSE_P{$$ ="false"; }
13461344
|ON{$$ ="on"; }
1347-
|OFF{$$ ="off"; }
1345+
/*
1346+
* OFF is also accepted as a boolean value, but is handled
1347+
* by the ColId rule below. The action for booleans and strings
1348+
* is the same, so we don't need to distinguish them here.
1349+
*/
1350+
|ColId_or_Sconst{$$ =$1 }
13481351
;
13491352

13501353
/* Timezone values can be:
@@ -2239,8 +2242,7 @@ copy_generic_opt_elem:
22392242
;
22402243

22412244
copy_generic_opt_arg:
2242-
opt_boolean{$$ = (Node *) makeString($1); }
2243-
|ColId_or_Sconst{$$ = (Node *) makeString($1); }
2245+
opt_boolean_or_string{$$ = (Node *) makeString($1); }
22442246
|NumericOnly{$$ = (Node *)$1; }
22452247
|'*'{$$ = (Node *) makeNode(A_Star); }
22462248
|'('copy_generic_opt_arg_list')'{$$ = (Node *)$2; }
@@ -2260,8 +2262,7 @@ copy_generic_opt_arg_list:
22602262

22612263
/* beware of emitting non-string list elements here; see commands/define.c*/
22622264
copy_generic_opt_arg_list_item:
2263-
opt_boolean{$$ = (Node *) makeString($1); }
2264-
|ColId_or_Sconst{$$ = (Node *) makeString($1); }
2265+
opt_boolean_or_string{$$ = (Node *) makeString($1); }
22652266
;
22662267

22672268

@@ -7158,8 +7159,7 @@ explain_option_name:
71587159
;
71597160

71607161
explain_option_arg:
7161-
opt_boolean{$$ = (Node *) makeString($1); }
7162-
|ColId_or_Sconst{$$ = (Node *) makeString($1); }
7162+
opt_boolean_or_string{$$ = (Node *) makeString($1); }
71637163
|NumericOnly{$$ = (Node *)$1; }
71647164
|/* EMPTY*/{$$ =NULL; }
71657165
;
@@ -11184,6 +11184,7 @@ unreserved_keyword:
1118411184
| NULLS_P
1118511185
| OBJECT_P
1118611186
| OF
11187+
| OFF
1118711188
| OIDS
1118811189
| OPERATOR
1118911190
| OPTION
@@ -11443,7 +11444,6 @@ reserved_keyword:
1144311444
| LOCALTIMESTAMP
1144411445
| NOT
1144511446
| NULL_P
11446-
| OFF
1144711447
| OFFSET
1144811448
| ON
1144911449
| ONLY

‎src/include/parser/kwlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ PG_KEYWORD("nulls", NULLS_P, UNRESERVED_KEYWORD)
262262
PG_KEYWORD("numeric",NUMERIC,COL_NAME_KEYWORD)
263263
PG_KEYWORD("object",OBJECT_P,UNRESERVED_KEYWORD)
264264
PG_KEYWORD("of",OF,UNRESERVED_KEYWORD)
265-
PG_KEYWORD("off",OFF,RESERVED_KEYWORD)
265+
PG_KEYWORD("off",OFF,UNRESERVED_KEYWORD)
266266
PG_KEYWORD("offset",OFFSET,RESERVED_KEYWORD)
267267
PG_KEYWORD("oids",OIDS,UNRESERVED_KEYWORD)
268268
PG_KEYWORD("on",ON,RESERVED_KEYWORD)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp