Skip to content

Commit 1d96b09

Browse files
author
Alexander Barkov
committed
MDEV-9979 Keywords UNBOUNDED, PRECEDING, FOLLOWING, TIES, OTHERS should be non-reserved
Adding keywords the following keywords into the "keyword" rules: - EXCLUDE - UNBOUNDED - PRECEDING - FOLLOWING - TIES - OTHERS They are non-reserved words in the SQL standard (checked in a SQL-2011 draft), and they don't cause any conflicts in sql_yacc.yy.
1 parent 642077e commit 1d96b09

File tree

3 files changed

+104
-6
lines changed

3 files changed

+104
-6
lines changed

mysql-test/r/keywords.result

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,57 @@ ERROR HY000: Unknown system variable 'option'
276276
set option option=1;
277277
ERROR HY000: Unknown system variable 'option'
278278
#
279+
# MDEV-9979 Keywords UNBOUNDED, PRECEDING, FOLLOWING, TIES, OTHERS should be non-reserved
280+
#
281+
CREATE TABLE EXCLUDE (EXCLUDE INT);
282+
SELECT EXCLUDE FROM EXCLUDE;
283+
EXCLUDE
284+
SELECT EXCLUDE EXCLUDE FROM EXCLUDE;
285+
EXCLUDE
286+
SELECT EXCLUDE AS EXCLUDE FROM EXCLUDE;
287+
EXCLUDE
288+
DROP TABLE EXCLUDE;
289+
CREATE TABLE UNBOUNDED (UNBOUNDED INT);
290+
SELECT UNBOUNDED FROM UNBOUNDED;
291+
UNBOUNDED
292+
SELECT UNBOUNDED UNBOUNDEX FROM UNBOUNDED;
293+
UNBOUNDEX
294+
SELECT UNBOUNDED AS UNBOUNDEX FROM UNBOUNDED;
295+
UNBOUNDEX
296+
DROP TABLE UNBOUNDED;
297+
CREATE TABLE PRECEDING (PRECEDING INT);
298+
SELECT PRECEDING FROM PRECEDING;
299+
PRECEDING
300+
SELECT PRECEDING PRECEDING FROM PRECEDING;
301+
PRECEDING
302+
SELECT PRECEDING AS PRECEDING FROM PRECEDING;
303+
PRECEDING
304+
DROP TABLE PRECEDING;
305+
CREATE TABLE FOLLOWING (FOLLOWING INT);
306+
SELECT FOLLOWING FROM FOLLOWING;
307+
FOLLOWING
308+
SELECT FOLLOWING FOLLOWING FROM FOLLOWING;
309+
FOLLOWING
310+
SELECT FOLLOWING AS FOLLOWING FROM FOLLOWING;
311+
FOLLOWING
312+
DROP TABLE FOLLOWING;
313+
CREATE TABLE TIES (TIES INT);
314+
SELECT TIES FROM TIES;
315+
TIES
316+
SELECT TIES TIES FROM TIES;
317+
TIES
318+
SELECT TIES AS TIES FROM TIES;
319+
TIES
320+
DROP TABLE TIES;
321+
CREATE TABLE OTHERS (OTHERS INT);
322+
SELECT OTHERS FROM OTHERS;
323+
OTHERS
324+
SELECT OTHERS OTHERS FROM OTHERS;
325+
OTHERS
326+
SELECT OTHERS AS OTHERS FROM OTHERS;
327+
OTHERS
328+
DROP TABLE OTHERS;
329+
#
279330
# MDEV-10585 EXECUTE IMMEDIATE statement
280331
#
281332
CREATE TABLE immediate (immediate int);

mysql-test/t/keywords.test

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,46 @@ set option=1;
174174
--error 1193
175175
set option option=1;
176176

177+
--echo #
178+
--echo # MDEV-9979 Keywords UNBOUNDED, PRECEDING, FOLLOWING, TIES, OTHERS should be non-reserved
179+
--echo #
180+
CREATE TABLE EXCLUDE (EXCLUDE INT);
181+
SELECT EXCLUDE FROM EXCLUDE;
182+
SELECT EXCLUDE EXCLUDE FROM EXCLUDE;
183+
SELECT EXCLUDE AS EXCLUDE FROM EXCLUDE;
184+
DROP TABLE EXCLUDE;
185+
186+
CREATE TABLE UNBOUNDED (UNBOUNDED INT);
187+
SELECT UNBOUNDED FROM UNBOUNDED;
188+
SELECT UNBOUNDED UNBOUNDEX FROM UNBOUNDED;
189+
SELECT UNBOUNDED AS UNBOUNDEX FROM UNBOUNDED;
190+
DROP TABLE UNBOUNDED;
191+
192+
CREATE TABLE PRECEDING (PRECEDING INT);
193+
SELECT PRECEDING FROM PRECEDING;
194+
SELECT PRECEDING PRECEDING FROM PRECEDING;
195+
SELECT PRECEDING AS PRECEDING FROM PRECEDING;
196+
DROP TABLE PRECEDING;
197+
198+
CREATE TABLE FOLLOWING (FOLLOWING INT);
199+
SELECT FOLLOWING FROM FOLLOWING;
200+
SELECT FOLLOWING FOLLOWING FROM FOLLOWING;
201+
SELECT FOLLOWING AS FOLLOWING FROM FOLLOWING;
202+
DROP TABLE FOLLOWING;
203+
204+
CREATE TABLE TIES (TIES INT);
205+
SELECT TIES FROM TIES;
206+
SELECT TIES TIES FROM TIES;
207+
SELECT TIES AS TIES FROM TIES;
208+
DROP TABLE TIES;
209+
210+
CREATE TABLE OTHERS (OTHERS INT);
211+
SELECT OTHERS FROM OTHERS;
212+
SELECT OTHERS OTHERS FROM OTHERS;
213+
SELECT OTHERS AS OTHERS FROM OTHERS;
214+
DROP TABLE OTHERS;
215+
216+
177217
--echo #
178218
--echo # MDEV-10585 EXECUTE IMMEDIATE statement
179219
--echo #

