summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-08-12 18:50:54 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-08-12 18:50:54 +0300
commit609ea2f37b8169a7c282fe2d607c2412467ccbbb (patch)
treece5f8317d4d659641799c560fe074abcc24d6ac6 /mysql-test
parentbe33124c9dc284c4409d02e5405de568b467a167 (diff)
downloadmariadb-git-609ea2f37b8169a7c282fe2d607c2412467ccbbb.tar.gz
MDEV-17614: After-merge fix
MDEV-17614 flags INSERT…ON DUPLICATE KEY UPDATE unsafe for statement-based replication when there are multiple unique indexes. This correctly fixes something whose attempted fix in MySQL 5.7 in mysql/mysql-server@c93b0d9a972cb6f98fd445f2b69d924350f9128a caused lock conflicts. That change was reverted in MySQL 5.7.26 in mysql/mysql-server@066b6fdd433aa6673622341f1a2f0a3a20018043 (with a substantial amount of other changes). In MDEV-17073 we already disabled the unfortunate MySQL change when statement-based replication was not being used. Now, thanks to MDEV-17614, we can actually remove the change altogether. This reverts commit 8a346f31b913daa011085afec2b2d38450c73e00 (MDEV-17073) and mysql/mysql-server@c93b0d9a972cb6f98fd445f2b69d924350f9128a while keeping the test cases.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/suite/innodb/r/auto_increment_dup,skip-log-bin.rdiff51
-rw-r--r--mysql-test/suite/innodb/r/auto_increment_dup.result27
-rw-r--r--mysql-test/suite/innodb/t/auto_increment_dup.test8
-rw-r--r--mysql-test/suite/rpl/disabled.def1
-rw-r--r--mysql-test/suite/rpl/r/rpl_mdev_17614.result31
5 files changed, 46 insertions, 72 deletions
diff --git a/mysql-test/suite/innodb/r/auto_increment_dup,skip-log-bin.rdiff b/mysql-test/suite/innodb/r/auto_increment_dup,skip-log-bin.rdiff
deleted file mode 100644
index 7b4ec54eed8..00000000000
--- a/mysql-test/suite/innodb/r/auto_increment_dup,skip-log-bin.rdiff
+++ /dev/null
@@ -1,51 +0,0 @@
---- auto_increment_dup.result
-+++ auto_increment_dup,skip-log-bin.reject
-@@ -89,13 +89,14 @@
- SET DEBUG_SYNC='execute_command_after_close_tables SIGNAL continue';
- affected rows: 0
- INSERT INTO t1(k) VALUES (2), (4), (5) ON DUPLICATE KEY UPDATE c='2';
--ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-+affected rows: 3
-+info: Records: 3 Duplicates: 0 Warnings: 0
- connection con1;
- #
- # 2 duplicates
- #
--affected rows: 3
--info: Records: 3 Duplicates: 0 Warnings: 0
-+affected rows: 4
-+info: Records: 3 Duplicates: 1 Warnings: 0
- connection default;
- #
- # 3 rows
-@@ -103,19 +104,21 @@
- SELECT * FROM t1 order by k;
- id k c
- 1 1 NULL
--2 2 NULL
--3 3 NULL
--affected rows: 3
-+4 2 1
-+2 3 NULL
-+5 4 NULL
-+6 5 NULL
-+affected rows: 5
- INSERT INTO t1(k) VALUES (2), (4), (5) ON DUPLICATE KEY UPDATE c='2';
--affected rows: 4
--info: Records: 3 Duplicates: 1 Warnings: 0
-+affected rows: 6
-+info: Records: 3 Duplicates: 3 Warnings: 0
- SELECT * FROM t1 order by k;
- id k c
- 1 1 NULL
--2 2 2
--3 3 NULL
--7 4 NULL
--8 5 NULL
-+4 2 2
-+2 3 NULL
-+5 4 2
-+6 5 2
- affected rows: 5
- disconnect con1;
- disconnect con2;
diff --git a/mysql-test/suite/innodb/r/auto_increment_dup.result b/mysql-test/suite/innodb/r/auto_increment_dup.result
index 1467a459fc1..9926047b665 100644
--- a/mysql-test/suite/innodb/r/auto_increment_dup.result
+++ b/mysql-test/suite/innodb/r/auto_increment_dup.result
@@ -89,13 +89,14 @@ affected rows: 0
SET DEBUG_SYNC='execute_command_after_close_tables SIGNAL continue';
affected rows: 0
INSERT INTO t1(k) VALUES (2), (4), (5) ON DUPLICATE KEY UPDATE c='2';
-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+affected rows: 3
+info: Records: 3 Duplicates: 0 Warnings: 0
connection con1;
#
# 2 duplicates
#
-affected rows: 3
-info: Records: 3 Duplicates: 0 Warnings: 0
+affected rows: 4
+info: Records: 3 Duplicates: 1 Warnings: 0
connection default;
#
# 3 rows
@@ -103,19 +104,21 @@ connection default;
SELECT * FROM t1 order by k;
id k c
1 1 NULL
-2 2 NULL
-3 3 NULL
-affected rows: 3
+4 2 1
+2 3 NULL
+5 4 NULL
+6 5 NULL
+affected rows: 5
INSERT INTO t1(k) VALUES (2), (4), (5) ON DUPLICATE KEY UPDATE c='2';
-affected rows: 4
-info: Records: 3 Duplicates: 1 Warnings: 0
+affected rows: 6
+info: Records: 3 Duplicates: 3 Warnings: 0
SELECT * FROM t1 order by k;
id k c
1 1 NULL
-2 2 2
-3 3 NULL
-7 4 NULL
-8 5 NULL
+4 2 2
+2 3 NULL
+5 4 2
+6 5 2
affected rows: 5
disconnect con1;
disconnect con2;
diff --git a/mysql-test/suite/innodb/t/auto_increment_dup.test b/mysql-test/suite/innodb/t/auto_increment_dup.test
index aa399e5966d..9e54a6a8a66 100644
--- a/mysql-test/suite/innodb/t/auto_increment_dup.test
+++ b/mysql-test/suite/innodb/t/auto_increment_dup.test
@@ -8,8 +8,6 @@
--source include/have_debug_sync.inc
--source include/innodb_binlog.inc
-let $stmt= `SELECT @@GLOBAL.log_bin`;
-
set global transaction isolation level repeatable read;
CREATE TABLE t1(
@@ -84,13 +82,7 @@ SET DEBUG_SYNC='ha_write_row_end SIGNAL write_row_done WAIT_FOR continue';
--reap
SET DEBUG_SYNC='execute_command_after_close_tables SIGNAL continue';
-if ($stmt) {
---error ER_LOCK_WAIT_TIMEOUT
-INSERT INTO t1(k) VALUES (2), (4), (5) ON DUPLICATE KEY UPDATE c='2';
-}
-if (!$stmt) {
INSERT INTO t1(k) VALUES (2), (4), (5) ON DUPLICATE KEY UPDATE c='2';
-}
--connection con1
--echo #
diff --git a/mysql-test/suite/rpl/disabled.def b/mysql-test/suite/rpl/disabled.def
index cfebf0f6ff1..59ca2958e80 100644
--- a/mysql-test/suite/rpl/disabled.def
+++ b/mysql-test/suite/rpl/disabled.def
@@ -15,4 +15,3 @@ rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnin
rpl_partition_archive : MDEV-5077 2013-09-27 svoj Cannot exchange partition with archive table
rpl_row_binlog_max_cache_size : MDEV-11092
rpl_row_index_choice : MDEV-11666
-rpl_mdev_17614 : MDEV-17614/MDEV-17073 Unexpected lock conflict
diff --git a/mysql-test/suite/rpl/r/rpl_mdev_17614.result b/mysql-test/suite/rpl/r/rpl_mdev_17614.result
index 28de23e28c9..39057334926 100644
--- a/mysql-test/suite/rpl/r/rpl_mdev_17614.result
+++ b/mysql-test/suite/rpl/r/rpl_mdev_17614.result
@@ -3,19 +3,24 @@ include/master-slave.inc
call mtr.add_suppression("Unsafe statement written to the binary log using statement format");
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY , b INT,
UNIQUE(b), c int) engine=innodb;
+connection slave;
+connection master;
INSERT INTO t1 VALUES (1, 1, 1);
BEGIN;
INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c);
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe
+connection master1;
INSERT INTO t1 VALUES(2, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c);
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe
+connection master;
COMMIT;
SELECT * FROM t1;
a b c
1 1 2
2 2 3
+connection slave;
include/wait_for_slave_sql_error.inc [errno=1062]
Last_SQL_Error = 'Error 'Duplicate entry '1' for key 'b'' on query. Default database: 'test'. Query: 'INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c)''
#Different value from server
@@ -26,61 +31,85 @@ a b c
stop slave;
include/wait_for_slave_to_stop.inc
reset slave;
+connection master;
reset master;
drop table t1;
+connection slave;
start slave;
include/wait_for_slave_to_start.inc
+connection master;
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT,
UNIQUE(b), c int) engine=innodb;
+connection slave;
+connection master;
INSERT INTO t1 VALUES (default, 1, 1);
BEGIN;
INSERT INTO t1 VALUES (default, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c);
+connection master1;
INSERT INTO t1 VALUES(default, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c);
+connection master;
COMMIT;
SELECT * FROM t1;
a b c
1 1 2
3 2 3
+connection slave;
#same data as master
SELECT * FROM t1;
a b c
1 1 2
3 2 3
+connection master;
drop table t1;
+connection slave;
+connection master;
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT,
UNIQUE(b), c int, d int ) engine=innodb;
+connection slave;
+connection master;
INSERT INTO t1 VALUES (1, 1, 1, 1);
BEGIN;
INSERT INTO t1 VALUES (2, NULL, 2, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c);
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe
+connection master1;
INSERT INTO t1 VALUES(3, NULL, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c);
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe
+connection master;
COMMIT;
SELECT * FROM t1;
a b c d
1 1 1 1
2 NULL 2 2
3 NULL 2 3
+connection slave;
#same data as master
SELECT * FROM t1;
a b c d
1 1 1 1
2 NULL 2 2
3 NULL 2 3
+connection master;
drop table t1;
+connection slave;
+connection master;
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT,
UNIQUE(b), c int) engine=innodb;
+connection slave;
+connection master;
INSERT INTO t1 VALUES (1, 1, 1);
BEGIN;
INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c);
+connection master1;
INSERT INTO t1 VALUES(2, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c);
+connection master;
COMMIT;
SELECT * FROM t1;
a b c
1 1 2
2 2 3
+connection slave;
include/wait_for_slave_sql_error.inc [errno=1062]
Last_SQL_Error = 'Error 'Duplicate entry '1' for key 'b'' on query. Default database: 'test'. Query: 'INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c)''
#Different value from server
@@ -91,8 +120,10 @@ a b c
stop slave;
include/wait_for_slave_to_stop.inc
reset slave;
+connection master;
reset master;
drop table t1;
+connection slave;
start slave;
include/wait_for_slave_to_start.inc
include/rpl_end.inc