From 7447b4ce37211e3450dcdbd1cb39b0b63d8c0751 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Sun, 22 Oct 2017 12:26:32 +0300 Subject: [PATCH] MDEV-13714 Value of SEQUENCE table option is ignored upon creation CREATE TABLE ... sequence=0 and sequence=DEFAULT created sequence tables when they should not. Signed-off-by: Monty --- mysql-test/suite/sql_sequence/create.result | 52 +++++++++++++++++++++ mysql-test/suite/sql_sequence/create.test | 34 ++++++++++++++ sql/sql_yacc.yy | 2 +- sql/sql_yacc_ora.yy | 2 +- 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/sql_sequence/create.result b/mysql-test/suite/sql_sequence/create.result index a5eb64802db..514e8e7566a 100644 --- a/mysql-test/suite/sql_sequence/create.result +++ b/mysql-test/suite/sql_sequence/create.result @@ -498,3 +498,55 @@ previous value for t1 drop sequence t1; create table t1 (a int) engine=sql_sequence; ERROR 42000: Unknown storage engine 'sql_sequence' +# +# MDEV-13714 SEQUENCE option fix +# +create or replace table s ( +`next_value` bigint(21) not null, +`min_value` bigint(21) not null, +`max_value` bigint(21) not null, +`start` bigint(21) not null, +`increment` bigint(21) not null, +`cache` bigint(21) not null, +`cycle` tinyint(1) unsigned not null, +`round` bigint(21) not null) +sequence=0; +create or replace table s2 ( +`next_value` bigint(21) not null, +`min_value` bigint(21) not null, +`max_value` bigint(21) not null, +`start` bigint(21) not null, +`increment` bigint(21) not null, +`cache` bigint(21) not null, +`cycle` tinyint(1) unsigned not null, +`round` bigint(21) not null) +sequence=default; +show create table s; +Table Create Table +s CREATE TABLE `s` ( + `next_value` bigint(21) NOT NULL, + `min_value` bigint(21) NOT NULL, + `max_value` bigint(21) NOT NULL, + `start` bigint(21) NOT NULL, + `increment` bigint(21) NOT NULL, + `cache` bigint(21) NOT NULL, + `cycle` tinyint(1) unsigned NOT NULL, + `round` bigint(21) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table s2; +Table Create Table +s2 CREATE TABLE `s2` ( + `next_value` bigint(21) NOT NULL, + `min_value` bigint(21) NOT NULL, + `max_value` bigint(21) NOT NULL, + `start` bigint(21) NOT NULL, + `increment` bigint(21) NOT NULL, + `cache` bigint(21) NOT NULL, + `cycle` tinyint(1) unsigned NOT NULL, + `round` bigint(21) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create sequence s; +ERROR 42S02: 'test.s' is not a SEQUENCE +show create sequence s2; +ERROR 42S02: 'test.s2' is not a SEQUENCE +drop table s,s2; diff --git a/mysql-test/suite/sql_sequence/create.test b/mysql-test/suite/sql_sequence/create.test index 23c32939efc..01930d6c6a5 100644 --- a/mysql-test/suite/sql_sequence/create.test +++ b/mysql-test/suite/sql_sequence/create.test @@ -375,3 +375,37 @@ drop sequence t1; --error ER_UNKNOWN_STORAGE_ENGINE create table t1 (a int) engine=sql_sequence; + +--echo # +--echo # MDEV-13714 SEQUENCE option fix +--echo # + +create or replace table s ( + `next_value` bigint(21) not null, + `min_value` bigint(21) not null, + `max_value` bigint(21) not null, + `start` bigint(21) not null, + `increment` bigint(21) not null, + `cache` bigint(21) not null, + `cycle` tinyint(1) unsigned not null, + `round` bigint(21) not null) +sequence=0; + +create or replace table s2 ( + `next_value` bigint(21) not null, + `min_value` bigint(21) not null, + `max_value` bigint(21) not null, + `start` bigint(21) not null, + `increment` bigint(21) not null, + `cache` bigint(21) not null, + `cycle` tinyint(1) unsigned not null, + `round` bigint(21) not null) +sequence=default; + +show create table s; +show create table s2; +--error ER_NOT_SEQUENCE +show create sequence s; +--error ER_NOT_SEQUENCE +show create sequence s2; +drop table s,s2; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 005cbd5fd02..0a62361e222 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5904,7 +5904,7 @@ create_table_option: | SEQUENCE_SYM opt_equal choice { Lex->create_info.used_fields|= HA_CREATE_USED_SEQUENCE; - Lex->create_info.sequence= $3; + Lex->create_info.sequence= ($3 == HA_CHOICE_YES); } ; diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 9dbad2007d4..11c577884d8 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -5776,7 +5776,7 @@ create_table_option: | SEQUENCE_SYM opt_equal choice { Lex->create_info.used_fields|= HA_CREATE_USED_SEQUENCE; - Lex->create_info.sequence= $3; + Lex->create_info.sequence= ($3 == HA_CHOICE_YES); } ;