summaryrefslogtreecommitdiff
path: root/mysql-test/suite/sql_sequence
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/sql_sequence')
-rw-r--r--mysql-test/suite/sql_sequence/create.result135
-rw-r--r--mysql-test/suite/sql_sequence/create.test74
-rw-r--r--mysql-test/suite/sql_sequence/next.result7
-rw-r--r--mysql-test/suite/sql_sequence/next.test9
-rw-r--r--mysql-test/suite/sql_sequence/partition.result7
-rw-r--r--mysql-test/suite/sql_sequence/partition.test11
-rw-r--r--mysql-test/suite/sql_sequence/slave_nextval.result108
-rw-r--r--mysql-test/suite/sql_sequence/slave_nextval.test132
8 files changed, 483 insertions, 0 deletions
diff --git a/mysql-test/suite/sql_sequence/create.result b/mysql-test/suite/sql_sequence/create.result
index a5eb64802db..0a44dfe8931 100644
--- a/mysql-test/suite/sql_sequence/create.result
+++ b/mysql-test/suite/sql_sequence/create.result
@@ -498,3 +498,138 @@ previous value for t1
drop sequence t1;
create table t1 (a int) engine=sql_sequence;
ERROR 42000: Unknown storage engine 'sql_sequence'
+#
+# MDEV-13711 assertion on CREATE LIKE fix
+#
+create sequence s;
+create table t like s;
+show create table t;
+Table Create Table
+t CREATE TABLE `t` (
+ `next_not_cached_value` bigint(21) NOT NULL,
+ `minimum_value` bigint(21) NOT NULL,
+ `maximum_value` bigint(21) NOT NULL,
+ `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
+ `increment` bigint(21) NOT NULL COMMENT 'increment value',
+ `cache_size` bigint(21) unsigned NOT NULL,
+ `cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
+ `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
+) ENGINE=MyISAM SEQUENCE=1
+show create sequence t;
+Table Create Table
+t CREATE SEQUENCE `t` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
+drop tables t, s;
+#
+# 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;
+#
+# MDEV-13721 Assertion is_lock_owner() failed in mysql_rm_table_no_locks
+#
+create or replace sequence s;
+create temporary table s (i int);
+drop sequence s;
+show create table s;
+Table Create Table
+s CREATE TEMPORARY TABLE `s` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table s;
+create or replace sequence s;
+create temporary sequence s;
+show create table s;
+Table Create Table
+s CREATE TEMPORARY TABLE `s` (
+ `next_not_cached_value` bigint(21) NOT NULL,
+ `minimum_value` bigint(21) NOT NULL,
+ `maximum_value` bigint(21) NOT NULL,
+ `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
+ `increment` bigint(21) NOT NULL COMMENT 'increment value',
+ `cache_size` bigint(21) unsigned NOT NULL,
+ `cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
+ `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
+) ENGINE=MyISAM SEQUENCE=1
+drop sequence s;
+show create table s;
+Table Create Table
+s CREATE TABLE `s` (
+ `next_not_cached_value` bigint(21) NOT NULL,
+ `minimum_value` bigint(21) NOT NULL,
+ `maximum_value` bigint(21) NOT NULL,
+ `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
+ `increment` bigint(21) NOT NULL COMMENT 'increment value',
+ `cache_size` bigint(21) unsigned NOT NULL,
+ `cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
+ `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
+) ENGINE=MyISAM SEQUENCE=1
+drop table s;
+create or replace sequence s;
+create temporary sequence s;
+drop temporary sequence s;
+show create table s;
+Table Create Table
+s CREATE TABLE `s` (
+ `next_not_cached_value` bigint(21) NOT NULL,
+ `minimum_value` bigint(21) NOT NULL,
+ `maximum_value` bigint(21) NOT NULL,
+ `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
+ `increment` bigint(21) NOT NULL COMMENT 'increment value',
+ `cache_size` bigint(21) unsigned NOT NULL,
+ `cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
+ `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
+) ENGINE=MyISAM SEQUENCE=1
+drop table s;
+create temporary sequence s;
+drop temporary table s;
+create temporary table s (i int);
+drop temporary sequence s;
+ERROR 42S02: Unknown SEQUENCE: 'test.s'
+drop table s;
diff --git a/mysql-test/suite/sql_sequence/create.test b/mysql-test/suite/sql_sequence/create.test
index 23c32939efc..6696e78db92 100644
--- a/mysql-test/suite/sql_sequence/create.test
+++ b/mysql-test/suite/sql_sequence/create.test
@@ -375,3 +375,77 @@ drop sequence t1;
--error ER_UNKNOWN_STORAGE_ENGINE
create table t1 (a int) engine=sql_sequence;
+
+--echo #
+--echo # MDEV-13711 assertion on CREATE LIKE fix
+--echo #
+
+create sequence s;
+create table t like s;
+show create table t;
+show create sequence t;
+drop tables t, s;
+
+--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;
+
+--echo #
+--echo # MDEV-13721 Assertion is_lock_owner() failed in mysql_rm_table_no_locks
+--echo #
+
+create or replace sequence s;
+create temporary table s (i int);
+drop sequence s;
+show create table s;
+drop table s;
+
+create or replace sequence s;
+create temporary sequence s;
+show create table s;
+drop sequence s;
+show create table s;
+drop table s;
+
+create or replace sequence s;
+create temporary sequence s;
+drop temporary sequence s;
+show create table s;
+drop table s;
+
+create temporary sequence s;
+drop temporary table s;
+create temporary table s (i int);
+--error ER_UNKNOWN_SEQUENCES
+drop temporary sequence s;
+drop table s;
diff --git a/mysql-test/suite/sql_sequence/next.result b/mysql-test/suite/sql_sequence/next.result
index a10c131e0e1..d138c342c9d 100644
--- a/mysql-test/suite/sql_sequence/next.result
+++ b/mysql-test/suite/sql_sequence/next.result
@@ -512,3 +512,10 @@ def PREVIOUS VALUE FOR s1 8 20 1 Y 32896 0 63
NEXT VALUE FOR s1 PREVIOUS VALUE FOR s1
1 1
DROP SEQUENCE s1;
+#
+# MDEV-13720 ER_NOT_SEQUENCE for temporary table
+#
+create temporary table tmp (i int);
+select next value for tmp;
+ERROR 42S02: 'test.tmp' is not a SEQUENCE
+drop table tmp;
diff --git a/mysql-test/suite/sql_sequence/next.test b/mysql-test/suite/sql_sequence/next.test
index 271c4a6558a..79249002d8f 100644
--- a/mysql-test/suite/sql_sequence/next.test
+++ b/mysql-test/suite/sql_sequence/next.test
@@ -260,3 +260,12 @@ SELECT
DROP SEQUENCE s1;
--enable_ps_protocol
--disable_metadata
+
+--echo #
+--echo # MDEV-13720 ER_NOT_SEQUENCE for temporary table
+--echo #
+
+create temporary table tmp (i int);
+--error ER_NOT_SEQUENCE
+select next value for tmp;
+drop table tmp;
diff --git a/mysql-test/suite/sql_sequence/partition.result b/mysql-test/suite/sql_sequence/partition.result
new file mode 100644
index 00000000000..223285ce95d
--- /dev/null
+++ b/mysql-test/suite/sql_sequence/partition.result
@@ -0,0 +1,7 @@
+#
+# MDEV-13715 ha_partition::engine_name() segfault fix
+#
+create sequence s;
+alter table s partition by hash(start_value) partitions 2;
+ERROR HY000: Table storage engine 'partition' does not support the create option 'SEQUENCE'
+drop sequence s;
diff --git a/mysql-test/suite/sql_sequence/partition.test b/mysql-test/suite/sql_sequence/partition.test
new file mode 100644
index 00000000000..d820b46987e
--- /dev/null
+++ b/mysql-test/suite/sql_sequence/partition.test
@@ -0,0 +1,11 @@
+--source include/have_partition.inc
+--source include/have_sequence.inc
+
+--echo #
+--echo # MDEV-13715 ha_partition::engine_name() segfault fix
+--echo #
+
+create sequence s;
+--error ER_ILLEGAL_HA_CREATE_OPTION
+alter table s partition by hash(start_value) partitions 2;
+drop sequence s;
diff --git a/mysql-test/suite/sql_sequence/slave_nextval.result b/mysql-test/suite/sql_sequence/slave_nextval.result
new file mode 100644
index 00000000000..bfbc472e117
--- /dev/null
+++ b/mysql-test/suite/sql_sequence/slave_nextval.result
@@ -0,0 +1,108 @@
+include/master-slave.inc
+[connection master]
+CREATE SEQUENCE s;
+INSERT INTO s VALUES (1,1,4,1,1,1,0,0);
+show create sequence s;
+Table Create Table
+s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 4 increment by 1 cache 1 nocycle ENGINE=MyISAM
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+1
+connection slave;
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+2
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+3
+connection master;
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+2
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+3
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+4
+select * from s;
+next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
+5 1 4 1 1 1 0 0
+connection slave;
+select * from s;
+next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
+5 1 4 1 1 1 0 0
+connection master;
+DROP SEQUENCE s;
+CREATE SEQUENCE s;
+INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
+show create sequence s;
+Table Create Table
+s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 3 increment by 1 cache 1 cycle ENGINE=MyISAM
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+1
+connection slave;
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+2
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+3
+connection master;
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+2
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+3
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+1
+select * from s;
+next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
+2 1 3 1 1 1 1 1
+connection slave;
+select * from s;
+next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
+2 1 3 1 1 1 1 1
+connection master;
+DROP SEQUENCE s;
+CREATE SEQUENCE s;
+INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
+SELECT NEXTVAL(s);
+NEXTVAL(s)
+1
+CREATE PROCEDURE pr(n INT)
+BEGIN
+DECLARE i INT DEFAULT 0;
+WHILE i < n
+DO
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+SET i= i+1;
+END WHILE;
+END $
+connect con1,localhost,root,,;
+CALL pr(100);
+connect con2,localhost,root,,;
+CALL pr(100);
+connect con3,localhost,root,,;
+CALL pr(100);
+connect con4,localhost,root,,;
+CALL pr(100);
+connect con5,localhost,root,,;
+CALL pr(100);
+connect con6,localhost,root,,;
+CALL pr(100);
+connect con7,localhost,root,,;
+CALL pr(100);
+connect con8,localhost,root,,;
+CALL pr(100);
+connection master;
+connection slave;
+connection master;
+DROP SEQUENCE s;
+DROP PROCEDURE pr;
+include/rpl_end.inc
diff --git a/mysql-test/suite/sql_sequence/slave_nextval.test b/mysql-test/suite/sql_sequence/slave_nextval.test
new file mode 100644
index 00000000000..70da1044540
--- /dev/null
+++ b/mysql-test/suite/sql_sequence/slave_nextval.test
@@ -0,0 +1,132 @@
+--source include/master-slave.inc
+--source include/have_binlog_format_row.inc
+
+#
+# MDEV-14092 NEXTVAL() fails on slave
+#
+
+CREATE SEQUENCE s;
+INSERT INTO s VALUES (1,1,4,1,1,1,0,0);
+show create sequence s;
+SELECT NEXTVAL(s);
+
+--sync_slave_with_master
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+
+--connection master
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+
+select * from s;
+
+--sync_slave_with_master
+
+select * from s;
+--connection master
+DROP SEQUENCE s;
+
+#
+# Same as above, but with cycles
+#
+
+CREATE SEQUENCE s;
+INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
+show create sequence s;
+SELECT NEXTVAL(s);
+
+--sync_slave_with_master
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+
+--connection master
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+
+select * from s;
+
+--sync_slave_with_master
+
+select * from s;
+
+--connection master
+DROP SEQUENCE s;
+
+# Here is a bit more complicated concurrent scenario that
+# causes the same effect without any updates on the slave. You might
+# need to replace 100 with a bigger value if it doesn't happen on your
+# machine right away.
+
+CREATE SEQUENCE s;
+INSERT INTO s VALUES (1,1,3,1,1,1,1,0);
+SELECT NEXTVAL(s);
+
+--delimiter $
+CREATE PROCEDURE pr(n INT)
+BEGIN
+DECLARE i INT DEFAULT 0;
+WHILE i < n
+DO
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+SELECT NEXTVAL(s);
+SET i= i+1;
+END WHILE;
+END $
+--delimiter ;
+
+--connect (con1,localhost,root,,)
+--send CALL pr(100)
+--connect (con2,localhost,root,,)
+--send CALL pr(100)
+--connect (con3,localhost,root,,)
+--send CALL pr(100)
+--connect (con4,localhost,root,,)
+--send CALL pr(100)
+--connect (con5,localhost,root,,)
+--send CALL pr(100)
+--connect (con6,localhost,root,,)
+--send CALL pr(100)
+--connect (con7,localhost,root,,)
+--send CALL pr(100)
+--connect (con8,localhost,root,,)
+--send CALL pr(100)
+
+
+--disable_query_log
+--disable_result_log
+
+--connection con1
+--reap
+--connection con2
+--reap
+--connection con3
+--reap
+--connection con4
+--reap
+--connection con5
+--reap
+--connection con6
+--reap
+--connection con7
+--reap
+--connection con8
+--reap
+
+--enable_query_log
+--enable_result_log
+
+--connection master
+
+--sync_slave_with_master
+
+--connection master
+DROP SEQUENCE s;
+DROP PROCEDURE pr;
+
+#
+# Cleanup
+#
+--source include/rpl_end.inc