Commit 5c84fe46 authored by Heikki Linnakangas's avatar Heikki Linnakangas

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 of
the SQL spec either. This became particularly annoying in 9.0, before that
PL/pgSQL replaced variable names in queries with parameter markers, so
it was possible to use OFF and many other backend parser keywords as
variable names. Because of that, backpatch to 9.0.
parent 71be8db5
...@@ -402,7 +402,7 @@ static RangeVar *makeRangeVarFromAnyName(List *names, int position, core_yyscan_ ...@@ -402,7 +402,7 @@ static RangeVar *makeRangeVarFromAnyName(List *names, int position, core_yyscan_
%type <ival> Iconst SignedIconst %type <ival> Iconst SignedIconst
%type <str> Sconst comment_text notify_payload %type <str> Sconst comment_text notify_payload
%type <str> RoleId opt_granted_by opt_boolean ColId_or_Sconst %type <str> RoleId opt_granted_by opt_boolean_or_string ColId_or_Sconst
%type <list> var_list %type <list> var_list
%type <str> ColId ColLabel var_name type_function_name param_name %type <str> ColId ColLabel var_name type_function_name param_name
%type <node> var_value zone_value %type <node> var_value zone_value
...@@ -1326,9 +1326,7 @@ var_list: var_value { $$ = list_make1($1); } ...@@ -1326,9 +1326,7 @@ var_list: var_value { $$ = list_make1($1); }
| var_list ',' var_value { $$ = lappend($1, $3); } | var_list ',' var_value { $$ = lappend($1, $3); }
; ;
var_value: opt_boolean var_value: opt_boolean_or_string
{ $$ = makeStringConst($1, @1); }
| ColId_or_Sconst
{ $$ = makeStringConst($1, @1); } { $$ = makeStringConst($1, @1); }
| NumericOnly | NumericOnly
{ $$ = makeAConst($1, @1); } { $$ = makeAConst($1, @1); }
...@@ -1340,11 +1338,16 @@ iso_level: READ UNCOMMITTED { $$ = "read uncommitted"; } ...@@ -1340,11 +1338,16 @@ iso_level: READ UNCOMMITTED { $$ = "read uncommitted"; }
| SERIALIZABLE { $$ = "serializable"; } | SERIALIZABLE { $$ = "serializable"; }
; ;
opt_boolean: opt_boolean_or_string:
TRUE_P { $$ = "true"; } TRUE_P { $$ = "true"; }
| FALSE_P { $$ = "false"; } | FALSE_P { $$ = "false"; }
| ON { $$ = "on"; } | ON { $$ = "on"; }
| OFF { $$ = "off"; } /*
* OFF is also accepted as a boolean value, but is handled
* by the ColId rule below. The action for booleans and strings
* is the same, so we don't need to distinguish them here.
*/
| ColId_or_Sconst { $$ = $1 }
; ;
/* Timezone values can be: /* Timezone values can be:
...@@ -2239,8 +2242,7 @@ copy_generic_opt_elem: ...@@ -2239,8 +2242,7 @@ copy_generic_opt_elem:
; ;
copy_generic_opt_arg: copy_generic_opt_arg:
opt_boolean { $$ = (Node *) makeString($1); } opt_boolean_or_string { $$ = (Node *) makeString($1); }
| ColId_or_Sconst { $$ = (Node *) makeString($1); }
| NumericOnly { $$ = (Node *) $1; } | NumericOnly { $$ = (Node *) $1; }
| '*' { $$ = (Node *) makeNode(A_Star); } | '*' { $$ = (Node *) makeNode(A_Star); }
| '(' copy_generic_opt_arg_list ')' { $$ = (Node *) $2; } | '(' copy_generic_opt_arg_list ')' { $$ = (Node *) $2; }
...@@ -2260,8 +2262,7 @@ copy_generic_opt_arg_list: ...@@ -2260,8 +2262,7 @@ copy_generic_opt_arg_list:
/* beware of emitting non-string list elements here; see commands/define.c */ /* beware of emitting non-string list elements here; see commands/define.c */
copy_generic_opt_arg_list_item: copy_generic_opt_arg_list_item:
opt_boolean { $$ = (Node *) makeString($1); } opt_boolean_or_string { $$ = (Node *) makeString($1); }
| ColId_or_Sconst { $$ = (Node *) makeString($1); }
; ;
...@@ -7158,8 +7159,7 @@ explain_option_name: ...@@ -7158,8 +7159,7 @@ explain_option_name:
; ;
explain_option_arg: explain_option_arg:
opt_boolean { $$ = (Node *) makeString($1); } opt_boolean_or_string { $$ = (Node *) makeString($1); }
| ColId_or_Sconst { $$ = (Node *) makeString($1); }
| NumericOnly { $$ = (Node *) $1; } | NumericOnly { $$ = (Node *) $1; }
| /* EMPTY */ { $$ = NULL; } | /* EMPTY */ { $$ = NULL; }
; ;
...@@ -11184,6 +11184,7 @@ unreserved_keyword: ...@@ -11184,6 +11184,7 @@ unreserved_keyword:
| NULLS_P | NULLS_P
| OBJECT_P | OBJECT_P
| OF | OF
| OFF
| OIDS | OIDS
| OPERATOR | OPERATOR
| OPTION | OPTION
...@@ -11443,7 +11444,6 @@ reserved_keyword: ...@@ -11443,7 +11444,6 @@ reserved_keyword:
| LOCALTIMESTAMP | LOCALTIMESTAMP
| NOT | NOT
| NULL_P | NULL_P
| OFF
| OFFSET | OFFSET
| ON | ON
| ONLY | ONLY
......
...@@ -262,7 +262,7 @@ PG_KEYWORD("nulls", NULLS_P, UNRESERVED_KEYWORD) ...@@ -262,7 +262,7 @@ PG_KEYWORD("nulls", NULLS_P, UNRESERVED_KEYWORD)
PG_KEYWORD("numeric", NUMERIC, COL_NAME_KEYWORD) PG_KEYWORD("numeric", NUMERIC, COL_NAME_KEYWORD)
PG_KEYWORD("object", OBJECT_P, UNRESERVED_KEYWORD) PG_KEYWORD("object", OBJECT_P, UNRESERVED_KEYWORD)
PG_KEYWORD("of", OF, UNRESERVED_KEYWORD) PG_KEYWORD("of", OF, UNRESERVED_KEYWORD)
PG_KEYWORD("off", OFF, RESERVED_KEYWORD) PG_KEYWORD("off", OFF, UNRESERVED_KEYWORD)
PG_KEYWORD("offset", OFFSET, RESERVED_KEYWORD) PG_KEYWORD("offset", OFFSET, RESERVED_KEYWORD)
PG_KEYWORD("oids", OIDS, UNRESERVED_KEYWORD) PG_KEYWORD("oids", OIDS, UNRESERVED_KEYWORD)
PG_KEYWORD("on", ON, RESERVED_KEYWORD) PG_KEYWORD("on", ON, RESERVED_KEYWORD)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment