summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-05-22 16:38:02 +0300
committerMonty <monty@mariadb.org>2018-05-22 18:33:18 +0300
commitd6976a7e52a687d5d1da903d2879bd48cca399d5 (patch)
treec0495c7baf9a55a1bba14d32b36fbd839525bac6 /mysql-test
parent14e5db6fadfe52399ab103feaf38d8b005caba32 (diff)
downloadmariadb-git-d6976a7e52a687d5d1da903d2879bd48cca399d5.tar.gz
MDEV-16234 CREATE TABLE .. SELECT LASTVAL breaks replication
Fixed by marking NEXTVAL() and LASTVAL() to be replicated row based
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/suite/sql_sequence/replication_mixed.result35
-rw-r--r--mysql-test/suite/sql_sequence/replication_mixed.test27
2 files changed, 62 insertions, 0 deletions
diff --git a/mysql-test/suite/sql_sequence/replication_mixed.result b/mysql-test/suite/sql_sequence/replication_mixed.result
new file mode 100644
index 00000000000..f581d59fc30
--- /dev/null
+++ b/mysql-test/suite/sql_sequence/replication_mixed.result
@@ -0,0 +1,35 @@
+include/master-slave.inc
+[connection master]
+#
+# MDEV-16234
+# CREATE TABLE .. SELECT LASTVAL is written to binlog as single
+# statement, causes discrepancy between master and slave
+#
+CREATE SEQUENCE s1 ENGINE=InnoDB;
+SELECT NEXTVAL(s1);
+NEXTVAL(s1)
+1
+CREATE TABLE t1 ENGINE=InnoDB SELECT LASTVAL(s1) AS a;
+INSERT INTO t1 VALUES (NEXTVAL(s1));
+INSERT INTO t1 VALUES (LASTVAL(s1));
+SELECT * FROM t1;
+a
+1
+2
+2
+SELECT * from s1;
+next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
+1001 1 9223372036854775806 1 1 1000 0 0
+connection slave;
+SELECT * FROM t1;
+a
+1
+2
+2
+SELECT * from s1;
+next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
+1001 1 9223372036854775806 1 1 1000 0 0
+connection master;
+DROP TABLE t1;
+DROP SEQUENCE s1;
+include/rpl_end.inc
diff --git a/mysql-test/suite/sql_sequence/replication_mixed.test b/mysql-test/suite/sql_sequence/replication_mixed.test
new file mode 100644
index 00000000000..0096ab5acd8
--- /dev/null
+++ b/mysql-test/suite/sql_sequence/replication_mixed.test
@@ -0,0 +1,27 @@
+--source include/have_innodb.inc
+--source include/have_binlog_format_mixed.inc
+--source include/master-slave.inc
+
+--echo #
+--echo # MDEV-16234
+--echo # CREATE TABLE .. SELECT LASTVAL is written to binlog as single
+--echo # statement, causes discrepancy between master and slave
+--echo #
+
+CREATE SEQUENCE s1 ENGINE=InnoDB;
+SELECT NEXTVAL(s1);
+CREATE TABLE t1 ENGINE=InnoDB SELECT LASTVAL(s1) AS a;
+INSERT INTO t1 VALUES (NEXTVAL(s1));
+INSERT INTO t1 VALUES (LASTVAL(s1));
+SELECT * FROM t1;
+SELECT * from s1;
+--sync_slave_with_master
+SELECT * FROM t1;
+SELECT * from s1;
+
+# Cleanup
+--connection master
+DROP TABLE t1;
+DROP SEQUENCE s1;
+
+--source include/rpl_end.inc