Skip to content

Commit

Permalink
sql_yacc_ora.yy: mering MDEV-13384 "window" seems like a reserved col…
Browse files Browse the repository at this point in the history
…umn name but it's not listed as one

Merging MDEV-13384 changes from sql_yacc.yy to sql_yacc_ora.yy
  • Loading branch information
abarkov committed May 18, 2018
1 parent 023c789 commit fdcc951
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 9 deletions.
16 changes: 16 additions & 0 deletions mysql-test/suite/compat/oracle/r/win.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# 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;
20 changes: 20 additions & 0 deletions mysql-test/suite/compat/oracle/t/win.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--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;
6 changes: 2 additions & 4 deletions sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token <kwd> PACKAGE_SYM /* Oracle-R */
%token <kwd> RAISE_SYM /* Oracle-PLSQL-R */
%token <kwd> ROWTYPE_SYM /* Oracle-PLSQL-R */
%token <kwd> WINDOW_SYM

/*
Non-reserved keywords
Expand Down Expand Up @@ -1640,6 +1639,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token <kwd> WARNINGS
%token <kwd> WEEK_SYM
%token <kwd> WEIGHT_STRING_SYM
%token <kwd> WINDOW_SYM /* SQL-2003-R */
%token <kwd> WITHIN
%token <kwd> WITHOUT /* SQL-2003-R */
%token <kwd> WORK_SYM /* SQL-2003-N */
Expand Down Expand Up @@ -15318,10 +15318,8 @@ ident_table_alias:
IDENT_sys
| keyword_alias
{
$$.str= thd->strmake($1.str, $1.length);
if (unlikely($$.str == NULL))
if (unlikely($$.copy_keyword(thd, &$1)))
MYSQL_YYABORT;
$$.length= $1.length;
}
;

Expand Down
24 changes: 19 additions & 5 deletions sql/sql_yacc_ora.yy
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token PACKAGE_SYM /* Oracle-R */
%token RAISE_SYM /* Oracle-PLSQL-R */
%token ROWTYPE_SYM /* Oracle-PLSQL-R */
%token WINDOW_SYM

/*
Non-reserved keywords
Expand Down Expand Up @@ -1026,6 +1025,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token <kwd> WARNINGS
%token <kwd> WEEK_SYM
%token <kwd> WEIGHT_STRING_SYM
%token <kwd> WINDOW_SYM /* SQL-2003-R */
%token <kwd> WITHIN
%token <kwd> WITHOUT /* SQL-2003-R */
%token <kwd> WORK_SYM /* SQL-2003-N */
Expand Down Expand Up @@ -1101,8 +1101,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
IDENT_sys
ident
label_ident
ident_or_empty
sp_decl_ident
ident_or_empty
ident_table_alias
ident_directly_assignable

%type <lex_string_with_metadata>
Expand All @@ -1120,6 +1121,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);

%type <kwd>
keyword keyword_sp
keyword_alias
keyword_directly_assignable
keyword_directly_not_assignable
keyword_sp_data_type
Expand Down Expand Up @@ -12019,7 +12021,7 @@ table_alias:

opt_table_alias:
/* empty */ { $$=0; }
| table_alias ident
| table_alias ident_table_alias
{
$$= (LEX_CSTRING*) thd->memdup(&$2,sizeof(LEX_STRING));
if (unlikely($$ == NULL))
Expand Down Expand Up @@ -14997,6 +14999,15 @@ TEXT_STRING_filesystem:
}
;

ident_table_alias:
IDENT_sys
| keyword_alias
{
if (unlikely($$.copy_keyword(thd, &$1)))
MYSQL_YYABORT;
}
;

ident:
IDENT_sys
| keyword
Expand Down Expand Up @@ -15114,14 +15125,17 @@ 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
| keyword_directly_assignable
| keyword_directly_not_assignable
;


/* Keyword that we allow for identifiers (except SP labels) */
keyword: keyword_alias | WINDOW_SYM;

/*
Keywords that we allow in Oracle-style direct assignments:
xxx := 10;
Expand Down

0 comments on commit fdcc951

Please sign in to comment.