From cd1afe0aac28cec267e9c2e74d7a5f73050e2614 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 15 Nov 2016 15:57:57 +0400 Subject: [PATCH] MDEV-10588 sql_mode=ORACLE: TRUNCATE TABLE t1 [ {DROP|REUSE} STORAGE ] --- mysql-test/r/keywords.result | 2 ++ mysql-test/suite/compat/oracle/r/truncate.result | 10 ++++++++++ mysql-test/suite/compat/oracle/t/truncate.test | 16 ++++++++++++++++ mysql-test/t/keywords.test | 3 +++ sql/lex.h | 1 + sql/sql_yacc.yy | 2 ++ sql/sql_yacc_ora.yy | 9 +++++++++ 7 files changed, 43 insertions(+) create mode 100644 mysql-test/suite/compat/oracle/r/truncate.result create mode 100644 mysql-test/suite/compat/oracle/t/truncate.test diff --git a/mysql-test/r/keywords.result b/mysql-test/r/keywords.result index 6649df3d8a70f..687a122d62808 100644 --- a/mysql-test/r/keywords.result +++ b/mysql-test/r/keywords.result @@ -356,3 +356,5 @@ CREATE TABLE notfound (notfound int); DROP TABLE notfound; CREATE TABLE raise (raise int); DROP TABLE raise; +CREATE TABLE reuse (reuse int); +DROP TABLE reuse; diff --git a/mysql-test/suite/compat/oracle/r/truncate.result b/mysql-test/suite/compat/oracle/r/truncate.result new file mode 100644 index 0000000000000..f04ce09a4f8a1 --- /dev/null +++ b/mysql-test/suite/compat/oracle/r/truncate.result @@ -0,0 +1,10 @@ +SET sql_mode=ORACLE; +# +# MDEV-10588 sql_mode=ORACLE: TRUNCATE TABLE t1 [ {DROP|REUSE} STORAGE ] +# +CREATE TABLE t1 (a INT); +TRUNCATE TABLE t1 REUSE STORAGE; +TRUNCATE TABLE t1 DROP STORAGE; +DROP TABLE t1; +CREATE TABLE reuse (reuse INT); +DROP TABLE reuse; diff --git a/mysql-test/suite/compat/oracle/t/truncate.test b/mysql-test/suite/compat/oracle/t/truncate.test new file mode 100644 index 0000000000000..ac540047e49cb --- /dev/null +++ b/mysql-test/suite/compat/oracle/t/truncate.test @@ -0,0 +1,16 @@ +SET sql_mode=ORACLE; + +--echo # +--echo # MDEV-10588 sql_mode=ORACLE: TRUNCATE TABLE t1 [ {DROP|REUSE} STORAGE ] +--echo # + +CREATE TABLE t1 (a INT); +TRUNCATE TABLE t1 REUSE STORAGE; +TRUNCATE TABLE t1 DROP STORAGE; +DROP TABLE t1; + +# REUSE is actually a reserved word in Oracle. +# But we don't reserve it for MDEV-10588 + +CREATE TABLE reuse (reuse INT); +DROP TABLE reuse; diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test index dd006d0106429..cf087590df2ce 100644 --- a/mysql-test/t/keywords.test +++ b/mysql-test/t/keywords.test @@ -256,3 +256,6 @@ DROP TABLE notfound; CREATE TABLE raise (raise int); DROP TABLE raise; + +CREATE TABLE reuse (reuse int); +DROP TABLE reuse; diff --git a/sql/lex.h b/sql/lex.h index a932a24cd3ca6..67db3b746bf8b 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -517,6 +517,7 @@ static SYMBOL symbols[] = { { "RETURN", SYM(RETURN_SYM)}, { "RETURNING", SYM(RETURNING_SYM)}, { "RETURNS", SYM(RETURNS_SYM)}, + { "REUSE", SYM(REUSE_SYM)}, { "REVERSE", SYM(REVERSE_SYM)}, { "REVOKE", SYM(REVOKE)}, { "RIGHT", SYM(RIGHT)}, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0aaec9e6cd52d..de5c07c6c6a75 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1369,6 +1369,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token RETURNING_SYM %token RETURNS_SYM /* SQL-2003-R */ %token RETURN_SYM /* SQL-2003-R */ +%token REUSE_SYM /* Oracle-R */ %token REVERSE_SYM %token REVOKE /* SQL-2003-R */ %token RIGHT /* SQL-2003-R */ @@ -14365,6 +14366,7 @@ keyword_sp: | RESUME_SYM {} | RETURNED_SQLSTATE_SYM {} | RETURNS_SYM {} + | REUSE_SYM {} | REVERSE_SYM {} | ROLE_SYM {} | ROLLUP_SYM {} diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 871d402d99076..46de67036ffe7 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -786,6 +786,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token RETURNING_SYM %token RETURNS_SYM /* SQL-2003-R */ %token RETURN_SYM /* SQL-2003-R */ +%token REUSE_SYM /* Oracle-R */ %token REVERSE_SYM %token REVOKE /* SQL-2003-R */ %token RIGHT /* SQL-2003-R */ @@ -12341,6 +12342,13 @@ truncate: if (lex->m_sql_cmd == NULL) MYSQL_YYABORT; } + opt_truncate_table_storage_clause { } + ; + +opt_truncate_table_storage_clause: + /* Empty */ + | DROP STORAGE_SYM + | REUSE_SYM STORAGE_SYM ; opt_table_sym: @@ -14507,6 +14515,7 @@ keyword_sp: | RESUME_SYM {} | RETURNED_SQLSTATE_SYM {} | RETURNS_SYM {} + | REUSE_SYM {} /* Oracle-R */ | REVERSE_SYM {} | ROLE_SYM {} | ROLLUP_SYM {}