From de85a60049af7af2cfdaa6f642e4ea7b7189afbe Mon Sep 17 00:00:00 2001 From: Rohit Kalhans Date: Wed, 8 Feb 2012 00:33:08 +0530 Subject: [PATCH 01/16] 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. sql/share/errmsg-utf8.txt: Added new Warning messages sql/sql_base.cc: created a new function that checks for select + write on a autoinc table made all such statements to be unsafe. sql/sql_parse.cc: made create autoincremnet tabble + select unsafe --- .../extra/rpl_tests/rpl_insert_id_pk.test | 3 + .../extra/rpl_tests/rpl_multi_update.test | 4 ++ .../extra/rpl_tests/rpl_multi_update2.test | 3 + .../extra/rpl_tests/rpl_multi_update3.test | 3 + mysql-test/r/ps.result | 1 + .../suite/binlog/r/binlog_unsafe.result | 55 +++++++++++++------ mysql-test/suite/binlog/t/binlog_unsafe.test | 2 +- .../rpl/r/rpl_auto_increment_11932.result | 1 + .../suite/rpl/r/rpl_insert_id_pk.result | 1 + .../suite/rpl/r/rpl_multi_update.result | 1 + .../suite/rpl/r/rpl_multi_update2.result | 1 + .../suite/rpl/r/rpl_multi_update3.result | 1 + mysql-test/suite/rpl/r/rpl_rotate_logs.result | 1 + .../suite/rpl/t/rpl_auto_increment_11932.test | 5 ++ mysql-test/suite/rpl/t/rpl_multi_update2.test | 1 + mysql-test/suite/rpl/t/rpl_multi_update3.test | 1 + mysql-test/suite/rpl/t/rpl_optimize.test | 2 + mysql-test/suite/rpl/t/rpl_rotate_logs.test | 1 + .../suite/rpl/t/rpl_semi_sync_event.test | 3 +- mysql-test/suite/rpl/t/rpl_timezone.test | 5 +- mysql-test/t/multi_update.test | 1 + mysql-test/t/ps.test | 5 ++ sql/share/errmsg-utf8.txt | 8 +++ sql/sql_base.cc | 41 +++++++++++++- sql/sql_lex.cc | 2 + sql/sql_lex.h | 15 +++++ sql/sql_parse.cc | 12 +++- 27 files changed, 153 insertions(+), 26 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test index c3ecd9381c9..f6152180e7a 100644 --- a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test +++ b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test @@ -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; diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update.test b/mysql-test/extra/rpl_tests/rpl_multi_update.test index bf7707f9d6d..cdbdbc191d7 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_update.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_update.test @@ -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; diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update2.test b/mysql-test/extra/rpl_tests/rpl_multi_update2.test index ae4261c0516..b85927a2aed 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_update2.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_update2.test @@ -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; diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update3.test b/mysql-test/extra/rpl_tests/rpl_multi_update3.test index 6c7a980aecb..f7d4815e9e5 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_update3.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_update3.test @@ -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; diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index afa105a39b8..310004de983 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1,3 +1,4 @@ +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); drop table if exists t1,t2,t3,t4; drop database if exists client_test_db; create table t1 diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index a307b765097..9c4330a96c0 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -1760,7 +1760,7 @@ SELECT COUNT(*) FROM mysql.general_log; Invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; RETURN 0; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t1 SELECT func_sidef_1(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1769,12 +1769,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. Invoking function func_sidef_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); RETURN 0; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t2 SELECT func_sidef_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1783,13 +1784,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP FUNCTION func_sidef_2; Invoking procedure proc_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_2() BEGIN INSERT INTO t1 SELECT func_sidef_1(); INSERT INTO ta2 VALUES (47); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. CALL proc_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1798,13 +1800,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PROCEDURE proc_2; Invoking trigger trig_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO trigger_table_2 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1813,6 +1816,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP TRIGGER trig_2; @@ -1826,7 +1830,8 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -* binlog_format = STATEMENT: expect 6 warnings. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t2 SELECT * FROM view_sidef_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1835,13 +1840,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP VIEW view_sidef_2; Invoking prepared statement prep_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. EXECUTE prep_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1850,6 +1856,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_2; @@ -1857,7 +1864,7 @@ DROP FUNCTION func_sidef_1; Invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_1() BEGIN INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; INSERT INTO ta1 VALUES (47); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. CALL proc_1(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1866,12 +1873,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. Invoking function func_sidef_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t2 SELECT func_sidef_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1880,13 +1888,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP FUNCTION func_sidef_2; Invoking procedure proc_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_2() BEGIN CALL proc_1(); INSERT INTO ta2 VALUES (47); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. CALL proc_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1895,13 +1904,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PROCEDURE proc_2; Invoking trigger trig_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO trigger_table_2 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1910,13 +1920,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP TRIGGER trig_2; Invoking prepared statement prep_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. PREPARE prep_2 FROM "CALL proc_1()"; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. EXECUTE prep_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1925,6 +1936,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_2; @@ -1932,7 +1944,7 @@ DROP PROCEDURE proc_1; Invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO trigger_table_1 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1941,12 +1953,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. Invoking function func_sidef_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); RETURN 0; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t2 SELECT func_sidef_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1955,13 +1968,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP FUNCTION func_sidef_2; Invoking procedure proc_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_2() BEGIN INSERT INTO trigger_table_1 VALUES (1); INSERT INTO ta2 VALUES (47); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. CALL proc_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1970,13 +1984,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PROCEDURE proc_2; Invoking trigger trig_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO trigger_table_2 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1985,13 +2000,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP TRIGGER trig_2; Invoking prepared statement prep_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. EXECUTE prep_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2000,6 +2016,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_2; @@ -2007,7 +2024,7 @@ DROP TRIGGER trig_1; Invoking prepared statement prep_1 invoking statement that is unsafe in many ways. PREPARE prep_1 FROM "INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1"; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. EXECUTE prep_1; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2016,12 +2033,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_1; Invoking statement that is unsafe in many ways. -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2030,6 +2048,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test index 040f57597c2..6b342f24ab5 100644 --- a/mysql-test/suite/binlog/t/binlog_unsafe.test +++ b/mysql-test/suite/binlog/t/binlog_unsafe.test @@ -233,7 +233,7 @@ while ($unsafe_type < 9) { --let $value_0= --let $sel_sidef_0= --let $sel_retval_0= - --let $CRC_ARG_expected_number_of_warnings= 6 + --let $CRC_ARG_expected_number_of_warnings= 7 } if ($unsafe_type == 8) { diff --git a/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result b/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result index 62ff28e7159..1d378e2d864 100644 --- a/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result +++ b/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); drop database if exists test1; create database test1; use test1; diff --git a/mysql-test/suite/rpl/r/rpl_insert_id_pk.result b/mysql-test/suite/rpl/r/rpl_insert_id_pk.result index c2d6d2c9b0c..467b8c1e5cc 100644 --- a/mysql-test/suite/rpl/r/rpl_insert_id_pk.result +++ b/mysql-test/suite/rpl/r/rpl_insert_id_pk.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); create table t1(a int auto_increment, primary key(a)); create table t2(b int auto_increment, c int, primary key(b)); insert into t1 values (1),(2),(3); diff --git a/mysql-test/suite/rpl/r/rpl_multi_update.result b/mysql-test/suite/rpl/r/rpl_multi_update.result index 8634e86afed..74fb7952a2a 100644 --- a/mysql-test/suite/rpl/r/rpl_multi_update.result +++ b/mysql-test/suite/rpl/r/rpl_multi_update.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); CREATE TABLE t1 ( a int unsigned not null auto_increment primary key, b int unsigned diff --git a/mysql-test/suite/rpl/r/rpl_multi_update2.result b/mysql-test/suite/rpl/r/rpl_multi_update2.result index a3cab693322..03ed5de473d 100644 --- a/mysql-test/suite/rpl/r/rpl_multi_update2.result +++ b/mysql-test/suite/rpl/r/rpl_multi_update2.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT'); drop table if exists t1,t2; CREATE TABLE t1 ( a int unsigned not null auto_increment primary key, diff --git a/mysql-test/suite/rpl/r/rpl_multi_update3.result b/mysql-test/suite/rpl/r/rpl_multi_update3.result index 6b9ec5c3947..bf9946f219f 100644 --- a/mysql-test/suite/rpl/r/rpl_multi_update3.result +++ b/mysql-test/suite/rpl/r/rpl_multi_update3.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); -------- Test for BUG#9361 -------- CREATE TABLE t1 ( diff --git a/mysql-test/suite/rpl/r/rpl_rotate_logs.result b/mysql-test/suite/rpl/r/rpl_rotate_logs.result index ebc75ce9e6e..ef95103c7bc 100644 --- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result +++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result @@ -1,3 +1,4 @@ +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); start slave; Got one of the listed errors start slave; diff --git a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test index d1da69533ec..1e5f9e53478 100644 --- a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test +++ b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test @@ -8,6 +8,7 @@ # Test supplied by Are Casilla source include/master-slave.inc; +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); --disable_warnings connection master; drop database if exists test1; @@ -42,12 +43,16 @@ CREATE PROCEDURE simpleproc3 () $ DELIMITER ;$ +--disable_warnings CALL simpleproc3(); +--enable_warnings select * from t2; TRUNCATE TABLE `t1`; +--disable_warnings CALL simpleproc3(); +--enable_warnings select * from t1; diff --git a/mysql-test/suite/rpl/t/rpl_multi_update2.test b/mysql-test/suite/rpl/t/rpl_multi_update2.test index 497568f2738..138c1455952 100644 --- a/mysql-test/suite/rpl/t/rpl_multi_update2.test +++ b/mysql-test/suite/rpl/t/rpl_multi_update2.test @@ -6,6 +6,7 @@ ####################################################### --source include/not_ndb_default.inc --source include/master-slave.inc +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT'); let $engine_type=MyISAM; --source extra/rpl_tests/rpl_multi_update2.test --source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_multi_update3.test b/mysql-test/suite/rpl/t/rpl_multi_update3.test index f6e70f14b30..dc12d528c24 100644 --- a/mysql-test/suite/rpl/t/rpl_multi_update3.test +++ b/mysql-test/suite/rpl/t/rpl_multi_update3.test @@ -6,6 +6,7 @@ ####################################################### --source include/not_ndb_default.inc --source include/master-slave.inc +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); let $engine_type=MyISAM; -- source extra/rpl_tests/rpl_multi_update3.test --source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_optimize.test b/mysql-test/suite/rpl/t/rpl_optimize.test index ad49df55db7..df863e614a2 100644 --- a/mysql-test/suite/rpl/t/rpl_optimize.test +++ b/mysql-test/suite/rpl/t/rpl_optimize.test @@ -19,6 +19,7 @@ enable_query_log; create table t1 (a int not null auto_increment primary key, b int, key(b)); INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +--disable_warnings INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; @@ -32,6 +33,7 @@ INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; +--enable_warnings save_master_pos; # a few updates to force OPTIMIZE to do something --disable_warnings diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test index a1b4f367812..67079b9bea1 100644 --- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test +++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test @@ -27,6 +27,7 @@ EOF chmod 0000 $MYSQLD_SLAVE_DATADIR/master.info; connection slave; +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); # START SLAVE will fail because it can't read the file (mode 000) # (system error 13) --replace_result $MYSQL_TEST_DIR TESTDIR diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test index cd73a84d569..bf622790fe7 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test @@ -52,9 +52,10 @@ SET GLOBAL event_scheduler = ON; replace_result $engine_type ENGINE_TYPE; eval CREATE TABLE t1 (i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f varchar(8)) ENGINE=$engine_type; INSERT INTO t1 (f) VALUES ('a'),('a'),('a'),('a'),('a'); +--disable_warnings INSERT INTO t1 SELECT i+5, f FROM t1; INSERT INTO t1 SELECT i+10, f FROM t1; - +--enable_warnings CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (SLEEP(5),CONCAT('ev1_',CONNECTION_ID())); CREATE EVENT ev2 ON SCHEDULE EVERY 1 SECOND diff --git a/mysql-test/suite/rpl/t/rpl_timezone.test b/mysql-test/suite/rpl/t/rpl_timezone.test index 7355106b6b4..1f0220421ab 100644 --- a/mysql-test/suite/rpl/t/rpl_timezone.test +++ b/mysql-test/suite/rpl/t/rpl_timezone.test @@ -13,14 +13,14 @@ # timezone used in CONVERT_TZ is not binlogged. To debug (by Guilhem # and possibly Konstantin). +source include/master-slave.inc; + --disable_query_log CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); --enable_query_log --disable_ps_protocol -source include/master-slave.inc; - # Save original timezone set @my_time_zone= @@global.time_zone; @@ -90,6 +90,7 @@ insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL); # from originally inserted) # set time_zone='MET'; +--disable_warnings ONCE insert into t2 (select * from t1); SELECT * FROM t1 ORDER BY n; sync_slave_with_master; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 4de574fbb0d..99ffe278e44 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -352,6 +352,7 @@ create table `t2` (`c2_id` int(10) unsigned NULL auto_increment, `c2_p_id` int(1 insert into t1 values (0,'A01-Comp',1); insert into t1 values (0,'B01-Comp',1); insert into t2 values (0,1,'A Note',1); +--disable_warnings ONCE update t1 left join t2 on p_id = c2_p_id set c2_note = 'asdf-1' where p_id = 2; select * from t1; select * from t2; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index e00bd785789..4c525c5320e 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1,5 +1,6 @@ -- source include/not_embedded.inc -- source include/have_log_bin.inc +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); # # SQL Syntax for Prepared Statements test # @@ -432,6 +433,7 @@ deallocate prepare stmt; create table t1 (a int); insert into t1 values (1),(2),(3); create table t2 select * from t1; +--disable_warnings prepare stmt FROM 'create table t2 select * from t1'; drop table t2; execute stmt; @@ -441,6 +443,7 @@ execute stmt; execute stmt; drop table t2; execute stmt; +--enable_warnings drop table t1,t2; deallocate prepare stmt; @@ -1176,6 +1179,7 @@ create database mysqltest character set utf8; prepare stmt1 from "create table mysqltest.t1 (c char(10))"; prepare stmt2 from "create table mysqltest.t2 select 'test'"; execute stmt1; +--disable_warnings ONCE execute stmt2; show create table mysqltest.t1; show create table mysqltest.t2; @@ -1183,6 +1187,7 @@ drop table mysqltest.t1; drop table mysqltest.t2; alter database mysqltest character set latin1; execute stmt1; +--disable_warnings ONCE execute stmt2; show create table mysqltest.t1; show create table mysqltest.t2; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index f5c96761da1..d164f75d7d8 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6486,3 +6486,11 @@ ER_PLUGIN_NO_UNINSTALL ER_PLUGIN_NO_INSTALL eng "Plugin '%s' is marked as not dynamically installable. You have to stop the server to install it." + + +ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT + eng "Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave." + +ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC + eng "CREATE TABLE... SELECT... on a table with an auto-increment column is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are inserted. This order cannot be predicted and may differ on master and the slave." + diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e0472e2c9b5..fda0ba61e63 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -214,7 +214,8 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list); static void free_cache_entry(TABLE *entry); static bool has_write_table_with_auto_increment(TABLE_LIST *tables); - +static bool +has_write_table_with_auto_increment_and_select(TABLE_LIST *tables); uint cached_open_tables(void) { @@ -5683,6 +5684,11 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, /* We have to emulate LOCK TABLES if we are statement needs prelocking. */ if (thd->lex->requires_prelocking()) { + + if (thd->variables.binlog_format != BINLOG_FORMAT_ROW && tables && + has_write_table_with_auto_increment_and_select(tables)) + thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT); + /* A query that modifies autoinc column in sub-statement can make the master and slave inconsistent. @@ -9080,6 +9086,39 @@ has_write_table_with_auto_increment(TABLE_LIST *tables) return 0; } +/* + checks if the tables have select tables in the table list and write tables + with auto-increment column. + + SYNOPSIS + has_two_write_locked_tables_with_auto_increment_and_select + tables Table list + + RETURN VALUES + + -true if the table list has atleast one table with auto-increment column + and atleast one table to select from. + -false otherwise +*/ + +static bool +has_write_table_with_auto_increment_and_select(TABLE_LIST *tables) +{ + bool has_select= false; + bool has_auto_increment_tables = has_write_table_with_auto_increment(tables); + for(TABLE_LIST *table= tables; table; table= table->next_global) + { + if (!table->placeholder() && + (table->lock_type <= TL_READ_NO_INSERT)) + { + has_select= true; + break; + } + } + return(has_select && has_auto_increment_tables); +} + + /* Open and lock system tables for read. diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 0cabab9fae7..7598ddd3cdd 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -61,9 +61,11 @@ Query_tables_list::binlog_stmt_unsafe_errcode[BINLOG_STMT_UNSAFE_COUNT] = ER_BINLOG_UNSAFE_MIXED_STATEMENT, ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT, ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE, + ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT, ER_BINLOG_UNSAFE_REPLACE_SELECT, ER_BINLOG_UNSAFE_CREATE_IGNORE_SELECT, ER_BINLOG_UNSAFE_CREATE_REPLACE_SELECT, + ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC, ER_BINLOG_UNSAFE_UPDATE_IGNORE }; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 8aaead811a0..1de92057b1f 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1268,6 +1268,13 @@ public: */ BINLOG_STMT_UNSAFE_INSERT_SELECT_UPDATE, + /** + Query that writes to a table with auto_inc column after selecting from + other tables are unsafe as the order in which the rows are retrieved by + select may differ on master and slave. + */ + BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT, + /** INSERT...REPLACE SELECT is unsafe because which rows are replaced depends on the order that rows are retrieved by SELECT. This order cannot be @@ -1289,6 +1296,14 @@ public: */ BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT, + /** + CREATE TABLE...SELECT on a table with auto-increment column is unsafe + because which rows are replaced depends on the order that rows are + retrieved from SELECT. This order cannot be predicted and may differ on + master and the slave + */ + BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC, + /** UPDATE...IGNORE is unsafe because which rows are ignored depends on the order that rows are updated. This order cannot be predicted and may differ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a5d23858a8d..f26deb9a01a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2414,9 +2414,12 @@ case SQLCOM_PREPARE: select_result *result; /* - CREATE TABLE...IGNORE/REPLACE SELECT... can be unsafe, unless - ORDER BY PRIMARY KEY clause is used in SELECT statement. We therefore - use row based logging if mixed or row based logging is available. + - CREATE TABLE...IGNORE + - REPLACE SELECT... + - CREATE TABLE [with auto inc. column]...SELECT + can be unsafe, unless ORDER BY PRIMARY KEY clause is used in SELECT + statement. We therefore use row based logging if mixed or row based + logging is available. TODO: Check if the order of the output of the select statement is deterministic. Waiting for BUG#42415 */ @@ -2426,6 +2429,9 @@ case SQLCOM_PREPARE: if(lex->duplicates == DUP_REPLACE) lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT); + if (lex->type & AUTO_INCREMENT_FLAG) + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC); + /* If: a) we inside an SP and there was NAME_CONST substitution, From b7430d73e4be2f5933e147ba7a44e3b054cb79b7 Mon Sep 17 00:00:00 2001 From: Rohit Kalhans Date: Wed, 8 Feb 2012 12:10:55 +0530 Subject: [PATCH 02/16] Backout the patch for bug#11758263. --- .../extra/rpl_tests/rpl_insert_id_pk.test | 3 - .../extra/rpl_tests/rpl_multi_update.test | 4 -- .../extra/rpl_tests/rpl_multi_update2.test | 3 - .../extra/rpl_tests/rpl_multi_update3.test | 3 - mysql-test/r/ps.result | 1 - .../suite/binlog/r/binlog_unsafe.result | 55 ++++++------------- mysql-test/suite/binlog/t/binlog_unsafe.test | 2 +- .../rpl/r/rpl_auto_increment_11932.result | 1 - .../suite/rpl/r/rpl_insert_id_pk.result | 1 - .../suite/rpl/r/rpl_multi_update.result | 1 - .../suite/rpl/r/rpl_multi_update2.result | 1 - .../suite/rpl/r/rpl_multi_update3.result | 1 - mysql-test/suite/rpl/r/rpl_rotate_logs.result | 1 - .../suite/rpl/t/rpl_auto_increment_11932.test | 5 -- mysql-test/suite/rpl/t/rpl_multi_update2.test | 1 - mysql-test/suite/rpl/t/rpl_multi_update3.test | 1 - mysql-test/suite/rpl/t/rpl_optimize.test | 2 - mysql-test/suite/rpl/t/rpl_rotate_logs.test | 1 - .../suite/rpl/t/rpl_semi_sync_event.test | 3 +- mysql-test/suite/rpl/t/rpl_timezone.test | 5 +- mysql-test/t/multi_update.test | 1 - mysql-test/t/ps.test | 5 -- sql/share/errmsg-utf8.txt | 8 --- sql/sql_base.cc | 41 +------------- sql/sql_lex.cc | 2 - sql/sql_lex.h | 15 ----- sql/sql_parse.cc | 12 +--- 27 files changed, 26 insertions(+), 153 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test index f6152180e7a..c3ecd9381c9 100644 --- a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test +++ b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test @@ -10,8 +10,6 @@ # 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)); @@ -52,7 +50,6 @@ 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; diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update.test b/mysql-test/extra/rpl_tests/rpl_multi_update.test index cdbdbc191d7..bf7707f9d6d 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_update.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_update.test @@ -1,7 +1,5 @@ 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 @@ -13,7 +11,6 @@ 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); @@ -21,7 +18,6 @@ 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; diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update2.test b/mysql-test/extra/rpl_tests/rpl_multi_update2.test index b85927a2aed..ae4261c0516 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_update2.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_update2.test @@ -17,8 +17,6 @@ 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); @@ -26,7 +24,6 @@ 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; diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update3.test b/mysql-test/extra/rpl_tests/rpl_multi_update3.test index f7d4815e9e5..6c7a980aecb 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_update3.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_update3.test @@ -18,8 +18,6 @@ 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); @@ -27,7 +25,6 @@ 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; diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 310004de983..afa105a39b8 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1,4 +1,3 @@ -call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); drop table if exists t1,t2,t3,t4; drop database if exists client_test_db; create table t1 diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index 9c4330a96c0..a307b765097 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -1760,7 +1760,7 @@ SELECT COUNT(*) FROM mysql.general_log; Invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; RETURN 0; END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT INTO t1 SELECT func_sidef_1(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1769,13 +1769,12 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. Invoking function func_sidef_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); RETURN 0; END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT INTO t2 SELECT func_sidef_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1784,14 +1783,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP FUNCTION func_sidef_2; Invoking procedure proc_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_2() BEGIN INSERT INTO t1 SELECT func_sidef_1(); INSERT INTO ta2 VALUES (47); END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. CALL proc_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1800,14 +1798,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PROCEDURE proc_2; Invoking trigger trig_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT INTO trigger_table_2 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1816,7 +1813,6 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP TRIGGER trig_2; @@ -1830,8 +1826,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT INTO t2 SELECT * FROM view_sidef_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1840,14 +1835,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP VIEW view_sidef_2; Invoking prepared statement prep_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. EXECUTE prep_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1856,7 +1850,6 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_2; @@ -1864,7 +1857,7 @@ DROP FUNCTION func_sidef_1; Invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_1() BEGIN INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; INSERT INTO ta1 VALUES (47); END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. CALL proc_1(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1873,13 +1866,12 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. Invoking function func_sidef_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT INTO t2 SELECT func_sidef_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1888,14 +1880,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP FUNCTION func_sidef_2; Invoking procedure proc_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_2() BEGIN CALL proc_1(); INSERT INTO ta2 VALUES (47); END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. CALL proc_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1904,14 +1895,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PROCEDURE proc_2; Invoking trigger trig_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT INTO trigger_table_2 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1920,14 +1910,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP TRIGGER trig_2; Invoking prepared statement prep_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. PREPARE prep_2 FROM "CALL proc_1()"; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. EXECUTE prep_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1936,7 +1925,6 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_2; @@ -1944,7 +1932,7 @@ DROP PROCEDURE proc_1; Invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT INTO trigger_table_1 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1953,13 +1941,12 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. Invoking function func_sidef_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); RETURN 0; END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT INTO t2 SELECT func_sidef_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1968,14 +1955,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP FUNCTION func_sidef_2; Invoking procedure proc_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_2() BEGIN INSERT INTO trigger_table_1 VALUES (1); INSERT INTO ta2 VALUES (47); END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. CALL proc_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1984,14 +1970,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PROCEDURE proc_2; Invoking trigger trig_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT INTO trigger_table_2 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2000,14 +1985,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP TRIGGER trig_2; Invoking prepared statement prep_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. EXECUTE prep_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2016,7 +2000,6 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_2; @@ -2024,7 +2007,7 @@ DROP TRIGGER trig_1; Invoking prepared statement prep_1 invoking statement that is unsafe in many ways. PREPARE prep_1 FROM "INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1"; -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. EXECUTE prep_1; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2033,13 +2016,12 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_1; Invoking statement that is unsafe in many ways. -* binlog_format = STATEMENT: expect 7 warnings. +* binlog_format = STATEMENT: expect 6 warnings. INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2048,7 +2030,6 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test index 6b342f24ab5..040f57597c2 100644 --- a/mysql-test/suite/binlog/t/binlog_unsafe.test +++ b/mysql-test/suite/binlog/t/binlog_unsafe.test @@ -233,7 +233,7 @@ while ($unsafe_type < 9) { --let $value_0= --let $sel_sidef_0= --let $sel_retval_0= - --let $CRC_ARG_expected_number_of_warnings= 7 + --let $CRC_ARG_expected_number_of_warnings= 6 } if ($unsafe_type == 8) { diff --git a/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result b/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result index 1d378e2d864..62ff28e7159 100644 --- a/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result +++ b/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result @@ -1,6 +1,5 @@ include/master-slave.inc [connection master] -call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); drop database if exists test1; create database test1; use test1; diff --git a/mysql-test/suite/rpl/r/rpl_insert_id_pk.result b/mysql-test/suite/rpl/r/rpl_insert_id_pk.result index 467b8c1e5cc..c2d6d2c9b0c 100644 --- a/mysql-test/suite/rpl/r/rpl_insert_id_pk.result +++ b/mysql-test/suite/rpl/r/rpl_insert_id_pk.result @@ -1,6 +1,5 @@ include/master-slave.inc [connection master] -call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); create table t1(a int auto_increment, primary key(a)); create table t2(b int auto_increment, c int, primary key(b)); insert into t1 values (1),(2),(3); diff --git a/mysql-test/suite/rpl/r/rpl_multi_update.result b/mysql-test/suite/rpl/r/rpl_multi_update.result index 74fb7952a2a..8634e86afed 100644 --- a/mysql-test/suite/rpl/r/rpl_multi_update.result +++ b/mysql-test/suite/rpl/r/rpl_multi_update.result @@ -1,6 +1,5 @@ include/master-slave.inc [connection master] -call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); CREATE TABLE t1 ( a int unsigned not null auto_increment primary key, b int unsigned diff --git a/mysql-test/suite/rpl/r/rpl_multi_update2.result b/mysql-test/suite/rpl/r/rpl_multi_update2.result index 03ed5de473d..a3cab693322 100644 --- a/mysql-test/suite/rpl/r/rpl_multi_update2.result +++ b/mysql-test/suite/rpl/r/rpl_multi_update2.result @@ -1,6 +1,5 @@ include/master-slave.inc [connection master] -call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT'); drop table if exists t1,t2; CREATE TABLE t1 ( a int unsigned not null auto_increment primary key, diff --git a/mysql-test/suite/rpl/r/rpl_multi_update3.result b/mysql-test/suite/rpl/r/rpl_multi_update3.result index bf9946f219f..6b9ec5c3947 100644 --- a/mysql-test/suite/rpl/r/rpl_multi_update3.result +++ b/mysql-test/suite/rpl/r/rpl_multi_update3.result @@ -1,6 +1,5 @@ include/master-slave.inc [connection master] -call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); -------- Test for BUG#9361 -------- CREATE TABLE t1 ( diff --git a/mysql-test/suite/rpl/r/rpl_rotate_logs.result b/mysql-test/suite/rpl/r/rpl_rotate_logs.result index ef95103c7bc..ebc75ce9e6e 100644 --- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result +++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result @@ -1,4 +1,3 @@ -CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); start slave; Got one of the listed errors start slave; diff --git a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test index 1e5f9e53478..d1da69533ec 100644 --- a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test +++ b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test @@ -8,7 +8,6 @@ # Test supplied by Are Casilla source include/master-slave.inc; -call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); --disable_warnings connection master; drop database if exists test1; @@ -43,16 +42,12 @@ CREATE PROCEDURE simpleproc3 () $ DELIMITER ;$ ---disable_warnings CALL simpleproc3(); ---enable_warnings select * from t2; TRUNCATE TABLE `t1`; ---disable_warnings CALL simpleproc3(); ---enable_warnings select * from t1; diff --git a/mysql-test/suite/rpl/t/rpl_multi_update2.test b/mysql-test/suite/rpl/t/rpl_multi_update2.test index 138c1455952..497568f2738 100644 --- a/mysql-test/suite/rpl/t/rpl_multi_update2.test +++ b/mysql-test/suite/rpl/t/rpl_multi_update2.test @@ -6,7 +6,6 @@ ####################################################### --source include/not_ndb_default.inc --source include/master-slave.inc -call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT'); let $engine_type=MyISAM; --source extra/rpl_tests/rpl_multi_update2.test --source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_multi_update3.test b/mysql-test/suite/rpl/t/rpl_multi_update3.test index dc12d528c24..f6e70f14b30 100644 --- a/mysql-test/suite/rpl/t/rpl_multi_update3.test +++ b/mysql-test/suite/rpl/t/rpl_multi_update3.test @@ -6,7 +6,6 @@ ####################################################### --source include/not_ndb_default.inc --source include/master-slave.inc -call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); let $engine_type=MyISAM; -- source extra/rpl_tests/rpl_multi_update3.test --source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_optimize.test b/mysql-test/suite/rpl/t/rpl_optimize.test index df863e614a2..ad49df55db7 100644 --- a/mysql-test/suite/rpl/t/rpl_optimize.test +++ b/mysql-test/suite/rpl/t/rpl_optimize.test @@ -19,7 +19,6 @@ enable_query_log; create table t1 (a int not null auto_increment primary key, b int, key(b)); INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); ---disable_warnings INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; @@ -33,7 +32,6 @@ INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; ---enable_warnings save_master_pos; # a few updates to force OPTIMIZE to do something --disable_warnings diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test index 67079b9bea1..a1b4f367812 100644 --- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test +++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test @@ -27,7 +27,6 @@ EOF chmod 0000 $MYSQLD_SLAVE_DATADIR/master.info; connection slave; -CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); # START SLAVE will fail because it can't read the file (mode 000) # (system error 13) --replace_result $MYSQL_TEST_DIR TESTDIR diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test index bf622790fe7..cd73a84d569 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test @@ -52,10 +52,9 @@ SET GLOBAL event_scheduler = ON; replace_result $engine_type ENGINE_TYPE; eval CREATE TABLE t1 (i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f varchar(8)) ENGINE=$engine_type; INSERT INTO t1 (f) VALUES ('a'),('a'),('a'),('a'),('a'); ---disable_warnings INSERT INTO t1 SELECT i+5, f FROM t1; INSERT INTO t1 SELECT i+10, f FROM t1; ---enable_warnings + CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (SLEEP(5),CONCAT('ev1_',CONNECTION_ID())); CREATE EVENT ev2 ON SCHEDULE EVERY 1 SECOND diff --git a/mysql-test/suite/rpl/t/rpl_timezone.test b/mysql-test/suite/rpl/t/rpl_timezone.test index 1f0220421ab..7355106b6b4 100644 --- a/mysql-test/suite/rpl/t/rpl_timezone.test +++ b/mysql-test/suite/rpl/t/rpl_timezone.test @@ -13,14 +13,14 @@ # timezone used in CONVERT_TZ is not binlogged. To debug (by Guilhem # and possibly Konstantin). -source include/master-slave.inc; - --disable_query_log CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); --enable_query_log --disable_ps_protocol +source include/master-slave.inc; + # Save original timezone set @my_time_zone= @@global.time_zone; @@ -90,7 +90,6 @@ insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL); # from originally inserted) # set time_zone='MET'; ---disable_warnings ONCE insert into t2 (select * from t1); SELECT * FROM t1 ORDER BY n; sync_slave_with_master; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 99ffe278e44..4de574fbb0d 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -352,7 +352,6 @@ create table `t2` (`c2_id` int(10) unsigned NULL auto_increment, `c2_p_id` int(1 insert into t1 values (0,'A01-Comp',1); insert into t1 values (0,'B01-Comp',1); insert into t2 values (0,1,'A Note',1); ---disable_warnings ONCE update t1 left join t2 on p_id = c2_p_id set c2_note = 'asdf-1' where p_id = 2; select * from t1; select * from t2; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 4c525c5320e..e00bd785789 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1,6 +1,5 @@ -- source include/not_embedded.inc -- source include/have_log_bin.inc -call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); # # SQL Syntax for Prepared Statements test # @@ -433,7 +432,6 @@ deallocate prepare stmt; create table t1 (a int); insert into t1 values (1),(2),(3); create table t2 select * from t1; ---disable_warnings prepare stmt FROM 'create table t2 select * from t1'; drop table t2; execute stmt; @@ -443,7 +441,6 @@ execute stmt; execute stmt; drop table t2; execute stmt; ---enable_warnings drop table t1,t2; deallocate prepare stmt; @@ -1179,7 +1176,6 @@ create database mysqltest character set utf8; prepare stmt1 from "create table mysqltest.t1 (c char(10))"; prepare stmt2 from "create table mysqltest.t2 select 'test'"; execute stmt1; ---disable_warnings ONCE execute stmt2; show create table mysqltest.t1; show create table mysqltest.t2; @@ -1187,7 +1183,6 @@ drop table mysqltest.t1; drop table mysqltest.t2; alter database mysqltest character set latin1; execute stmt1; ---disable_warnings ONCE execute stmt2; show create table mysqltest.t1; show create table mysqltest.t2; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index d164f75d7d8..f5c96761da1 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6486,11 +6486,3 @@ ER_PLUGIN_NO_UNINSTALL ER_PLUGIN_NO_INSTALL eng "Plugin '%s' is marked as not dynamically installable. You have to stop the server to install it." - - -ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT - eng "Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave." - -ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC - eng "CREATE TABLE... SELECT... on a table with an auto-increment column is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are inserted. This order cannot be predicted and may differ on master and the slave." - diff --git a/sql/sql_base.cc b/sql/sql_base.cc index fda0ba61e63..e0472e2c9b5 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -214,8 +214,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list); static void free_cache_entry(TABLE *entry); static bool has_write_table_with_auto_increment(TABLE_LIST *tables); -static bool -has_write_table_with_auto_increment_and_select(TABLE_LIST *tables); + uint cached_open_tables(void) { @@ -5684,11 +5683,6 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, /* We have to emulate LOCK TABLES if we are statement needs prelocking. */ if (thd->lex->requires_prelocking()) { - - if (thd->variables.binlog_format != BINLOG_FORMAT_ROW && tables && - has_write_table_with_auto_increment_and_select(tables)) - thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT); - /* A query that modifies autoinc column in sub-statement can make the master and slave inconsistent. @@ -9086,39 +9080,6 @@ has_write_table_with_auto_increment(TABLE_LIST *tables) return 0; } -/* - checks if the tables have select tables in the table list and write tables - with auto-increment column. - - SYNOPSIS - has_two_write_locked_tables_with_auto_increment_and_select - tables Table list - - RETURN VALUES - - -true if the table list has atleast one table with auto-increment column - and atleast one table to select from. - -false otherwise -*/ - -static bool -has_write_table_with_auto_increment_and_select(TABLE_LIST *tables) -{ - bool has_select= false; - bool has_auto_increment_tables = has_write_table_with_auto_increment(tables); - for(TABLE_LIST *table= tables; table; table= table->next_global) - { - if (!table->placeholder() && - (table->lock_type <= TL_READ_NO_INSERT)) - { - has_select= true; - break; - } - } - return(has_select && has_auto_increment_tables); -} - - /* Open and lock system tables for read. diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 7598ddd3cdd..0cabab9fae7 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -61,11 +61,9 @@ Query_tables_list::binlog_stmt_unsafe_errcode[BINLOG_STMT_UNSAFE_COUNT] = ER_BINLOG_UNSAFE_MIXED_STATEMENT, ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT, ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE, - ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT, ER_BINLOG_UNSAFE_REPLACE_SELECT, ER_BINLOG_UNSAFE_CREATE_IGNORE_SELECT, ER_BINLOG_UNSAFE_CREATE_REPLACE_SELECT, - ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC, ER_BINLOG_UNSAFE_UPDATE_IGNORE }; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 1de92057b1f..8aaead811a0 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1268,13 +1268,6 @@ public: */ BINLOG_STMT_UNSAFE_INSERT_SELECT_UPDATE, - /** - Query that writes to a table with auto_inc column after selecting from - other tables are unsafe as the order in which the rows are retrieved by - select may differ on master and slave. - */ - BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT, - /** INSERT...REPLACE SELECT is unsafe because which rows are replaced depends on the order that rows are retrieved by SELECT. This order cannot be @@ -1296,14 +1289,6 @@ public: */ BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT, - /** - CREATE TABLE...SELECT on a table with auto-increment column is unsafe - because which rows are replaced depends on the order that rows are - retrieved from SELECT. This order cannot be predicted and may differ on - master and the slave - */ - BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC, - /** UPDATE...IGNORE is unsafe because which rows are ignored depends on the order that rows are updated. This order cannot be predicted and may differ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f26deb9a01a..a5d23858a8d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2414,12 +2414,9 @@ case SQLCOM_PREPARE: select_result *result; /* - - CREATE TABLE...IGNORE - - REPLACE SELECT... - - CREATE TABLE [with auto inc. column]...SELECT - can be unsafe, unless ORDER BY PRIMARY KEY clause is used in SELECT - statement. We therefore use row based logging if mixed or row based - logging is available. + CREATE TABLE...IGNORE/REPLACE SELECT... can be unsafe, unless + ORDER BY PRIMARY KEY clause is used in SELECT statement. We therefore + use row based logging if mixed or row based logging is available. TODO: Check if the order of the output of the select statement is deterministic. Waiting for BUG#42415 */ @@ -2429,9 +2426,6 @@ case SQLCOM_PREPARE: if(lex->duplicates == DUP_REPLACE) lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT); - if (lex->type & AUTO_INCREMENT_FLAG) - lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC); - /* If: a) we inside an SP and there was NAME_CONST substitution, From 31c990ca5766dfac05dc4c72d0b6022bf2d4556a Mon Sep 17 00:00:00 2001 From: Rohit Kalhans Date: Thu, 9 Feb 2012 23:28:33 +0530 Subject: [PATCH 03/16] 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 retrieved from the table may differ on master and slave. Solution: We mark writing to a table with auto_increment table based on the rows selected from another 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. sql/share/errmsg-utf8.txt: Added new warning messages. sql/sql_base.cc: -Created function to check statements that write to tables with auto_increment column and has select. -Marked all the statements that write to a table with auto_increment column based on rows fetched from other table(s) as unsafe. sql/sql_table.cc: mark CREATE TABLE[with auto_increment column] as unsafe. --- .../extra/rpl_tests/rpl_insert_id_pk.test | 3 + .../extra/rpl_tests/rpl_multi_update.test | 4 ++ .../extra/rpl_tests/rpl_multi_update2.test | 3 + .../extra/rpl_tests/rpl_multi_update3.test | 3 + mysql-test/r/ps.result | 1 + .../suite/binlog/r/binlog_unsafe.result | 55 +++++++++++++------ mysql-test/suite/binlog/t/binlog_unsafe.test | 2 +- .../rpl/r/rpl_auto_increment_11932.result | 1 + .../suite/rpl/r/rpl_insert_id_pk.result | 1 + .../suite/rpl/r/rpl_multi_update.result | 1 + .../suite/rpl/r/rpl_multi_update2.result | 1 + .../suite/rpl/r/rpl_multi_update3.result | 1 + mysql-test/suite/rpl/r/rpl_rotate_logs.result | 1 + .../suite/rpl/t/rpl_auto_increment_11932.test | 5 ++ mysql-test/suite/rpl/t/rpl_multi_update2.test | 1 + mysql-test/suite/rpl/t/rpl_multi_update3.test | 1 + mysql-test/suite/rpl/t/rpl_optimize.test | 2 + mysql-test/suite/rpl/t/rpl_rotate_logs.test | 1 + .../suite/rpl/t/rpl_semi_sync_event.test | 3 +- mysql-test/suite/rpl/t/rpl_timezone.test | 5 +- mysql-test/t/events_restart.test | 23 ++++++++ mysql-test/t/multi_update.test | 1 + mysql-test/t/ps.test | 7 +++ sql/share/errmsg-utf8.txt | 8 +++ sql/sql_base.cc | 49 ++++++++++++++++- sql/sql_lex.cc | 2 + sql/sql_lex.h | 15 +++++ sql/sql_table.cc | 9 +++ 28 files changed, 186 insertions(+), 23 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test index c3ecd9381c9..f6152180e7a 100644 --- a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test +++ b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test @@ -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; diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update.test b/mysql-test/extra/rpl_tests/rpl_multi_update.test index bf7707f9d6d..cdbdbc191d7 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_update.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_update.test @@ -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; diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update2.test b/mysql-test/extra/rpl_tests/rpl_multi_update2.test index ae4261c0516..b85927a2aed 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_update2.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_update2.test @@ -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; diff --git a/mysql-test/extra/rpl_tests/rpl_multi_update3.test b/mysql-test/extra/rpl_tests/rpl_multi_update3.test index 6c7a980aecb..f7d4815e9e5 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_update3.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_update3.test @@ -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; diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index afa105a39b8..310004de983 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1,3 +1,4 @@ +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); drop table if exists t1,t2,t3,t4; drop database if exists client_test_db; create table t1 diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index a307b765097..9c4330a96c0 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -1760,7 +1760,7 @@ SELECT COUNT(*) FROM mysql.general_log; Invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; RETURN 0; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t1 SELECT func_sidef_1(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1769,12 +1769,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. Invoking function func_sidef_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); RETURN 0; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t2 SELECT func_sidef_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1783,13 +1784,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP FUNCTION func_sidef_2; Invoking procedure proc_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_2() BEGIN INSERT INTO t1 SELECT func_sidef_1(); INSERT INTO ta2 VALUES (47); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. CALL proc_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1798,13 +1800,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PROCEDURE proc_2; Invoking trigger trig_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO trigger_table_2 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1813,6 +1816,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP TRIGGER trig_2; @@ -1826,7 +1830,8 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. -* binlog_format = STATEMENT: expect 6 warnings. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t2 SELECT * FROM view_sidef_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1835,13 +1840,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP VIEW view_sidef_2; Invoking prepared statement prep_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. EXECUTE prep_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1850,6 +1856,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_2; @@ -1857,7 +1864,7 @@ DROP FUNCTION func_sidef_1; Invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_1() BEGIN INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; INSERT INTO ta1 VALUES (47); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. CALL proc_1(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1866,12 +1873,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. Invoking function func_sidef_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t2 SELECT func_sidef_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1880,13 +1888,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP FUNCTION func_sidef_2; Invoking procedure proc_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_2() BEGIN CALL proc_1(); INSERT INTO ta2 VALUES (47); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. CALL proc_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1895,13 +1904,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PROCEDURE proc_2; Invoking trigger trig_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO trigger_table_2 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1910,13 +1920,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP TRIGGER trig_2; Invoking prepared statement prep_2 invoking procedure proc_1 invoking statement that is unsafe in many ways. PREPARE prep_2 FROM "CALL proc_1()"; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. EXECUTE prep_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1925,6 +1936,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_2; @@ -1932,7 +1944,7 @@ DROP PROCEDURE proc_1; Invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO trigger_table_1 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1941,12 +1953,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. Invoking function func_sidef_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); RETURN 0; END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO t2 SELECT func_sidef_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1955,13 +1968,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP FUNCTION func_sidef_2; Invoking procedure proc_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE PROCEDURE proc_2() BEGIN INSERT INTO trigger_table_1 VALUES (1); INSERT INTO ta2 VALUES (47); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. CALL proc_2(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1970,13 +1984,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PROCEDURE proc_2; Invoking trigger trig_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT INTO trigger_table_2 VALUES (1); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -1985,13 +2000,14 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP TRIGGER trig_2; Invoking prepared statement prep_2 invoking trigger trig_1 invoking statement that is unsafe in many ways. PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. EXECUTE prep_2; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2000,6 +2016,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_2; @@ -2007,7 +2024,7 @@ DROP TRIGGER trig_1; Invoking prepared statement prep_1 invoking statement that is unsafe in many ways. PREPARE prep_1 FROM "INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1"; -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. EXECUTE prep_1; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2016,12 +2033,13 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. DROP PREPARE prep_1; Invoking statement that is unsafe in many ways. -* binlog_format = STATEMENT: expect 6 warnings. +* binlog_format = STATEMENT: expect 7 warnings. INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2030,6 +2048,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a UDF which may not return the same value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave. Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. * SQL_LOG_BIN = 0: expect nothing logged and no warning. * binlog_format = MIXED: expect row events in binlog and no warning. diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test index 040f57597c2..6b342f24ab5 100644 --- a/mysql-test/suite/binlog/t/binlog_unsafe.test +++ b/mysql-test/suite/binlog/t/binlog_unsafe.test @@ -233,7 +233,7 @@ while ($unsafe_type < 9) { --let $value_0= --let $sel_sidef_0= --let $sel_retval_0= - --let $CRC_ARG_expected_number_of_warnings= 6 + --let $CRC_ARG_expected_number_of_warnings= 7 } if ($unsafe_type == 8) { diff --git a/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result b/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result index 62ff28e7159..1d378e2d864 100644 --- a/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result +++ b/mysql-test/suite/rpl/r/rpl_auto_increment_11932.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); drop database if exists test1; create database test1; use test1; diff --git a/mysql-test/suite/rpl/r/rpl_insert_id_pk.result b/mysql-test/suite/rpl/r/rpl_insert_id_pk.result index c2d6d2c9b0c..467b8c1e5cc 100644 --- a/mysql-test/suite/rpl/r/rpl_insert_id_pk.result +++ b/mysql-test/suite/rpl/r/rpl_insert_id_pk.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); create table t1(a int auto_increment, primary key(a)); create table t2(b int auto_increment, c int, primary key(b)); insert into t1 values (1),(2),(3); diff --git a/mysql-test/suite/rpl/r/rpl_multi_update.result b/mysql-test/suite/rpl/r/rpl_multi_update.result index 8634e86afed..74fb7952a2a 100644 --- a/mysql-test/suite/rpl/r/rpl_multi_update.result +++ b/mysql-test/suite/rpl/r/rpl_multi_update.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); CREATE TABLE t1 ( a int unsigned not null auto_increment primary key, b int unsigned diff --git a/mysql-test/suite/rpl/r/rpl_multi_update2.result b/mysql-test/suite/rpl/r/rpl_multi_update2.result index a3cab693322..03ed5de473d 100644 --- a/mysql-test/suite/rpl/r/rpl_multi_update2.result +++ b/mysql-test/suite/rpl/r/rpl_multi_update2.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT'); drop table if exists t1,t2; CREATE TABLE t1 ( a int unsigned not null auto_increment primary key, diff --git a/mysql-test/suite/rpl/r/rpl_multi_update3.result b/mysql-test/suite/rpl/r/rpl_multi_update3.result index 6b9ec5c3947..bf9946f219f 100644 --- a/mysql-test/suite/rpl/r/rpl_multi_update3.result +++ b/mysql-test/suite/rpl/r/rpl_multi_update3.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); -------- Test for BUG#9361 -------- CREATE TABLE t1 ( diff --git a/mysql-test/suite/rpl/r/rpl_rotate_logs.result b/mysql-test/suite/rpl/r/rpl_rotate_logs.result index ebc75ce9e6e..ef95103c7bc 100644 --- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result +++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result @@ -1,3 +1,4 @@ +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); start slave; Got one of the listed errors start slave; diff --git a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test index d1da69533ec..1e5f9e53478 100644 --- a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test +++ b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test @@ -8,6 +8,7 @@ # Test supplied by Are Casilla source include/master-slave.inc; +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); --disable_warnings connection master; drop database if exists test1; @@ -42,12 +43,16 @@ CREATE PROCEDURE simpleproc3 () $ DELIMITER ;$ +--disable_warnings CALL simpleproc3(); +--enable_warnings select * from t2; TRUNCATE TABLE `t1`; +--disable_warnings CALL simpleproc3(); +--enable_warnings select * from t1; diff --git a/mysql-test/suite/rpl/t/rpl_multi_update2.test b/mysql-test/suite/rpl/t/rpl_multi_update2.test index 497568f2738..138c1455952 100644 --- a/mysql-test/suite/rpl/t/rpl_multi_update2.test +++ b/mysql-test/suite/rpl/t/rpl_multi_update2.test @@ -6,6 +6,7 @@ ####################################################### --source include/not_ndb_default.inc --source include/master-slave.inc +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT'); let $engine_type=MyISAM; --source extra/rpl_tests/rpl_multi_update2.test --source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_multi_update3.test b/mysql-test/suite/rpl/t/rpl_multi_update3.test index f6e70f14b30..dc12d528c24 100644 --- a/mysql-test/suite/rpl/t/rpl_multi_update3.test +++ b/mysql-test/suite/rpl/t/rpl_multi_update3.test @@ -6,6 +6,7 @@ ####################################################### --source include/not_ndb_default.inc --source include/master-slave.inc +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); let $engine_type=MyISAM; -- source extra/rpl_tests/rpl_multi_update3.test --source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_optimize.test b/mysql-test/suite/rpl/t/rpl_optimize.test index ad49df55db7..df863e614a2 100644 --- a/mysql-test/suite/rpl/t/rpl_optimize.test +++ b/mysql-test/suite/rpl/t/rpl_optimize.test @@ -19,6 +19,7 @@ enable_query_log; create table t1 (a int not null auto_increment primary key, b int, key(b)); INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +--disable_warnings INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; @@ -32,6 +33,7 @@ INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; INSERT INTO t1 (a) SELECT null FROM t1; +--enable_warnings save_master_pos; # a few updates to force OPTIMIZE to do something --disable_warnings diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test index a1b4f367812..67079b9bea1 100644 --- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test +++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test @@ -27,6 +27,7 @@ EOF chmod 0000 $MYSQLD_SLAVE_DATADIR/master.info; connection slave; +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); # START SLAVE will fail because it can't read the file (mode 000) # (system error 13) --replace_result $MYSQL_TEST_DIR TESTDIR diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test index cd73a84d569..bf622790fe7 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_event.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_event.test @@ -52,9 +52,10 @@ SET GLOBAL event_scheduler = ON; replace_result $engine_type ENGINE_TYPE; eval CREATE TABLE t1 (i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f varchar(8)) ENGINE=$engine_type; INSERT INTO t1 (f) VALUES ('a'),('a'),('a'),('a'),('a'); +--disable_warnings INSERT INTO t1 SELECT i+5, f FROM t1; INSERT INTO t1 SELECT i+10, f FROM t1; - +--enable_warnings CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (SLEEP(5),CONCAT('ev1_',CONNECTION_ID())); CREATE EVENT ev2 ON SCHEDULE EVERY 1 SECOND diff --git a/mysql-test/suite/rpl/t/rpl_timezone.test b/mysql-test/suite/rpl/t/rpl_timezone.test index 7355106b6b4..1f0220421ab 100644 --- a/mysql-test/suite/rpl/t/rpl_timezone.test +++ b/mysql-test/suite/rpl/t/rpl_timezone.test @@ -13,14 +13,14 @@ # timezone used in CONVERT_TZ is not binlogged. To debug (by Guilhem # and possibly Konstantin). +source include/master-slave.inc; + --disable_query_log CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); --enable_query_log --disable_ps_protocol -source include/master-slave.inc; - # Save original timezone set @my_time_zone= @@global.time_zone; @@ -90,6 +90,7 @@ insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL); # from originally inserted) # set time_zone='MET'; +--disable_warnings ONCE insert into t2 (select * from t1); SELECT * FROM t1 ORDER BY n; sync_slave_with_master; diff --git a/mysql-test/t/events_restart.test b/mysql-test/t/events_restart.test index facf2912087..c6152e5d961 100644 --- a/mysql-test/t/events_restart.test +++ b/mysql-test/t/events_restart.test @@ -106,3 +106,26 @@ let $wait_condition= select count(*) = 0 from information_schema.processlist where db='events_test' and command = 'Connect' and user=current_user(); --source include/wait_condition.inc + +--echo # +--echo # Test for bug#11748899 -- EVENT SET TO DISABLED AND ON COMPLETION +--echo # NOT PRESERVE IS DELETED AT SERVER +--echo # +SELECT @@event_scheduler; +USE test; +--disable_warnings +DROP EVENT IF EXISTS e1; +--enable_warnings +CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DISABLE DO SELECT 1; +--replace_column 6 # 9 # 10 # +SHOW EVENTS; + +--echo "Now we restart the server" +--source include/restart_mysqld.inc +USE test; +SELECT @@event_scheduler; +--replace_column 6 # 9 # 10 # +SHOW EVENTS; +DROP EVENT e1; + +--echo # end test for bug#11748899 diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 4de574fbb0d..99ffe278e44 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -352,6 +352,7 @@ create table `t2` (`c2_id` int(10) unsigned NULL auto_increment, `c2_p_id` int(1 insert into t1 values (0,'A01-Comp',1); insert into t1 values (0,'B01-Comp',1); insert into t2 values (0,1,'A Note',1); +--disable_warnings ONCE update t1 left join t2 on p_id = c2_p_id set c2_note = 'asdf-1' where p_id = 2; select * from t1; select * from t2; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index e00bd785789..7fff7472caf 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1,5 +1,6 @@ -- source include/not_embedded.inc -- source include/have_log_bin.inc +call mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.'); # # SQL Syntax for Prepared Statements test # @@ -238,8 +239,10 @@ prepare stmt1 from "select 1 into @var"; execute stmt1; execute stmt1; prepare stmt1 from "create table t1 select 1 as i"; +--disable_warnings ONCE execute stmt1; drop table t1; +--disable_warnings ONCE execute stmt1; prepare stmt1 from "insert into t1 select i from t1"; execute stmt1; @@ -432,6 +435,7 @@ deallocate prepare stmt; create table t1 (a int); insert into t1 values (1),(2),(3); create table t2 select * from t1; +--disable_warnings prepare stmt FROM 'create table t2 select * from t1'; drop table t2; execute stmt; @@ -441,6 +445,7 @@ execute stmt; execute stmt; drop table t2; execute stmt; +--enable_warnings drop table t1,t2; deallocate prepare stmt; @@ -1176,6 +1181,7 @@ create database mysqltest character set utf8; prepare stmt1 from "create table mysqltest.t1 (c char(10))"; prepare stmt2 from "create table mysqltest.t2 select 'test'"; execute stmt1; +--disable_warnings ONCE execute stmt2; show create table mysqltest.t1; show create table mysqltest.t2; @@ -1183,6 +1189,7 @@ drop table mysqltest.t1; drop table mysqltest.t2; alter database mysqltest character set latin1; execute stmt1; +--disable_warnings ONCE execute stmt2; show create table mysqltest.t1; show create table mysqltest.t2; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index f5c96761da1..d164f75d7d8 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6486,3 +6486,11 @@ ER_PLUGIN_NO_UNINSTALL ER_PLUGIN_NO_INSTALL eng "Plugin '%s' is marked as not dynamically installable. You have to stop the server to install it." + + +ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT + eng "Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave." + +ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC + eng "CREATE TABLE... SELECT... on a table with an auto-increment column is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are inserted. This order cannot be predicted and may differ on master and the slave." + diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e0472e2c9b5..f4776130d2f 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -214,7 +214,8 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list); static void free_cache_entry(TABLE *entry); static bool has_write_table_with_auto_increment(TABLE_LIST *tables); - +static bool +has_write_table_with_auto_increment_and_select(TABLE_LIST *tables); uint cached_open_tables(void) { @@ -5683,6 +5684,17 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, /* We have to emulate LOCK TABLES if we are statement needs prelocking. */ if (thd->lex->requires_prelocking()) { + + /* + DML statements that modify a table with an auto_increment column based on + rows selected from a table are unsafe as the order in which the rows are + fetched fron the select tables cannot be determined and may differ on + master and slave. + */ + if (thd->variables.binlog_format != BINLOG_FORMAT_ROW && tables && + has_write_table_with_auto_increment_and_select(tables)) + thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT); + /* A query that modifies autoinc column in sub-statement can make the master and slave inconsistent. @@ -9080,6 +9092,41 @@ has_write_table_with_auto_increment(TABLE_LIST *tables) return 0; } +/* + checks if the tables have select tables in the table list and write tables + with auto-increment column. + + SYNOPSIS + has_two_write_locked_tables_with_auto_increment_and_select + tables Table list + + RETURN VALUES + + -true if the table list has atleast one table with auto-increment column + + + and atleast one table to select from. + -false otherwise +*/ + +static bool +has_write_table_with_auto_increment_and_select(TABLE_LIST *tables) +{ + bool has_select= false; + bool has_auto_increment_tables = has_write_table_with_auto_increment(tables); + for(TABLE_LIST *table= tables; table; table= table->next_global) + { + if (!table->placeholder() && + (table->lock_type <= TL_READ_NO_INSERT)) + { + has_select= true; + break; + } + } + return(has_select && has_auto_increment_tables); +} + + /* Open and lock system tables for read. diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 0cabab9fae7..7598ddd3cdd 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -61,9 +61,11 @@ Query_tables_list::binlog_stmt_unsafe_errcode[BINLOG_STMT_UNSAFE_COUNT] = ER_BINLOG_UNSAFE_MIXED_STATEMENT, ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT, ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE, + ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT, ER_BINLOG_UNSAFE_REPLACE_SELECT, ER_BINLOG_UNSAFE_CREATE_IGNORE_SELECT, ER_BINLOG_UNSAFE_CREATE_REPLACE_SELECT, + ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC, ER_BINLOG_UNSAFE_UPDATE_IGNORE }; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 8aaead811a0..1de92057b1f 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1268,6 +1268,13 @@ public: */ BINLOG_STMT_UNSAFE_INSERT_SELECT_UPDATE, + /** + Query that writes to a table with auto_inc column after selecting from + other tables are unsafe as the order in which the rows are retrieved by + select may differ on master and slave. + */ + BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT, + /** INSERT...REPLACE SELECT is unsafe because which rows are replaced depends on the order that rows are retrieved by SELECT. This order cannot be @@ -1289,6 +1296,14 @@ public: */ BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT, + /** + CREATE TABLE...SELECT on a table with auto-increment column is unsafe + because which rows are replaced depends on the order that rows are + retrieved from SELECT. This order cannot be predicted and may differ on + master and the slave + */ + BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC, + /** UPDATE...IGNORE is unsafe because which rows are ignored depends on the order that rows are updated. This order cannot be predicted and may differ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index be1e0d009a3..c7f454376e2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3121,6 +3121,15 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(TRUE); } + /* + CREATE TABLE[with auto_increment column] SELECT is unsafe as the rows + inserted in the created table depends on the order of the rows fetched + from the select tables. This order may differ on master and slave. We + therefore mark it as unsafe. + */ + if (select_field_count > 0 && auto_increment) + thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC); + /* Create keys */ List_iterator key_iterator(alter_info->key_list); From 93fa4604ee75beafb17acdf3052603f8877ed9c7 Mon Sep 17 00:00:00 2001 From: Rohit Kalhans Date: Fri, 10 Feb 2012 01:43:47 +0530 Subject: [PATCH 04/16] Followup patch for bug#11758263. --- mysql-test/t/events_restart.test | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/mysql-test/t/events_restart.test b/mysql-test/t/events_restart.test index c6152e5d961..83d28c0812d 100644 --- a/mysql-test/t/events_restart.test +++ b/mysql-test/t/events_restart.test @@ -107,25 +107,3 @@ let $wait_condition= where db='events_test' and command = 'Connect' and user=current_user(); --source include/wait_condition.inc ---echo # ---echo # Test for bug#11748899 -- EVENT SET TO DISABLED AND ON COMPLETION ---echo # NOT PRESERVE IS DELETED AT SERVER ---echo # -SELECT @@event_scheduler; -USE test; ---disable_warnings -DROP EVENT IF EXISTS e1; ---enable_warnings -CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DISABLE DO SELECT 1; ---replace_column 6 # 9 # 10 # -SHOW EVENTS; - ---echo "Now we restart the server" ---source include/restart_mysqld.inc -USE test; -SELECT @@event_scheduler; ---replace_column 6 # 9 # 10 # -SHOW EVENTS; -DROP EVENT e1; - ---echo # end test for bug#11748899 From 297002573cebf4806c57da8a457d814e948ddb09 Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Fri, 10 Feb 2012 12:47:42 +1100 Subject: [PATCH 05/16] BUG#12739098 - 62401: ASSERTION TRX->ERROR_STATE == DB_SUCCESS, QUE0QUE.C LINE 1264 ON TRUNCATE During FIC error handling the trx->error_state was not being set to DB_SUCCESS after failure, before attempting the next DDL SQL operation. This reset to DB_SUCCESS is somewhat of a requirement though not explicitly stated anywhere. The fix is to reset it to DB_SUCCESS in row0merge.cc if row_merge_rename_indexes or row_merge_drop_index functions fail, also reset to DB_SUCCESS at trx commit. rb://935 Approved by Jimmy Yang. --- storage/innodb_plugin/row/row0merge.c | 31 +++++++++++++++++++++------ storage/innodb_plugin/trx/trx0trx.c | 2 ++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/storage/innodb_plugin/row/row0merge.c b/storage/innodb_plugin/row/row0merge.c index 647d0031635..9e7dba552b5 100644 --- a/storage/innodb_plugin/row/row0merge.c +++ b/storage/innodb_plugin/row/row0merge.c @@ -2012,7 +2012,7 @@ row_merge_drop_index( tables in Innobase. Deleting a row from SYS_INDEXES table also frees the file segments of the B-tree associated with the index. */ - static const char str1[] = + static const char sql[] = "PROCEDURE DROP_INDEX_PROC () IS\n" "BEGIN\n" /* Rename the index, so that it will be dropped by @@ -2036,9 +2036,19 @@ row_merge_drop_index( ut_a(trx->dict_operation_lock_mode == RW_X_LATCH); - err = que_eval_sql(info, str1, FALSE, trx); + err = que_eval_sql(info, sql, FALSE, trx); - ut_a(err == DB_SUCCESS); + + if (err != DB_SUCCESS) { + /* Even though we ensure that DDL transactions are WAIT + and DEADLOCK free, we could encounter other errors e.g., + DB_TOO_MANY_TRANSACTIONS. */ + trx->error_state = DB_SUCCESS; + + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Error: row_merge_drop_index failed " + "with error code: %lu.\n", (ulint) err); + } /* Replace this index with another equivalent index for all foreign key constraints on this table where this index is used */ @@ -2290,7 +2300,7 @@ row_merge_rename_indexes( /* We use the private SQL parser of Innobase to generate the query graphs needed in renaming indexes. */ - static const char rename_indexes[] = + static const char sql[] = "PROCEDURE RENAME_INDEXES_PROC () IS\n" "BEGIN\n" "UPDATE SYS_INDEXES SET NAME=SUBSTR(NAME,1,LENGTH(NAME)-1)\n" @@ -2306,7 +2316,7 @@ row_merge_rename_indexes( pars_info_add_dulint_literal(info, "tableid", table->id); - err = que_eval_sql(info, rename_indexes, FALSE, trx); + err = que_eval_sql(info, sql, FALSE, trx); if (err == DB_SUCCESS) { dict_index_t* index = dict_table_get_first_index(table); @@ -2316,6 +2326,15 @@ row_merge_rename_indexes( } index = dict_table_get_next_index(index); } while (index); + } else { + /* Even though we ensure that DDL transactions are WAIT + and DEADLOCK free, we could encounter other errors e.g., + DB_TOO_MANY_TRANSACTIONS. */ + trx->error_state = DB_SUCCESS; + + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Error: row_merge_rename_indexes " + "failed with error code: %lu.\n", (ulint) err); } trx->op_info = ""; @@ -2354,7 +2373,7 @@ row_merge_rename_tables( memcpy(old_name, old_table->name, strlen(old_table->name) + 1); } else { ut_print_timestamp(stderr); - fprintf(stderr, "InnoDB: too long table name: '%s', " + fprintf(stderr, " InnoDB: too long table name: '%s', " "max length is %d\n", old_table->name, MAX_FULL_NAME_LEN); ut_error; diff --git a/storage/innodb_plugin/trx/trx0trx.c b/storage/innodb_plugin/trx/trx0trx.c index 7f3a3fcb4bf..80f079423fe 100644 --- a/storage/innodb_plugin/trx/trx0trx.c +++ b/storage/innodb_plugin/trx/trx0trx.c @@ -1008,6 +1008,8 @@ trx_commit_off_kernel( ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0); UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx); + + trx->error_state = DB_SUCCESS; } /****************************************************************//** From b566d9a512a9671a423e1ff944d1e4ede2df7f7e Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Fri, 10 Feb 2012 14:09:12 +1100 Subject: [PATCH 06/16] BUG#12739098 - 62401: ASSERTION TRX->ERROR_STATE == DB_SUCCESS, QUE0QUE.C LINE 1264 ON TRUNCATE During FIC error handling the trx->error_state was not being set to DB_SUCCESS after failure, before attempting the next DDL SQL operation. This reset to DB_SUCCESS is somewhat of a requirement though not explicitly stated anywhere. The fix is to reset it to DB_SUCCESS in row0merge.cc if row_merge_rename_indexes or row_merge_drop_index functions fail, also reset to DB_SUCCESS at trx commit. rb://935 Approved by Jimmy Yang. --- storage/innodb_plugin/row/row0merge.c | 31 +++++++++++++++++++++------ storage/innodb_plugin/trx/trx0trx.c | 2 ++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/storage/innodb_plugin/row/row0merge.c b/storage/innodb_plugin/row/row0merge.c index 8c18cfa078b..7f59d7cf9e9 100644 --- a/storage/innodb_plugin/row/row0merge.c +++ b/storage/innodb_plugin/row/row0merge.c @@ -2012,7 +2012,7 @@ row_merge_drop_index( tables in Innobase. Deleting a row from SYS_INDEXES table also frees the file segments of the B-tree associated with the index. */ - static const char str1[] = + static const char sql[] = "PROCEDURE DROP_INDEX_PROC () IS\n" "BEGIN\n" /* Rename the index, so that it will be dropped by @@ -2036,9 +2036,19 @@ row_merge_drop_index( ut_a(trx->dict_operation_lock_mode == RW_X_LATCH); - err = que_eval_sql(info, str1, FALSE, trx); + err = que_eval_sql(info, sql, FALSE, trx); - ut_a(err == DB_SUCCESS); + + if (err != DB_SUCCESS) { + /* Even though we ensure that DDL transactions are WAIT + and DEADLOCK free, we could encounter other errors e.g., + DB_TOO_MANY_TRANSACTIONS. */ + trx->error_state = DB_SUCCESS; + + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Error: row_merge_drop_index failed " + "with error code: %lu.\n", (ulint) err); + } /* Replace this index with another equivalent index for all foreign key constraints on this table where this index is used */ @@ -2290,7 +2300,7 @@ row_merge_rename_indexes( /* We use the private SQL parser of Innobase to generate the query graphs needed in renaming indexes. */ - static const char rename_indexes[] = + static const char sql[] = "PROCEDURE RENAME_INDEXES_PROC () IS\n" "BEGIN\n" "UPDATE SYS_INDEXES SET NAME=SUBSTR(NAME,1,LENGTH(NAME)-1)\n" @@ -2306,7 +2316,7 @@ row_merge_rename_indexes( pars_info_add_dulint_literal(info, "tableid", table->id); - err = que_eval_sql(info, rename_indexes, FALSE, trx); + err = que_eval_sql(info, sql, FALSE, trx); if (err == DB_SUCCESS) { dict_index_t* index = dict_table_get_first_index(table); @@ -2316,6 +2326,15 @@ row_merge_rename_indexes( } index = dict_table_get_next_index(index); } while (index); + } else { + /* Even though we ensure that DDL transactions are WAIT + and DEADLOCK free, we could encounter other errors e.g., + DB_TOO_MANY_TRANSACTIONS. */ + trx->error_state = DB_SUCCESS; + + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: Error: row_merge_rename_indexes " + "failed with error code: %lu.\n", (ulint) err); } trx->op_info = ""; @@ -2354,7 +2373,7 @@ row_merge_rename_tables( memcpy(old_name, old_table->name, strlen(old_table->name) + 1); } else { ut_print_timestamp(stderr); - fprintf(stderr, "InnoDB: too long table name: '%s', " + fprintf(stderr, " InnoDB: too long table name: '%s', " "max length is %d\n", old_table->name, MAX_FULL_NAME_LEN); ut_error; diff --git a/storage/innodb_plugin/trx/trx0trx.c b/storage/innodb_plugin/trx/trx0trx.c index 7f3a3fcb4bf..80f079423fe 100644 --- a/storage/innodb_plugin/trx/trx0trx.c +++ b/storage/innodb_plugin/trx/trx0trx.c @@ -1008,6 +1008,8 @@ trx_commit_off_kernel( ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0); UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx); + + trx->error_state = DB_SUCCESS; } /****************************************************************//** From 701cef2d35c700e8bef1735703a71c48a09c6238 Mon Sep 17 00:00:00 2001 From: Rohit Kalhans Date: Mon, 13 Feb 2012 14:12:13 +0530 Subject: [PATCH 07/16] BUG#11758263: Modification of indentation in the added code. Fixed a typo in the comment. Fixing test cases which were previouslyno throwing due disable warnings macro. sql/sql_base.cc: Change in indentation and fixing a typo in the comment. --- mysql-test/r/multi_update.result | 11 ++++++++-- .../suite/rpl/r/rpl_innodb_mixed_dml.result | 3 ++- .../rpl/r/rpl_known_bugs_detection.result | 2 ++ mysql-test/t/multi_update.test | 2 ++ sql/sql_base.cc | 22 +++++++++---------- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index c6ee170eef7..9b66ddb37b4 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -1,3 +1,4 @@ +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); drop table if exists t1,t2,t3; drop database if exists mysqltest; drop view if exists v1; @@ -125,6 +126,8 @@ ID ParId tst tst1 2 2 NULL NULL 3 3 NULL NULL UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. select * from t2; ID ParId tst tst1 1 1 MySQL MySQL AB @@ -349,6 +352,8 @@ drop table t1,t2; create table t1 (a int not null auto_increment primary key, b int not null); insert into t1 (b) values (1),(2),(3),(4); update t1, t1 as t2 set t1.b=t2.b+1 where t1.a=t2.a; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. select * from t1; a b 1 2 @@ -605,7 +610,8 @@ a b show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; UPDATE t2,t1 SET t2.a=t1.a+2 +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # COMMIT delete from t1; delete from t2; @@ -617,7 +623,8 @@ ERROR 23000: Duplicate entry '4' for key 'PRIMARY' show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # COMMIT drop table t1, t2; set @@session.binlog_format= @sav_binlog_format; diff --git a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result index d89bce479e5..193172912be 100644 --- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result +++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result @@ -861,7 +861,8 @@ master-bin.000001 # Table_map # # table_id: # (test_rpl.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t2 SELECT * FROM t1 +master-bin.000001 # Table_map # # table_id: # (test_rpl.t2) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test_rpl`; INSERT INTO t2 VALUES (1, 't1, text 1') ON DUPLICATE KEY UPDATE b = 't2, text 1' diff --git a/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result b/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result index 8ed402b9f8d..295ce7f5889 100644 --- a/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result +++ b/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result @@ -45,6 +45,7 @@ ON DUPLICATE KEY UPDATE t1.field_3 = t2.field_c; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... SELECT... ON DUPLICATE KEY UPDATE is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are updated. This order cannot be predicted and may differ on master and the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f'); INSERT INTO t1 (field_1, field_2, field_3) SELECT t2.field_a, t2.field_b, t2.field_c @@ -53,6 +54,7 @@ ON DUPLICATE KEY UPDATE t1.field_3 = t2.field_c; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... SELECT... ON DUPLICATE KEY UPDATE is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are updated. This order cannot be predicted and may differ on master and the slave. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. SELECT * FROM t1; id field_1 field_2 field_3 1 1 a 1a diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 99ffe278e44..6742b2c7b94 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -6,6 +6,8 @@ source include/not_embedded.inc; source include/have_log_bin.inc; +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); + --disable_warnings drop table if exists t1,t2,t3; drop database if exists mysqltest; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index f4776130d2f..c5b1ffb1fa9 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5681,20 +5681,20 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, *(ptr++)= table->table; } + /* + DML statements that modify a table with an auto_increment column based on + rows selected from a table are unsafe as the order in which the rows are + fetched fron the select tables cannot be determined and may differ on + master and slave. + */ + if (thd->variables.binlog_format != BINLOG_FORMAT_ROW && tables && + has_write_table_with_auto_increment_and_select(tables)) + thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT); + /* We have to emulate LOCK TABLES if we are statement needs prelocking. */ if (thd->lex->requires_prelocking()) { - /* - DML statements that modify a table with an auto_increment column based on - rows selected from a table are unsafe as the order in which the rows are - fetched fron the select tables cannot be determined and may differ on - master and slave. - */ - if (thd->variables.binlog_format != BINLOG_FORMAT_ROW && tables && - has_write_table_with_auto_increment_and_select(tables)) - thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT); - /* A query that modifies autoinc column in sub-statement can make the master and slave inconsistent. @@ -9093,7 +9093,7 @@ has_write_table_with_auto_increment(TABLE_LIST *tables) } /* - checks if the tables have select tables in the table list and write tables + checks if we have select tables in the table list and write tables with auto-increment column. SYNOPSIS From ba7d726c4812ebba43ad138d67b10e38f81b0b79 Mon Sep 17 00:00:00 2001 From: Rohit Kalhans Date: Mon, 13 Feb 2012 15:37:50 +0530 Subject: [PATCH 08/16] fixing test failure on pb2. --- mysql-test/r/multi_update.result | 4 ---- mysql-test/t/multi_update.test | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 9b66ddb37b4..3ea832852f6 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -126,8 +126,6 @@ ID ParId tst tst1 2 2 NULL NULL 3 3 NULL NULL UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id; -Warnings: -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. select * from t2; ID ParId tst tst1 1 1 MySQL MySQL AB @@ -352,8 +350,6 @@ drop table t1,t2; create table t1 (a int not null auto_increment primary key, b int not null); insert into t1 (b) values (1),(2),(3),(4); update t1, t1 as t2 set t1.b=t2.b+1 where t1.a=t2.a; -Warnings: -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave. select * from t1; a b 1 2 diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 6742b2c7b94..e5f5f5806ef 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -140,6 +140,7 @@ INSERT INTO t2(ParId) VALUES(1), (2), (3); select * from t2; +--disable_warnings ONCE UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id; select * from t2; @@ -297,6 +298,7 @@ drop table t1,t2; create table t1 (a int not null auto_increment primary key, b int not null); insert into t1 (b) values (1),(2),(3),(4); +--disable_warnings ONCE update t1, t1 as t2 set t1.b=t2.b+1 where t1.a=t2.a; select * from t1; drop table t1; From c3ef620d393353d0882d0383b392bf70ce95a65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 15 Feb 2012 15:53:29 +0200 Subject: [PATCH 09/16] store_create_info(): Fix a compiler warning about unused variable. --- sql/sql_show.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index da77bf329b1..7645868180d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1214,7 +1214,9 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, handler *file= table->file; TABLE_SHARE *share= table->s; HA_CREATE_INFO create_info; +#ifdef WITH_PARTITION_STORAGE_ENGINE bool show_table_options= FALSE; +#endif /* WITH_PARTITION_STORAGE_ENGINE */ bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL | MODE_ORACLE | MODE_MSSQL | @@ -1429,7 +1431,9 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, packet->append(STRING_WITH_LEN("\n)")); if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode) { +#ifdef WITH_PARTITION_STORAGE_ENGINE show_table_options= TRUE; +#endif /* WITH_PARTITION_STORAGE_ENGINE */ /* Get possible table space definitions and append them to the CREATE TABLE statement From 2a6a6abb70202e94eb0b6eec62f7bdde25d8a68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 15 Feb 2012 16:28:00 +0200 Subject: [PATCH 10/16] Remove a race condition in innodb_bug53756.test. Before killing the server, tell mysql-test-run that it is to be expected. Discussed with Bjorn Munch on IM. --- mysql-test/suite/innodb/t/innodb_bug53756.test | 6 +++--- mysql-test/suite/innodb_plugin/t/innodb_bug53756.test | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/innodb/t/innodb_bug53756.test b/mysql-test/suite/innodb/t/innodb_bug53756.test index 7a48f130b2c..04856d448cb 100644 --- a/mysql-test/suite/innodb/t/innodb_bug53756.test +++ b/mysql-test/suite/innodb/t/innodb_bug53756.test @@ -139,6 +139,9 @@ INSERT INTO bug_53756 VALUES (666,666); # Request a crash on next execution of commit. SET SESSION debug="+d,crash_commit_before"; # +# Write file to make mysql-test-run.pl start up the server again +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +# # Execute the statement that causes the crash. --error 2013 COMMIT; @@ -154,9 +157,6 @@ COMMIT; --echo # --echo # Restart server. # -# Write file to make mysql-test-run.pl start up the server again ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -# # Turn on reconnect --enable_reconnect # diff --git a/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test b/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test index 37a79ea3021..ba035fe0a46 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test +++ b/mysql-test/suite/innodb_plugin/t/innodb_bug53756.test @@ -139,6 +139,9 @@ INSERT INTO bug_53756 VALUES (666,666); # Request a crash on next execution of commit. SET SESSION debug="+d,crash_commit_before"; # +# Write file to make mysql-test-run.pl start up the server again +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +# # Execute the statement that causes the crash. --error 2013 COMMIT; @@ -154,9 +157,6 @@ COMMIT; --echo # --echo # Restart server. # -# Write file to make mysql-test-run.pl start up the server again ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -# # Turn on reconnect --enable_reconnect # From 7177a2b9d79122babf85cfe26c8fe8f9dbd06f1c Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 15 Feb 2012 17:13:47 +0100 Subject: [PATCH 11/16] Updated/added copyright headers --- client/sql_string.cc | 3 +-- include/heap.h | 2 +- include/m_string.h | 3 +-- myisam/ft_stopwords.c | 2 +- myisam/mi_preload.c | 3 +-- mysys/my_compare.c | 2 +- mysys/my_init.c | 3 +-- mysys/my_symlink.c | 3 +-- sql/item.cc | 3 +-- sql/item_strfunc.cc | 3 +-- sql/item_subselect.cc | 2 +- sql/item_sum.cc | 2 +- sql/my_decimal.h | 2 +- sql/sp_head.cc | 3 +-- sql/sql_class.cc | 3 +-- sql/sql_load.cc | 3 +-- sql/sql_select.cc | 2 +- sql/sql_string.cc | 3 +-- sql/sql_table.cc | 3 +-- sql/sql_view.cc | 3 +-- sql/unireg.h | 3 +-- strings/decimal.c | 3 +-- 22 files changed, 22 insertions(+), 37 deletions(-) diff --git a/client/sql_string.cc b/client/sql_string.cc index 0c89e1d0bca..246b5cd2c41 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -1,6 +1,5 @@ /* - Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/heap.h b/include/heap.h index 9d67c94e003..9a84b19f30b 100644 --- a/include/heap.h +++ b/include/heap.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/include/m_string.h b/include/m_string.h index 94de334a050..2d9033b7e95 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -1,5 +1,4 @@ -/* Copyright (c) 2000, 2001, 2003-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/myisam/ft_stopwords.c b/myisam/ft_stopwords.c index 72cbf6cc18a..03e96ce730c 100644 --- a/myisam/ft_stopwords.c +++ b/myisam/ft_stopwords.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index f53fcd2e1ee..d11c1856b2e 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2003, 2005, 2006 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_compare.c b/mysys/my_compare.c index c7037befd93..f58c081b1cc 100644 --- a/mysys/my_compare.c +++ b/mysys/my_compare.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_init.c b/mysys/my_init.c index 87ec253f983..a6b04276dd2 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2000-2007 MySQL AB, 2008 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c index fbf015512a3..8239f357d24 100644 --- a/mysys/my_symlink.c +++ b/mysys/my_symlink.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2001-2003, 2005, 2006, 2008 MySQL AB, 2008 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item.cc b/sql/item.cc index ad73a5d6f5a..538d2ceff17 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1,5 +1,4 @@ -/* Copyright (c) 2000-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index cd11cc3c34a..90291f4b8e6 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1,5 +1,4 @@ -/* Copyright (c) 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index db8d6b128a4..65ab147ca3c 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 56487e5fe7e..f902f0b6e90 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/my_decimal.h b/sql/my_decimal.h index ee023438f20..9100eab2ac2 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2006 MySQL AB +/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sp_head.cc b/sql/sp_head.cc index f2061454e1e..bf53578d69b 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1,5 +1,4 @@ -/* Copyright (c) 2002-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 9734629fd9c..bfa5cec940f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,5 +1,4 @@ -/* Copyright (c) 2000-2008 MySQL AB, 2009, 2010 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ad5334a906f..a6491e1bf49 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1,5 +1,4 @@ -/* Copyright (c) 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 86ff425d17b..42aa2f6c7fa 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 545643de49f..7049f50254f 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -1,5 +1,4 @@ -/* Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2bb758f8b86..c7fd637c5cf 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,5 +1,4 @@ -/* Copyright (c) 2000-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 3ae35e5cfe0..5fc357988da 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1,5 +1,4 @@ -/* Copyright (c) 2004-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/unireg.h b/sql/unireg.h index dd79de0781a..ccc8a353b3d 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -1,5 +1,4 @@ -/* Copyright (c) 2000-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/strings/decimal.c b/strings/decimal.c index 87faff9b4cd..3a86d0b5324 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2004-2008 MySQL AB, 2009 Sun Microsystems, Inc. - Use is subject to license terms. +/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 66b658720605482b5b98a827ed063a05a49318bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 16 Feb 2012 12:20:41 +0200 Subject: [PATCH 12/16] Correct a few copyright messages. --- storage/innodb_plugin/handler/ha_innodb.cc | 4 ++-- storage/innodb_plugin/include/log0log.h | 6 +++--- storage/innodb_plugin/include/mtr0mtr.h | 4 ++-- storage/innodb_plugin/log/log0log.c | 6 +++--- storage/innodb_plugin/mtr/mtr0mtr.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc index f23642d6af8..09094c0146e 100644 --- a/storage/innodb_plugin/handler/ha_innodb.cc +++ b/storage/innodb_plugin/handler/ha_innodb.cc @@ -26,8 +26,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ diff --git a/storage/innodb_plugin/include/log0log.h b/storage/innodb_plugin/include/log0log.h index 8fce4ef96bc..8c61244a38d 100644 --- a/storage/innodb_plugin/include/log0log.h +++ b/storage/innodb_plugin/include/log0log.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2010, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ diff --git a/storage/innodb_plugin/include/mtr0mtr.h b/storage/innodb_plugin/include/mtr0mtr.h index 8a9ec8ea7f0..46beb63ee80 100644 --- a/storage/innodb_plugin/include/mtr0mtr.h +++ b/storage/innodb_plugin/include/mtr0mtr.h @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ diff --git a/storage/innodb_plugin/log/log0log.c b/storage/innodb_plugin/log/log0log.c index 4bb9abdc1a4..28456e6b907 100644 --- a/storage/innodb_plugin/log/log0log.c +++ b/storage/innodb_plugin/log/log0log.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2010, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ diff --git a/storage/innodb_plugin/mtr/mtr0mtr.c b/storage/innodb_plugin/mtr/mtr0mtr.c index 5fad61b2922..1988bbabbf3 100644 --- a/storage/innodb_plugin/mtr/mtr0mtr.c +++ b/storage/innodb_plugin/mtr/mtr0mtr.c @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ From 4045c9976cf475b3f42f4133440c1d9a9060fb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 16 Feb 2012 12:24:11 +0200 Subject: [PATCH 13/16] Add instrumentation for Bug#13721257 RACE CONDITION IN UPDATES OR INSERTS OF WIDE RECORDS row_ins_index_entry_low(), row_upd_clust_rec(): Make a redo log checkpoint if a DEBUG flag is set. Add DEBUG_SYNC around btr_store_big_rec_extern_fields(). rb:946 approved by Jimmy Yang --- storage/innobase/row/row0ins.c | 11 +++++++++++ storage/innobase/row/row0upd.c | 10 +++++++++- storage/innodb_plugin/row/row0ins.c | 11 +++++++++++ storage/innodb_plugin/row/row0upd.c | 10 +++++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c index db134ca7a41..bb5c95a572b 100644 --- a/storage/innobase/row/row0ins.c +++ b/storage/innobase/row/row0ins.c @@ -6,6 +6,9 @@ Insert into a table Created 4/20/1996 Heikki Tuuri *******************************************************/ +#include "my_global.h" /* HAVE_* */ +#include "m_string.h" /* for my_sys.h */ +#include "my_sys.h" /* DEBUG_SYNC_C */ #include "row0ins.h" #ifdef UNIV_NONINL @@ -2121,16 +2124,24 @@ function_exit: if (big_rec) { rec_t* rec; + + DBUG_EXECUTE_IF( + "row_ins_extern_checkpoint", + log_make_checkpoint_at(ut_dulint_max, TRUE);); + mtr_start(&mtr); + DEBUG_SYNC_C("before_row_ins_extern_latch"); btr_cur_search_to_nth_level(index, 0, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, &cursor, 0, &mtr); rec = btr_cur_get_rec(&cursor); offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); + DEBUG_SYNC_C("before_row_ins_upd_extern"); err = btr_store_big_rec_extern_fields(index, rec, offsets, big_rec, &mtr); + DEBUG_SYNC_C("after_row_ins_upd_extern"); if (modify) { dtuple_big_rec_free(big_rec); diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c index 0790cfe02e2..d3ed71089a8 100644 --- a/storage/innobase/row/row0upd.c +++ b/storage/innobase/row/row0upd.c @@ -6,6 +6,9 @@ Update of a row Created 12/27/1996 Heikki Tuuri *******************************************************/ +#include "my_global.h" /* HAVE_* */ +#include "m_string.h" /* for my_sys.h */ +#include "my_sys.h" /* DEBUG_SYNC_C */ #include "row0upd.h" #ifdef UNIV_NONINL @@ -1591,15 +1594,20 @@ row_upd_clust_rec( rec_t* rec; *offsets_ = (sizeof offsets_) / sizeof *offsets_; - mtr_start(mtr); + DBUG_EXECUTE_IF( + "row_upd_extern_checkpoint", + log_make_checkpoint_at(ut_dulint_max, TRUE);); + mtr_start(mtr); ut_a(btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr)); rec = btr_cur_get_rec(btr_cur); + DEBUG_SYNC_C("before_row_upd_extern"); err = btr_store_big_rec_extern_fields( index, rec, rec_get_offsets(rec, index, offsets_, ULINT_UNDEFINED, &heap), big_rec, mtr); + DEBUG_SYNC_C("after_row_upd_extern"); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } diff --git a/storage/innodb_plugin/row/row0ins.c b/storage/innodb_plugin/row/row0ins.c index 2cbe1e13edc..939791aa19f 100644 --- a/storage/innodb_plugin/row/row0ins.c +++ b/storage/innodb_plugin/row/row0ins.c @@ -23,6 +23,9 @@ Insert into a table Created 4/20/1996 Heikki Tuuri *******************************************************/ +#include "my_global.h" /* HAVE_* */ +#include "m_string.h" /* for my_sys.h */ +#include "my_sys.h" /* DEBUG_SYNC_C */ #include "row0ins.h" #ifdef UNIV_NONINL @@ -2122,8 +2125,14 @@ function_exit: if (UNIV_LIKELY_NULL(big_rec)) { rec_t* rec; ulint* offsets; + + DBUG_EXECUTE_IF( + "row_ins_extern_checkpoint", + log_make_checkpoint_at(IB_ULONGLONG_MAX, TRUE);); + mtr_start(&mtr); + DEBUG_SYNC_C("before_row_ins_extern_latch"); btr_cur_search_to_nth_level(index, 0, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, &cursor, 0, __FILE__, __LINE__, &mtr); @@ -2131,9 +2140,11 @@ function_exit: offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap); + DEBUG_SYNC_C("before_row_ins_upd_extern"); err = btr_store_big_rec_extern_fields( index, btr_cur_get_block(&cursor), rec, offsets, &mtr, FALSE, big_rec); + DEBUG_SYNC_C("after_row_ins_upd_extern"); if (modify) { dtuple_big_rec_free(big_rec); diff --git a/storage/innodb_plugin/row/row0upd.c b/storage/innodb_plugin/row/row0upd.c index 072ca1d7b54..f03c120d6fb 100644 --- a/storage/innodb_plugin/row/row0upd.c +++ b/storage/innodb_plugin/row/row0upd.c @@ -23,6 +23,9 @@ Update of a row Created 12/27/1996 Heikki Tuuri *******************************************************/ +#include "my_global.h" /* HAVE_* */ +#include "m_string.h" /* for my_sys.h */ +#include "my_sys.h" /* DEBUG_SYNC_C */ #include "row0upd.h" #ifdef UNIV_NONINL @@ -1979,15 +1982,20 @@ row_upd_clust_rec( rec_t* rec; rec_offs_init(offsets_); - mtr_start(mtr); + DBUG_EXECUTE_IF( + "row_upd_extern_checkpoint", + log_make_checkpoint_at(IB_ULONGLONG_MAX, TRUE);); + mtr_start(mtr); ut_a(btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr)); rec = btr_cur_get_rec(btr_cur); + DEBUG_SYNC_C("before_row_upd_extern"); err = btr_store_big_rec_extern_fields( index, btr_cur_get_block(btr_cur), rec, rec_get_offsets(rec, index, offsets_, ULINT_UNDEFINED, &heap), mtr, TRUE, big_rec); + DEBUG_SYNC_C("after_row_upd_extern"); mtr_commit(mtr); } From 4fc7565ab7f1423c523d5868c7c37f14c9093c11 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Thu, 16 Feb 2012 11:35:30 +0100 Subject: [PATCH 14/16] Updated/added copyright headers --- sql/sql_show.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 7645868180d..2c85e29f985 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From e63d0c916bf36c1164143d05cc57a50b47827e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 16 Feb 2012 15:54:16 +0200 Subject: [PATCH 15/16] Fix link error on Windows. error LNK2001: unresolved external symbol _debug_sync_C_callback_ptr --- storage/innodb_plugin/row/row0ins.c | 12 +++++++++--- storage/innodb_plugin/row/row0upd.c | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/storage/innodb_plugin/row/row0ins.c b/storage/innodb_plugin/row/row0ins.c index 939791aa19f..56d1c1a7b88 100644 --- a/storage/innodb_plugin/row/row0ins.c +++ b/storage/innodb_plugin/row/row0ins.c @@ -23,9 +23,15 @@ Insert into a table Created 4/20/1996 Heikki Tuuri *******************************************************/ -#include "my_global.h" /* HAVE_* */ -#include "m_string.h" /* for my_sys.h */ -#include "my_sys.h" /* DEBUG_SYNC_C */ +#ifdef __WIN__ +/* error LNK2001: unresolved external symbol _debug_sync_C_callback_ptr */ +# define DEBUG_SYNC_C(dummy) ((void) 0) +#else +# include "my_global.h" /* HAVE_* */ +# include "m_string.h" /* for my_sys.h */ +# include "my_sys.h" /* DEBUG_SYNC_C */ +#endif + #include "row0ins.h" #ifdef UNIV_NONINL diff --git a/storage/innodb_plugin/row/row0upd.c b/storage/innodb_plugin/row/row0upd.c index f03c120d6fb..acd72ead42f 100644 --- a/storage/innodb_plugin/row/row0upd.c +++ b/storage/innodb_plugin/row/row0upd.c @@ -23,9 +23,15 @@ Update of a row Created 12/27/1996 Heikki Tuuri *******************************************************/ -#include "my_global.h" /* HAVE_* */ -#include "m_string.h" /* for my_sys.h */ -#include "my_sys.h" /* DEBUG_SYNC_C */ +#ifdef __WIN__ +/* error LNK2001: unresolved external symbol _debug_sync_C_callback_ptr */ +# define DEBUG_SYNC_C(dummy) ((void) 0) +#else +# include "my_global.h" /* HAVE_* */ +# include "m_string.h" /* for my_sys.h */ +# include "my_sys.h" /* DEBUG_SYNC_C */ +#endif + #include "row0upd.h" #ifdef UNIV_NONINL From 2837fba743733ced6a5e0beecb67eb307ed44bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 17 Feb 2012 09:18:53 +0200 Subject: [PATCH 16/16] Put back a fix that was reverted when reverting the buggy Bug#12612184 fix in revision-id inaam.rana@oracle.com-20110930110219-vnpaqghj9hm0grds (revno 3559). --- storage/innobase/include/buf0buf.ic | 8 ++++---- storage/innobase/include/sync0sync.h | 10 ++++++---- storage/innobase/sync/sync0rw.c | 10 ++++++---- storage/innobase/sync/sync0sync.c | 16 +++++++++++----- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index 99e55df3312..74cb57a8a8a 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -1251,7 +1251,7 @@ buf_block_dbg_add_level( where we have acquired latch */ ulint level) /*!< in: latching order level */ { - sync_thread_add_level(&block->lock, level); + sync_thread_add_level(&block->lock, level, FALSE); } #endif /* UNIV_SYNC_DEBUG */ /********************************************************************//** diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h index b5bf30e758c..9b07c4758c9 100644 --- a/storage/innobase/include/sync0sync.h +++ b/storage/innobase/include/sync0sync.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2011, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -400,8 +400,10 @@ void sync_thread_add_level( /*==================*/ void* latch, /*!< in: pointer to a mutex or an rw-lock */ - ulint level); /*!< in: level in the latching order; if + ulint level, /*!< in: level in the latching order; if SYNC_LEVEL_VARYING, nothing is done */ + ibool relock) /*!< in: TRUE if re-entering an x-lock */ + __attribute__((nonnull)); /******************************************************************//** Removes a latch from the thread level array if it is found there. @return TRUE if found in the array; it is no error if the latch is diff --git a/storage/innobase/sync/sync0rw.c b/storage/innobase/sync/sync0rw.c index fc4f987fe65..8de9b40ef67 100644 --- a/storage/innobase/sync/sync0rw.c +++ b/storage/innobase/sync/sync0rw.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -785,7 +785,9 @@ rw_lock_add_debug_info( rw_lock_debug_mutex_exit(); if ((pass == 0) && (lock_type != RW_LOCK_WAIT_EX)) { - sync_thread_add_level(lock, lock->level); + sync_thread_add_level(lock, lock->level, + lock_type == RW_LOCK_EX + && lock->lock_word < 0); } } diff --git a/storage/innobase/sync/sync0sync.c b/storage/innobase/sync/sync0sync.c index ea44589bdcf..8ce62d5ea45 100644 --- a/storage/innobase/sync/sync0sync.c +++ b/storage/innobase/sync/sync0sync.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2011, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -690,7 +690,7 @@ mutex_set_debug_info( ut_ad(mutex); ut_ad(file_name); - sync_thread_add_level(mutex, mutex->level); + sync_thread_add_level(mutex, mutex->level, FALSE); mutex->file_name = file_name; mutex->line = line; @@ -1133,8 +1133,9 @@ void sync_thread_add_level( /*==================*/ void* latch, /*!< in: pointer to a mutex or an rw-lock */ - ulint level) /*!< in: level in the latching order; if + ulint level, /*!< in: level in the latching order; if SYNC_LEVEL_VARYING, nothing is done */ + ibool relock) /*!< in: TRUE if re-entering an x-lock */ { ulint i; sync_level_t* slot; @@ -1185,6 +1186,10 @@ sync_thread_add_level( array = thread_slot->levels; + if (relock) { + goto levels_ok; + } + /* NOTE that there is a problem with _NODE and _LEAF levels: if the B-tree height changes, then a leaf can change to an internal node or the other way around. We do not know at present if this can cause @@ -1360,6 +1365,7 @@ sync_thread_add_level( ut_error; } +levels_ok: if (array->next_free == ULINT_UNDEFINED) { ut_a(array->n_elems < array->max_elems);