mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
BUG#11758263 50440: MARK UNORDERED UPDATE WITH AUTOINC UNSAFE
Problem: Statements that write to tables with auto_increment columns based on the selection from another table, may lead to master and slave going out of sync, as the order in which the rows are retrived from the table may differ on master and slave. Solution: We mark writing to a table with auto_increment table as unsafe. This will cause the execution of such statements to throw a warning and forces the statement to be logged in ROW if the logging format is mixed. Changes: 1. All the statements that writes to a table with auto_increment column(s) based on the rows fetched from another table, will now be unsafe. 2. CREATE TABLE with SELECT will now be unsafe.
This commit is contained in:
@ -10,6 +10,8 @@
|
||||
# We also check how the foreign_key_check variable is replicated
|
||||
|
||||
-- source include/master-slave.inc
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
|
||||
|
||||
#should work for both SBR and RBR
|
||||
|
||||
create table t1(a int auto_increment, primary key(a));
|
||||
@ -50,6 +52,7 @@ create table t2(b int auto_increment, c int, primary key(b));
|
||||
insert into t1 values (10);
|
||||
insert into t1 values (null),(null),(null);
|
||||
insert into t2 values (5,0);
|
||||
--disable_warnings ONCE
|
||||
insert into t2 (c) select * from t1 ORDER BY a;
|
||||
select * from t2 ORDER BY b;
|
||||
sync_slave_with_master;
|
||||
|
@ -1,5 +1,7 @@
|
||||
source include/master-slave.inc;
|
||||
|
||||
call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.');
|
||||
|
||||
eval CREATE TABLE t1 (
|
||||
a int unsigned not null auto_increment primary key,
|
||||
b int unsigned
|
||||
@ -11,6 +13,7 @@ eval CREATE TABLE t2 (
|
||||
) ENGINE=$engine_type;
|
||||
|
||||
INSERT INTO t1 VALUES (NULL, 0);
|
||||
--disable_warnings ONCE
|
||||
INSERT INTO t1 SELECT NULL, 0 FROM t1;
|
||||
|
||||
INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
|
||||
@ -18,6 +21,7 @@ INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY a;
|
||||
|
||||
--disable_warnings ONCE
|
||||
UPDATE t1, t2 SET t1.b = t2.b WHERE t1.a = t2.a;
|
||||
sync_slave_with_master;
|
||||
|
||||
|
@ -17,6 +17,8 @@ eval CREATE TABLE t2 (
|
||||
) ENGINE=$engine_type;
|
||||
|
||||
INSERT INTO t1 VALUES (NULL, 0);
|
||||
|
||||
--disable_warnings ONCE
|
||||
INSERT INTO t1 SELECT NULL, 0 FROM t1;
|
||||
|
||||
INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
|
||||
@ -24,6 +26,7 @@ INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY a;
|
||||
|
||||
--disable_warnings ONCE
|
||||
UPDATE t1, t2 SET t1.b = (t2.b+4) WHERE t1.a = t2.a;
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY a;
|
||||
|
@ -18,6 +18,8 @@ eval CREATE TABLE t2 (
|
||||
) ENGINE=$engine_type;
|
||||
|
||||
INSERT INTO t1 VALUES (NULL, 0);
|
||||
|
||||
--disable_warnings ONCE
|
||||
INSERT INTO t1 SELECT NULL, 0 FROM t1;
|
||||
|
||||
INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
|
||||
@ -25,6 +27,7 @@ INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY a;
|
||||
|
||||
--disable_warnings ONCE
|
||||
UPDATE t2, (SELECT a FROM t1 ORDER BY a) AS t SET t2.b = t.a+5 ;
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY a;
|
||||
|
Reference in New Issue
Block a user