mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 21:42:35 +01:00
1626b42ca3
binlog_format=mixed Statement-based replication of DELETE ... LIMIT, UPDATE ... LIMIT, INSERT ... SELECT ... LIMIT is not safe as order of rows is not defined. With this fix, we issue a warning that this statement is not safe to replicate in statement mode, or go to row-based mode in mixed mode. Note that we may consider a statement as safe if ORDER BY primary_key is present. However it may confuse users to see very similiar statements replicated differently. Note 2: regular UPDATE statement (w/o LIMIT) is unsafe as well, but this patch doesn't address this issue. See comment from Kristian posted 18 Mar 10:55. mysql-test/suite/binlog/r/binlog_stm_ps.result: Updated a test case according to fix for BUG#34768: INSERT ... SELECT ... LIMIT is now replicated in row mode. mysql-test/suite/binlog/r/binlog_unsafe.result: A test case for BUG#34768. mysql-test/suite/binlog/t/binlog_unsafe.test: A test case for BUG#34768. sql/sql_delete.cc: Statement-based replication of DELETE ... LIMIT is not safe as order of rows is not defined, so in mixed mode we go to row-based. sql/sql_insert.cc: Statement-based replication of INSERT ... SELECT ... LIMIT is not safe as order of rows is not defined, so in mixed mode we go to row-based. sql/sql_update.cc: Statement-based replication of UPDATE ... LIMIT is not safe as order of rows is not defined, so in mixed mode we go to row-based.
41 lines
1.4 KiB
Text
41 lines
1.4 KiB
Text
SET BINLOG_FORMAT=STATEMENT;
|
|
CREATE TABLE t1 (a CHAR(40));
|
|
CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY);
|
|
CREATE TABLE t3 (b INT AUTO_INCREMENT PRIMARY KEY);
|
|
CREATE VIEW v1(a,b) AS SELECT a,b FROM t2,t3;
|
|
INSERT INTO t1 SELECT UUID();
|
|
Warnings:
|
|
Warning 1592 Statement is not safe to log in statement format.
|
|
SHOW WARNINGS;
|
|
Level Warning
|
|
Code 1592
|
|
Message Statement is not safe to log in statement format.
|
|
DROP TABLE t1,t2,t3;
|
|
CREATE TABLE t1(a INT, b INT, KEY(a), PRIMARY KEY(b));
|
|
INSERT INTO t1 SELECT * FROM t1 LIMIT 1;
|
|
Warnings:
|
|
Warning 1592 Statement is not safe to log in statement format.
|
|
REPLACE INTO t1 SELECT * FROM t1 LIMIT 1;
|
|
Warnings:
|
|
Warning 1592 Statement is not safe to log in statement format.
|
|
UPDATE t1 SET a=1 LIMIT 1;
|
|
Warnings:
|
|
Warning 1592 Statement is not safe to log in statement format.
|
|
DELETE FROM t1 LIMIT 1;
|
|
Warnings:
|
|
Warning 1592 Statement is not safe to log in statement format.
|
|
CREATE PROCEDURE p1()
|
|
BEGIN
|
|
INSERT INTO t1 SELECT * FROM t1 LIMIT 1;
|
|
REPLACE INTO t1 SELECT * FROM t1 LIMIT 1;
|
|
UPDATE t1 SET a=1 LIMIT 1;
|
|
DELETE FROM t1 LIMIT 1;
|
|
END|
|
|
CALL p1();
|
|
Warnings:
|
|
Warning 1592 Statement is not safe to log in statement format.
|
|
Warning 1592 Statement is not safe to log in statement format.
|
|
Warning 1592 Statement is not safe to log in statement format.
|
|
Warning 1592 Statement is not safe to log in statement format.
|
|
DROP PROCEDURE p1;
|
|
DROP TABLE t1;
|