Commit 8cee2f13 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

MDEV-13384: "window" seems like a reserved column name but it's not listed as one

Window is a reserved keyword according to SQL Standard 2016. However, we
can make the grammar slightly flexible by allowing WINDOW keyword everywhere
except table aliases. Change yacc grammar to separate between all keywords
and table_alias keywords.
parent b65fd73b
......@@ -3273,3 +3273,19 @@ row_number() over (partition by i order by i) i
1 1
1 2
DROP TABLE t1;
#
# MDEV-13384: "window" seems like a reserved column name but it's not listed as one
#
# Currently we allow window as an identifier, except for table aliases.
#
CREATE TABLE door (id INT, window VARCHAR(10));
SELECT id
FROM door as window;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'window' at line 2
SELECT id, window
FROM door;
id window
SELECT id, window
FROM door as window;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'window' at line 2
DROP TABLE door;
......@@ -2036,3 +2036,24 @@ PREPARE stmt FROM "SELECT row_number() over (partition by i order by i), i FROM
EXECUTE stmt;
DROP TABLE t1;
--echo #
--echo # MDEV-13384: "window" seems like a reserved column name but it's not listed as one
--echo #
--echo # Currently we allow window as an identifier, except for table aliases.
--echo #
CREATE TABLE door (id INT, window VARCHAR(10));
--error ER_PARSE_ERROR
SELECT id
FROM door as window;
SELECT id, window
FROM door;
--error ER_PARSE_ERROR
SELECT id, window
FROM door as window;
DROP TABLE door;
......@@ -1740,7 +1740,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
NCHAR_STRING opt_component key_cache_name
sp_opt_label BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
opt_constraint constraint opt_ident
opt_constraint constraint opt_ident ident_table_alias
%type <lex_str_ptr>
opt_table_alias
......@@ -1893,7 +1893,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <Lex_length_and_dec> precision opt_precision float_options
%type <symbol> keyword keyword_sp
%type <symbol> keyword keyword_sp keyword_alias
%type <lex_user> user grant_user grant_role user_or_role current_role
admin_option_for_role user_maybe_role
......@@ -11402,7 +11402,7 @@ table_alias:
opt_table_alias:
/* empty */ { $$=0; }
| table_alias ident
| table_alias ident_table_alias
{
$$= (LEX_STRING*) thd->memdup(&$2,sizeof(LEX_STRING));
if ($$ == NULL)
......@@ -14458,6 +14458,16 @@ TEXT_STRING_filesystem:
MYSQL_YYABORT;
}
}
ident_table_alias:
IDENT_sys { $$= $1; }
| keyword_alias
{
$$.str= thd->strmake($1.str, $1.length);
if ($$.str == NULL)
MYSQL_YYABORT;
$$.length= $1.length;
}
;
ident:
......@@ -14552,8 +14562,8 @@ user: user_maybe_role
}
;
/* Keyword that we allow for identifiers (except SP labels) */
keyword:
/* Keywords which we allow as table aliases. */
keyword_alias:
keyword_sp {}
| ASCII_SYM {}
| BACKUP_SYM {}
......@@ -14627,6 +14637,10 @@ keyword:
| UPGRADE_SYM {}
;
/* Keyword that we allow for identifiers (except SP labels) */
keyword: keyword_alias | WINDOW_SYM ;
/*
* Keywords that we allow for labels in SPs.
* Anything that's the beginning of a statement or characteristics
......
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