sql/sql_yacc.yy

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
10301030
Comments for TOKENS.
10311031
For each token, please include in the same line a comment that contains
10321032
the following tags:
1033+
SQL-2011-N : Non Reserved keywird as per SQL-2011
10331034
SQL-2003-R : Reserved keyword as per SQL-2003
10341035
SQL-2003-N : Non Reserved keyword as per SQL-2003
10351036
SQL-1999-R : Reserved keyword as per SQL-1999
@@ -1219,7 +1220,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
12191220
%token EVERY_SYM /* SQL-2003-N */
12201221
%token EXCHANGE_SYM
12211222
%token EXAMINED_SYM
1222-
%token EXCLUDE_SYM
1223+
%token EXCLUDE_SYM /* SQL-2011-N */
12231224
%token EXECUTE_SYM /* SQL-2003-R */
12241225
%token EXISTS /* SQL-2003-R */
12251226
%token EXIT_SYM
@@ -1240,7 +1241,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
12401241
%token FLOAT_SYM /* SQL-2003-R */
12411242
%token FLUSH_SYM
12421243
%token FOLLOWS_SYM /* MYSQL trigger*/
1243-
%token FOLLOWING_SYM
1244+
%token FOLLOWING_SYM /* SQL-2011-N */
12441245
%token FORCE_SYM
12451246
%token FOREIGN /* SQL-2003-R */
12461247
%token FOR_SYM /* SQL-2003-R */
@@ -1442,7 +1443,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
14421443
%token ORDER_SYM /* SQL-2003-R */
14431444
%token OR_OR_SYM /* OPERATOR */
14441445
%token OR_SYM /* SQL-2003-R */
1445-
%token OTHERS_SYM
1446+
%token OTHERS_SYM /* SQL-2011-N */
14461447
%token OUTER
14471448
%token OUTFILE
14481449
%token OUT_SYM /* SQL-2003-R */
@@ -1469,7 +1470,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
14691470
%token PORT_SYM
14701471
%token POSITION_SYM /* SQL-2003-N */
14711472
%token PRECEDES_SYM /* MYSQL */
1472-
%token PRECEDING_SYM
1473+
%token PRECEDING_SYM /* SQL-2011-N */
14731474
%token PRECISION /* SQL-2003-R */
14741475
%token PREPARE_SYM /* SQL-2003-R */
14751476
%token PRESERVE_SYM
@@ -1630,7 +1631,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
16301631
%token TEXT_SYM
16311632
%token THAN_SYM
16321633
%token THEN_SYM /* SQL-2003-R */
1633-
%token TIES_SYM
1634+
%token TIES_SYM /* SQL-2011-N */
16341635
%token TIMESTAMP /* SQL-2003-R */
16351636
%token TIMESTAMP_ADD
16361637
%token TIMESTAMP_DIFF
@@ -1651,7 +1652,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
16511652
%token TYPE_SYM /* SQL-2003-N */
16521653
%token UDF_RETURNS_SYM
16531654
%token ULONGLONG_NUM
1654-
%token UNBOUNDED_SYM
1655+
%token UNBOUNDED_SYM /* SQL-2011-N */
16551656
%token UNCOMMITTED_SYM /* SQL-2003-N */
16561657
%token UNDEFINED_SYM
16571658
%token UNDERSCORE_CHARSET
@@ -14539,9 +14540,11 @@ keyword:
1453914540
| DO_SYM {}
1454014541
| END {}
1454114542
| EXAMINED_SYM {}
14543+
| EXCLUDE_SYM {}
1454214544
| EXECUTE_SYM {}
1454314545
| FLUSH_SYM {}
1454414546
| FOLLOWS_SYM {}
14547+
| FOLLOWING_SYM {}
1454514548
| FORMAT_SYM {}
1454614549
| GET_SYM {}
1454714550
| HANDLER_SYM {}
@@ -14553,10 +14556,12 @@ keyword:
1455314556
| OPEN_SYM {}
1455414557
| OPTION {}
1455514558
| OPTIONS_SYM {}
14559+
| OTHERS_SYM {}
1455614560
| OWNER_SYM {}
1455714561
| PARSER_SYM {}
1455814562
| PORT_SYM {}
1455914563
| PRECEDES_SYM {}
14564+
| PRECEDING_SYM {}
1456014565
| PREPARE_SYM {}
1456114566
| REMOVE_SYM {}
1456214567
| REPAIR {}
@@ -14575,9 +14580,11 @@ keyword:
1457514580
| START_SYM {}
1457614581
| STOP_SYM {}
1457714582
| STORED_SYM {}
14583+
| TIES_SYM {}
1457814584
| TRUNCATE_SYM {}
1457914585
| UNICODE_SYM {}
1458014586
| UNINSTALL_SYM {}
14587+
| UNBOUNDED_SYM {}
1458114588
| WRAPPER_SYM {}
1458214589
| XA_SYM {}
1458314590
| UPGRADE_SYM {}

0 commit comments

Comments
 (0)