mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
WL#2687 WL#5072 BUG#40278 BUG#47175
Non-transactional updates that take place inside a transaction present problems for logging because they are visible to other clients before the transaction is committed, and they are not rolled back even if the transaction is rolled back. It is not always possible to log correctly in statement format when both transactional and non-transactional tables are used in the same transaction. In the current patch, we ensure that such scenario is completely safe under the ROW and MIXED modes.
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
call mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT");
|
||||
CREATE TABLE t1m (m INT, n INT) ENGINE=MYISAM;
|
||||
CREATE TABLE t1b (b INT, c INT) ENGINE=BLACKHOLE;
|
||||
CREATE TABLE t1n (e INT, f INT) ENGINE=NDB;
|
||||
@ -6,10 +7,15 @@ SET SESSION BINLOG_FORMAT=STATEMENT;
|
||||
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction.
|
||||
The last event before the COMMIT is use `test`; UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c
|
||||
*** Please look in binlog_multi_engine.test if you have a diff here ****
|
||||
START TRANSACTION;
|
||||
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction.
|
||||
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;
|
||||
COMMIT;
|
||||
TRUNCATE t1m;
|
||||
@ -20,8 +26,12 @@ Log_name Pos Event_type Server_id End_log_pos Info
|
||||
mysqld-bin.000001 # Query # # BEGIN
|
||||
mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2)
|
||||
mysqld-bin.000001 # Query # # COMMIT
|
||||
mysqld-bin.000001 # Query # # BEGIN
|
||||
mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2)
|
||||
mysqld-bin.000001 # Query # # COMMIT
|
||||
mysqld-bin.000001 # Query # # BEGIN
|
||||
mysqld-bin.000001 # Query # # use `test`; UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c
|
||||
mysqld-bin.000001 # Query # # COMMIT
|
||||
mysqld-bin.000001 # Query # # BEGIN
|
||||
mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2)
|
||||
mysqld-bin.000001 # Query # # use `test`; UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f
|
||||
@ -39,6 +49,7 @@ RESET MASTER;
|
||||
SET SESSION BINLOG_FORMAT=MIXED;
|
||||
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
The last event before the COMMIT is use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2)
|
||||
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
|
||||
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
|
||||
@ -51,14 +62,15 @@ Log_name Pos Event_type Server_id End_log_pos Info
|
||||
mysqld-bin.000001 # Query # # BEGIN
|
||||
mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2)
|
||||
mysqld-bin.000001 # Query # # COMMIT
|
||||
mysqld-bin.000001 # Query # # BEGIN
|
||||
mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2)
|
||||
mysqld-bin.000001 # Query # # COMMIT
|
||||
mysqld-bin.000001 # Query # # BEGIN
|
||||
mysqld-bin.000001 # Table_map # # table_id: # (test.t1n)
|
||||
mysqld-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status)
|
||||
mysqld-bin.000001 # Write_rows # # table_id: #
|
||||
mysqld-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
mysqld-bin.000001 # Query # # COMMIT
|
||||
mysqld-bin.000001 # Query # # use `test`; UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c
|
||||
mysqld-bin.000001 # Query # # use `test`; TRUNCATE t1m
|
||||
mysqld-bin.000001 # Query # # use `test`; TRUNCATE t1b
|
||||
mysqld-bin.000001 # Query # # use `test`; TRUNCATE t1n
|
||||
|
Reference in New Issue
Block a user