diff options
author | Alfranio Correia <alfranio.correia@sun.com> | 2009-12-17 21:43:35 +0000 |
---|---|---|
committer | Alfranio Correia <alfranio.correia@sun.com> | 2009-12-17 21:43:35 +0000 |
commit | 3dadf9564cbfd6e584db282b9105b8f5fb38f99b (patch) | |
tree | fb25bfc9b6c669b42e70afadf7790f0f8d7db7e3 /mysql-test/suite/binlog/r | |
parent | e852131f048df0c48d6779c40b23a347fbccc107 (diff) | |
parent | e83c9f627377f05e093f092cee227da1b43d8e94 (diff) | |
download | mariadb-git-3dadf9564cbfd6e584db282b9105b8f5fb38f99b.tar.gz |
merge mysql-5.1-rep+3 --> mysql-5.1-rep+2-delivery1
Diffstat (limited to 'mysql-test/suite/binlog/r')
19 files changed, 3269 insertions, 1196 deletions
diff --git a/mysql-test/suite/binlog/r/binlog_database.result b/mysql-test/suite/binlog/r/binlog_database.result index 1cc9281f3fc..c6fd37d39ee 100644 --- a/mysql-test/suite/binlog/r/binlog_database.result +++ b/mysql-test/suite/binlog/r/binlog_database.result @@ -29,9 +29,13 @@ show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create temporary table tt1 (a int) master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values (1) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # drop database if exists mysqltest1 +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values (1) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; drop table tt1, t1 FLUSH STATUS; set binlog_format=mixed; @@ -65,9 +69,13 @@ show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create temporary table tt1 (a int) master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values (1) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # drop database if exists mysqltest1 +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values (1) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; drop table tt1, t1 FLUSH STATUS; set binlog_format=row; diff --git a/mysql-test/suite/binlog/r/binlog_innodb.result b/mysql-test/suite/binlog/r/binlog_innodb.result index 424f7d60829..c6d7b527f4c 100644 --- a/mysql-test/suite/binlog/r/binlog_innodb.result +++ b/mysql-test/suite/binlog/r/binlog_innodb.result @@ -14,12 +14,12 @@ SET BINLOG_FORMAT=STATEMENT; BEGIN; SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; UPDATE t1 SET b = 1*a WHERE a > 1; -ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-UNCOMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT' +ERROR HY000: Cannot execute statement: binlogging impossible since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED. COMMIT; BEGIN; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; UPDATE t1 SET b = 2*a WHERE a > 2; -ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT' +ERROR HY000: Cannot execute statement: binlogging impossible since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED. COMMIT; BEGIN; SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; diff --git a/mysql-test/suite/binlog/r/binlog_killed.result b/mysql-test/suite/binlog/r/binlog_killed.result index 72fda535b6f..905c94a2e9e 100644 --- a/mysql-test/suite/binlog/r/binlog_killed.result +++ b/mysql-test/suite/binlog/r/binlog_killed.result @@ -1,3 +1,4 @@ +call mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT"); create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM; create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; @@ -87,8 +88,10 @@ select @b /* must be 1 at the end of a stmt calling bug27563() */; must have the update query event more to FD show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # User var # # @`b`=0 master-bin.000001 # Query # # use `test`; update t4 set b=b + bug27563(b) +master-bin.000001 # Query # # COMMIT select (@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) is not null; @@ -123,8 +126,10 @@ select @b /* must be 1 at the end of a stmt calling bug27563() */; must have the delete query event more to FD show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # User var # # @`b`=0 master-bin.000001 # Query # # use `test`; delete from t4 where b=bug27563(1) or b=bug27563(2) +master-bin.000001 # Query # # COMMIT select (@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) is not null; diff --git a/mysql-test/suite/binlog/r/binlog_killed_simulate.result b/mysql-test/suite/binlog/r/binlog_killed_simulate.result index df04f5129cf..6b2f7c8a30f 100644 --- a/mysql-test/suite/binlog/r/binlog_killed_simulate.result +++ b/mysql-test/suite/binlog/r/binlog_killed_simulate.result @@ -18,8 +18,10 @@ load data infile '../../std_data/rpl_loaddata.dat' into table t2 /* will be "kil ERROR 70100: Query execution was interrupted show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=# master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t2` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (a, b) ;file_id=# +master-bin.000001 # Query # # COMMIT select (@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) is not null; diff --git a/mysql-test/suite/binlog/r/binlog_mixed_failure_mixing_engines.result b/mysql-test/suite/binlog/r/binlog_mixed_failure_mixing_engines.result deleted file mode 100644 index dfc08d76a6a..00000000000 --- a/mysql-test/suite/binlog/r/binlog_mixed_failure_mixing_engines.result +++ /dev/null @@ -1,406 +0,0 @@ -################################################################################### -# CONFIGURATION -################################################################################### -CREATE TABLE nt_1 (a text, b int PRIMARY KEY) ENGINE = MyISAM; -CREATE TABLE nt_2 (a text, b int PRIMARY KEY) ENGINE = MyISAM; -CREATE TABLE tt_1 (a text, b int PRIMARY KEY) ENGINE = Innodb; -CREATE TABLE tt_2 (a text, b int PRIMARY KEY) ENGINE = Innodb; -CREATE TRIGGER tr_i_tt_1_to_nt_1 BEFORE INSERT ON tt_1 FOR EACH ROW -BEGIN -INSERT INTO nt_1 VALUES (NEW.a, NEW.b); -END| -CREATE TRIGGER tr_i_nt_2_to_tt_2 BEFORE INSERT ON nt_2 FOR EACH ROW -BEGIN -INSERT INTO tt_2 VALUES (NEW.a, NEW.b); -END| -################################################################################### -# CHECK HISTORY IN BINLOG -################################################################################### - - - -*** "B M* T C" with error in M* generates in the binlog the "B M* R B T C" entries - -INSERT INTO nt_1 VALUES ("new text 1", 1); -BEGIN; -INSERT INTO tt_1 VALUES (USER(), 2), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 3", 3); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 1", 1) -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 3", 3) -master-bin.000001 # Xid # # COMMIT /* XID */ - -INSERT INTO tt_2 VALUES ("new text 4", 4); -BEGIN; -INSERT INTO nt_2 VALUES (USER(), 5), (USER(), 4); -ERROR 23000: Duplicate entry '4' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 6", 6); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 4", 4) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 6", 6) -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B M M* T C" with error in M* generates in the binlog the "B M M* T C" entries - -INSERT INTO nt_1 VALUES ("new text 10", 10); -BEGIN; -INSERT INTO tt_1 VALUES ("new text 7", 7), ("new text 8", 8); -INSERT INTO tt_1 VALUES (USER(), 9), (USER(), 10); -ERROR 23000: Duplicate entry '10' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 11", 11); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 10", 10) -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 7", 7), ("new text 8", 8) -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 11", 11) -master-bin.000001 # Xid # # COMMIT /* XID */ - -INSERT INTO tt_2 VALUES ("new text 15", 15); -BEGIN; -INSERT INTO nt_2 VALUES ("new text 12", 12), ("new text 13", 13); -INSERT INTO nt_2 VALUES (USER(), 14), (USER(), 15); -ERROR 23000: Duplicate entry '15' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 16", 16); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 15", 15) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text 12", 12), ("new text 13", 13) -master-bin.000001 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 16", 16) -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B M* M* T C" with error in M* generates in the binlog the "B M* R B M* R B T C" entries - -INSERT INTO nt_1 VALUES ("new text 18", 18); -INSERT INTO nt_1 VALUES ("new text 20", 20); -BEGIN; -INSERT INTO tt_1 VALUES (USER(), 17), (USER(), 18); -ERROR 23000: Duplicate entry '18' for key 'PRIMARY' -INSERT INTO tt_1 VALUES (USER(), 19), (USER(), 20); -ERROR 23000: Duplicate entry '20' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 21", 21); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 18", 18) -master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 20", 20) -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 21", 21) -master-bin.000001 # Xid # # COMMIT /* XID */ - -INSERT INTO tt_2 VALUES ("new text 23", 23); -INSERT INTO tt_2 VALUES ("new text 25", 25); -BEGIN; -INSERT INTO nt_2 VALUES (USER(), 22), (USER(), 23); -ERROR 23000: Duplicate entry '23' for key 'PRIMARY' -INSERT INTO nt_2 VALUES (USER(), 24), (USER(), 25); -ERROR 23000: Duplicate entry '25' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 26", 26); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 23", 23) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 25", 25) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 26", 26) -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B T INSERT M...SELECT* C" with an error in INSERT M...SELECT* generates -*** in the binlog the following entries: "Nothing". -*** There is a bug in that will be fixed after WL#2687. Please, check BUG#47175 for further details. - -TRUNCATE TABLE nt_2; -TRUNCATE TABLE tt_2; -INSERT INTO tt_2 VALUES ("new text 7", 7); -BEGIN; -INSERT INTO tt_2 VALUES ("new text 27", 27); -INSERT INTO nt_2(a, b) SELECT USER(), b FROM nt_1; -ERROR 23000: Duplicate entry '7' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 28", 28); -ROLLBACK; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE nt_2 -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE tt_2 -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 7", 7) -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B INSERT M..SELECT* C" with an error in INSERT M...SELECT* generates -*** in the binlog the following entries: "B INSERT M..SELECT* R". - -TRUNCATE TABLE nt_2; -TRUNCATE TABLE tt_2; -INSERT INTO tt_2 VALUES ("new text 7", 7); -BEGIN; -INSERT INTO nt_2(a, b) SELECT USER(), b FROM nt_1; -ERROR 23000: Duplicate entry '7' for key 'PRIMARY' -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE nt_2 -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE tt_2 -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 7", 7) -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK - - - -*** "B N N T C" generates in the binlog the "B N C B N C B T C" entries - -TRUNCATE TABLE nt_1; -TRUNCATE TABLE tt_2; -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 1); -INSERT INTO nt_1 VALUES (USER(), 2); -INSERT INTO tt_2 VALUES (USER(), 3); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE nt_1 -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE tt_2 -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B N N T R" generates in the binlog the "B N C B N C B T R" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 4); -INSERT INTO nt_1 VALUES (USER(), 5); -INSERT INTO tt_2 VALUES (USER(), 6); -ROLLBACK; -Warnings: -Warning 1196 Some non-transactional changed tables couldn't be rolled back -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK - - - -*** "B N* N* T C" with error in N* generates in the binlog the "B N R B N R B T C" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 7), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO nt_1 VALUES (USER(), 8), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO tt_2 VALUES (USER(), 9); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B N* N* T R" with error in N* generates in the binlog the "B N R B N R B T R" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 10), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO nt_1 VALUES (USER(), 11), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO tt_2 VALUES (USER(), 12); -ROLLBACK; -Warnings: -Warning 1196 Some non-transactional changed tables couldn't be rolled back -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK - - - -*** "B N N T N T C" generates in the binlog the "B N C B N C B T N T C" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 13); -INSERT INTO nt_1 VALUES (USER(), 14); -INSERT INTO tt_2 VALUES (USER(), 15); -INSERT INTO nt_1 VALUES (USER(), 16); -INSERT INTO tt_2 VALUES (USER(), 17); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B N N T N T R" generates in the binlog the "B N C B N C B T N T R" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 18); -INSERT INTO nt_1 VALUES (USER(), 19); -INSERT INTO tt_2 VALUES (USER(), 20); -INSERT INTO nt_1 VALUES (USER(), 21); -INSERT INTO tt_2 VALUES (USER(), 22); -ROLLBACK; -Warnings: -Warning 1196 Some non-transactional changed tables couldn't be rolled back -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -################################################################################### -# CLEAN -################################################################################### -DROP TABLE tt_1; -DROP TABLE tt_2; -DROP TABLE nt_1; -DROP TABLE nt_2; diff --git a/mysql-test/suite/binlog/r/binlog_multi_engine.result b/mysql-test/suite/binlog/r/binlog_multi_engine.result index 9252229903b..eee83183575 100644 --- a/mysql-test/suite/binlog/r/binlog_multi_engine.result +++ b/mysql-test/suite/binlog/r/binlog_multi_engine.result @@ -1,3 +1,4 @@ +call mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT"); CREATE TABLE t1m (m INT, n INT) ENGINE=MYISAM; CREATE TABLE t1b (b INT, c INT) ENGINE=BLACKHOLE; CREATE TABLE t1n (e INT, f INT) ENGINE=NDB; @@ -6,10 +7,15 @@ SET SESSION BINLOG_FORMAT=STATEMENT; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2); INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2); UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. +The last event before the COMMIT is use `test`; UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c *** Please look in binlog_multi_engine.test if you have a diff here **** START TRANSACTION; INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2); UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c; COMMIT; TRUNCATE t1m; @@ -20,8 +26,12 @@ Log_name Pos Event_type Server_id End_log_pos Info mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2) mysqld-bin.000001 # Query # # COMMIT +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2) +mysqld-bin.000001 # Query # # COMMIT +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c +mysqld-bin.000001 # Query # # COMMIT mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2) mysqld-bin.000001 # Query # # use `test`; UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f @@ -39,10 +49,11 @@ RESET MASTER; SET SESSION BINLOG_FORMAT=MIXED; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2); INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2); +The last event before the COMMIT is use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2) INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2); UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c; UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f; -ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging +ERROR HY000: Cannot execute statement: binlogging impossible since more than one engine is involved and at least one engine is self-logging. TRUNCATE t1m; TRUNCATE t1b; TRUNCATE t1n; @@ -51,14 +62,15 @@ Log_name Pos Event_type Server_id End_log_pos Info mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2) mysqld-bin.000001 # Query # # COMMIT +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2) +mysqld-bin.000001 # Query # # COMMIT mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Table_map # # table_id: # (test.t1n) mysqld-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) mysqld-bin.000001 # Write_rows # # table_id: # mysqld-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F mysqld-bin.000001 # Query # # COMMIT -mysqld-bin.000001 # Query # # use `test`; UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c mysqld-bin.000001 # Query # # use `test`; TRUNCATE t1m mysqld-bin.000001 # Query # # use `test`; TRUNCATE t1b mysqld-bin.000001 # Query # # use `test`; TRUNCATE t1n @@ -68,9 +80,9 @@ INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2); INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2); INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2); UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f; -ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging +ERROR HY000: Cannot execute statement: binlogging impossible since more than one engine is involved and at least one engine is self-logging. UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c; -ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging +ERROR HY000: Cannot execute statement: binlogging impossible since more than one engine is involved and at least one engine is self-logging. show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info mysqld-bin.000001 # Query # # BEGIN diff --git a/mysql-test/suite/binlog/r/binlog_row_failure_mixing_engines.result b/mysql-test/suite/binlog/r/binlog_row_failure_mixing_engines.result deleted file mode 100644 index 45c8640d3e3..00000000000 --- a/mysql-test/suite/binlog/r/binlog_row_failure_mixing_engines.result +++ /dev/null @@ -1,440 +0,0 @@ -################################################################################### -# CONFIGURATION -################################################################################### -CREATE TABLE nt_1 (a text, b int PRIMARY KEY) ENGINE = MyISAM; -CREATE TABLE nt_2 (a text, b int PRIMARY KEY) ENGINE = MyISAM; -CREATE TABLE tt_1 (a text, b int PRIMARY KEY) ENGINE = Innodb; -CREATE TABLE tt_2 (a text, b int PRIMARY KEY) ENGINE = Innodb; -CREATE TRIGGER tr_i_tt_1_to_nt_1 BEFORE INSERT ON tt_1 FOR EACH ROW -BEGIN -INSERT INTO nt_1 VALUES (NEW.a, NEW.b); -END| -CREATE TRIGGER tr_i_nt_2_to_tt_2 BEFORE INSERT ON nt_2 FOR EACH ROW -BEGIN -INSERT INTO tt_2 VALUES (NEW.a, NEW.b); -END| -################################################################################### -# CHECK HISTORY IN BINLOG -################################################################################### - - - -*** "B M* T C" with error in M* generates in the binlog the "B M* R B T C" entries - -INSERT INTO nt_1 VALUES ("new text 1", 1); -BEGIN; -INSERT INTO tt_1 VALUES (USER(), 2), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 3", 3); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - -INSERT INTO tt_2 VALUES ("new text 4", 4); -BEGIN; -INSERT INTO nt_2 VALUES (USER(), 5), (USER(), 4); -ERROR 23000: Duplicate entry '4' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 6", 6); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -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 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B M M* T C" with error in M* generates in the binlog the "B M M* T C" entries - -INSERT INTO nt_1 VALUES ("new text 10", 10); -BEGIN; -INSERT INTO tt_1 VALUES ("new text 7", 7), ("new text 8", 8); -INSERT INTO tt_1 VALUES (USER(), 9), (USER(), 10); -ERROR 23000: Duplicate entry '10' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 11", 11); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - -INSERT INTO tt_2 VALUES ("new text 15", 15); -BEGIN; -INSERT INTO nt_2 VALUES ("new text 12", 12), ("new text 13", 13); -INSERT INTO nt_2 VALUES (USER(), 14), (USER(), 15); -ERROR 23000: Duplicate entry '15' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 16", 16); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -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 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B M* M* T C" with error in M* generates in the binlog the "B M* R B M* R B T C" entries - -INSERT INTO nt_1 VALUES ("new text 18", 18); -INSERT INTO nt_1 VALUES ("new text 20", 20); -BEGIN; -INSERT INTO tt_1 VALUES (USER(), 17), (USER(), 18); -ERROR 23000: Duplicate entry '18' for key 'PRIMARY' -INSERT INTO tt_1 VALUES (USER(), 19), (USER(), 20); -ERROR 23000: Duplicate entry '20' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 21", 21); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_1) -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - -INSERT INTO tt_2 VALUES ("new text 23", 23); -INSERT INTO tt_2 VALUES ("new text 25", 25); -BEGIN; -INSERT INTO nt_2 VALUES (USER(), 22), (USER(), 23); -ERROR 23000: Duplicate entry '23' for key 'PRIMARY' -INSERT INTO nt_2 VALUES (USER(), 24), (USER(), 25); -ERROR 23000: Duplicate entry '25' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 26", 26); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -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 # Table_map # # table_id: # (test.tt_2) -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 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B T INSERT M...SELECT* C" with an error in INSERT M...SELECT* generates -*** in the binlog the following entries: "Nothing". -*** There is a bug in that will be fixed after WL#2687. Please, check BUG#47175 for further details. - -TRUNCATE TABLE nt_2; -TRUNCATE TABLE tt_2; -INSERT INTO tt_2 VALUES ("new text 7", 7); -BEGIN; -INSERT INTO tt_2 VALUES ("new text 27", 27); -INSERT INTO nt_2(a, b) SELECT USER(), b FROM nt_1; -ERROR 23000: Duplicate entry '7' for key 'PRIMARY' -INSERT INTO tt_2 VALUES ("new text 28", 28); -ROLLBACK; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE nt_2 -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE tt_2 -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B INSERT M..SELECT* C" with an error in INSERT M...SELECT* generates -*** in the binlog the following entries: "B INSERT M..SELECT* R". - -TRUNCATE TABLE nt_2; -TRUNCATE TABLE tt_2; -INSERT INTO tt_2 VALUES ("new text 7", 7); -BEGIN; -INSERT INTO nt_2(a, b) SELECT USER(), b FROM nt_1; -ERROR 23000: Duplicate entry '7' for key 'PRIMARY' -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE nt_2 -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE tt_2 -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -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 # Table_map # # table_id: # (test.nt_2) -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK - - - -*** "B N N T C" generates in the binlog the "B N C B N C B T C" entries - -TRUNCATE TABLE nt_1; -TRUNCATE TABLE tt_2; -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 1); -INSERT INTO nt_1 VALUES (USER(), 2); -INSERT INTO tt_2 VALUES (USER(), 3); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE nt_1 -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; TRUNCATE TABLE tt_2 -master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B N N T R" generates in the binlog the "B N C B N C B T R" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 4); -INSERT INTO nt_1 VALUES (USER(), 5); -INSERT INTO tt_2 VALUES (USER(), 6); -ROLLBACK; -Warnings: -Warning 1196 Some non-transactional changed tables couldn't be rolled back -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK - - - -*** "B N* N* T C" with error in N* generates in the binlog the "B N R B N R B T C" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 7), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO nt_1 VALUES (USER(), 8), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO tt_2 VALUES (USER(), 9); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B N* N* T R" with error in N* generates in the binlog the "B N R B N R B T R" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 10), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO nt_1 VALUES (USER(), 11), (USER(), 1); -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -INSERT INTO tt_2 VALUES (USER(), 12); -ROLLBACK; -Warnings: -Warning 1196 Some non-transactional changed tables couldn't be rolled back -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK - - - -*** "B N N T N T C" generates in the binlog the "B N C B N C B T N T C" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 13); -INSERT INTO nt_1 VALUES (USER(), 14); -INSERT INTO tt_2 VALUES (USER(), 15); -INSERT INTO nt_1 VALUES (USER(), 16); -INSERT INTO tt_2 VALUES (USER(), 17); -COMMIT; -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Xid # # COMMIT /* XID */ - - - -*** "B N N T N T R" generates in the binlog the "B N C B N C B T N T R" entries - -BEGIN; -INSERT INTO nt_1 VALUES (USER(), 18); -INSERT INTO nt_1 VALUES (USER(), 19); -INSERT INTO tt_2 VALUES (USER(), 20); -INSERT INTO nt_1 VALUES (USER(), 21); -INSERT INTO tt_2 VALUES (USER(), 22); -ROLLBACK; -Warnings: -Warning 1196 Some non-transactional changed tables couldn't be rolled back -show binlog events from <binlog_start>; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.nt_1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.tt_2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK -################################################################################### -# CLEAN -################################################################################### -DROP TABLE tt_1; -DROP TABLE tt_2; -DROP TABLE nt_1; -DROP TABLE nt_2; diff --git a/mysql-test/suite/binlog/r/binlog_row_insert_select.result b/mysql-test/suite/binlog/r/binlog_row_insert_select.result index c7386b092e4..214a77dd36b 100644 --- a/mysql-test/suite/binlog/r/binlog_row_insert_select.result +++ b/mysql-test/suite/binlog/r/binlog_row_insert_select.result @@ -11,7 +11,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT select * from t1; a 1 diff --git a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result index 4ccc3b5e797..e0cb1b695be 100644 --- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result @@ -1,3 +1,4 @@ +call mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT"); drop table if exists t1, t2; create table t1 (a int) engine=innodb; create table t2 (a int) engine=myisam; @@ -9,10 +10,12 @@ commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ delete from t1; delete from t2; @@ -26,11 +29,9 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT delete from t1; delete from t2; reset master; @@ -46,13 +47,15 @@ commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; savepoint my_savepoint master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.t2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; rollback to savepoint my_savepoint master-bin.000001 # Xid # # COMMIT /* XID */ delete from t1; @@ -75,13 +78,15 @@ a show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; savepoint my_savepoint master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.t2) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; rollback to savepoint my_savepoint master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F @@ -101,11 +106,9 @@ get_lock("a",10) show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT delete from t1; delete from t2; reset master; @@ -389,9 +392,7 @@ master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # COMMIT -master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; TRUNCATE table t2 -master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F @@ -432,19 +433,8 @@ select get_lock("a",10); get_lock("a",10) 1 flush logs; -select -(@a:=load_file("MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output")) -is not null; -(@a:=load_file("MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output")) -is not null -1 -select -@a like "%#%error_code=0%ROLLBACK\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" OR -@a like "%#%error_code=0%ROLLBACK\r\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%", -@a not like "%#%error_code=%error_code=%"; -@a like "%#%error_code=0%ROLLBACK\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" OR -@a like "%#%error_code=0%ROLLBACK\r\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" @a not like "%#%error_code=%error_code=%" -1 1 +This does not matter in ROW mode as the rolled back changes do not contain transactional changes as these +were previously flushed upon committing/rolling back each statement. drop table t1, t2; create temporary table tt (a int unique); create table ti (a int) engine=innodb; @@ -461,12 +451,6 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.ti) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.ti) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK select count(*) from ti /* zero */; count(*) 0 @@ -484,6 +468,8 @@ insert into ti values (2) /* to make the dup error in the following */; insert into tt select * from ti /* one affected and error */; ERROR 23000: Duplicate entry '2' for key 'a' rollback; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info select count(*) from ti /* zero */; @@ -517,7 +503,7 @@ master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT /* only (!) with fixes for #23333 will show there is the query */; select count(*) from t1 /* must be 3 */; count(*) @@ -559,10 +545,9 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT /* the output must denote there is the query */; select count(*) from t1 /* must be 1 */; count(*) @@ -576,11 +561,9 @@ ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT /* the output must denote there is the query */; select count(*) from t1 /* must be 2 */; count(*) @@ -598,7 +581,7 @@ master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Update_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT /* the output must denote there is the query */; select count(*) from t1 /* must be 2 */; count(*) @@ -613,10 +596,9 @@ ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t4) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT /* the output must denote there is the query */; select count(*) from t1 /* must be 4 */; count(*) @@ -646,11 +628,10 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t3) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT /* the output must denote there is the query */; select count(*) from t1 /* must be 1 */; count(*) @@ -669,12 +650,9 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Delete_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT /* the output must denote there is the query */; select count(*) from t1 /* must be 1 */; count(*) @@ -694,12 +672,9 @@ count(*) show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.t4) master-bin.000001 # Table_map # # table_id: # (test.t1) -master-bin.000001 # Write_rows # # table_id: # -master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # COMMIT /* the output must denote there is the query */; drop trigger trg_del_t2; drop table t1,t2,t3,t4,t5; @@ -720,12 +695,6 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Table_map # # table_id: # (test.ti) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Table_map # # table_id: # (test.ti) -master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # ROLLBACK select count(*) from ti /* zero */; count(*) 0 @@ -743,6 +712,8 @@ insert into ti values (2) /* to make the dup error in the following */; insert into tt select * from ti /* one affected and error */; ERROR 23000: Duplicate entry '2' for key 'a' rollback; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info select count(*) from ti /* zero */; @@ -772,8 +743,10 @@ insert into t2 values (bug27417(2)); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=3 master-bin.000001 # Query # # use `test`; insert into t2 values (bug27417(2)) +master-bin.000001 # Query # # COMMIT select count(*) from t1 /* must be 3 */; count(*) 3 @@ -787,8 +760,10 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=4 master-bin.000001 # Query # # use `test`; delete from t2 where a=bug27417(3) +master-bin.000001 # Query # # COMMIT select count(*) from t1 /* must be 5 */; count(*) 5 @@ -809,10 +784,6 @@ insert into t2 values (bug27417(1)); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Intvar # # INSERT_ID=1 -master-bin.000001 # Query # # use `test`; insert into t2 values (bug27417(1)) -master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -824,10 +795,6 @@ insert into t2 select bug27417(1) union select bug27417(2); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Intvar # # INSERT_ID=2 -master-bin.000001 # Query # # use `test`; insert into t2 select bug27417(1) union select bug27417(2) -master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 2 */; count(*) 2 @@ -838,8 +805,10 @@ update t3 set b=b+bug27417(1); ERROR 23000: Duplicate entry '4' for key 'b' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=4 master-bin.000001 # Query # # use `test`; update t3 set b=b+bug27417(1) +master-bin.000001 # Query # # COMMIT select count(*) from t1 /* must be 2 */; count(*) 2 @@ -852,10 +821,6 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Intvar # # INSERT_ID=6 -master-bin.000001 # Query # # use `test`; UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */ -master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 4 */; count(*) 4 @@ -883,10 +848,6 @@ delete from t2; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Intvar # # INSERT_ID=9 -master-bin.000001 # Query # # use `test`; delete from t2 -master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -903,9 +864,6 @@ delete t2.* from t2,t5 where t2.a=t5.a + 1; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Query # # use `test`; delete t2.* from t2,t5 where t2.a=t5.a + 1 -master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -923,14 +881,6 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # BEGIN -master-bin.000001 # Intvar # # INSERT_ID=10 -master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci -master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=# -master-bin.000001 # Intvar # # INSERT_ID=10 -master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci -master-bin.000001 # Execute_load_query # # use `test`; LOAD DATA INFILE '../../std_data/rpl_loaddata.dat' INTO TABLE `t4` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (a, @b) SET b=((@b) + `bug27417`(2)) ;file_id=# -master-bin.000001 # Query # # ROLLBACK drop trigger trg_del_t2; drop table t1,t2,t3,t4,t5; drop function bug27417; diff --git a/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result b/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result index 800bb58e9cc..2d2619983d6 100644 --- a/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result +++ b/mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result @@ -5,14 +5,27 @@ insert delayed into t1 values (300); FLUSH TABLES; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `mtr`; INSERT INTO test_suppressions (pattern) VALUES ( NAME_CONST('pattern',_latin1'Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT' COLLATE 'latin1_swedish_ci')) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert delayed into t1 values (207) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=208 master-bin.000001 # Query # # use `test`; insert delayed into t1 values (null) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert delayed into t1 values (300) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; FLUSH TABLES insert delayed into t1 values (null),(null),(null),(null); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. insert delayed into t1 values (null),(null),(400),(null); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. select * from t1; a 207 diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result index c5ac0a726ba..baecff8bb85 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result @@ -592,8 +592,10 @@ show binlog events from 0; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 107 Server version, Binlog ver: 4 master-bin.000001 107 Query 1 228 use `test`; create table t1 (a bigint unsigned, b bigint(20) unsigned) -master-bin.000001 228 Query 1 352 use `test`; insert into t1 values (9999999999999999,14632475938453979136) -master-bin.000001 352 Query 1 428 use `test`; drop table t1 +master-bin.000001 228 Query 1 296 BEGIN +master-bin.000001 296 Query 1 420 use `test`; insert into t1 values (9999999999999999,14632475938453979136) +master-bin.000001 420 Query 1 489 COMMIT +master-bin.000001 489 Query 1 565 use `test`; drop table t1 reset master; CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; USE bug39182; @@ -699,16 +701,24 @@ use test; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key) +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=127 master-bin.000001 # Query # # use `test`; insert into t1 values(null) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; drop table t1 master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Query # # use `test`; create table if not exists t2 select * from t1 master-bin.000001 # Query # # use `test`; create temporary table tt1 (a int) master-bin.000001 # Query # # use `test`; create table if not exists t3 like tt1 +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `mysql`; INSERT INTO user SET host='localhost', user='@#@', password=password('Just a test') +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `mysql`; UPDATE user SET password=password('Another password') WHERE host='localhost' AND user='@#@' +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `mysql`; DELETE FROM user WHERE host='localhost' AND user='@#@' +master-bin.000001 # Query # # COMMIT drop table t1,t2,t3,tt1; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; insert delayed into t1 values (207); @@ -718,16 +728,24 @@ FLUSH TABLES; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key) +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=127 master-bin.000001 # Query # # use `test`; insert into t1 values(null) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; drop table t1 master-bin.000001 # Query # # use `test`; create table t1 (a int) master-bin.000001 # Query # # use `test`; create table if not exists t2 select * from t1 master-bin.000001 # Query # # use `test`; create temporary table tt1 (a int) master-bin.000001 # Query # # use `test`; create table if not exists t3 like tt1 +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `mysql`; INSERT INTO user SET host='localhost', user='@#@', password=password('Just a test') +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `mysql`; UPDATE user SET password=password('Another password') WHERE host='localhost' AND user='@#@' +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `mysql`; DELETE FROM user WHERE host='localhost' AND user='@#@' +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; drop table t1,t2,t3,tt1 master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam master-bin.000001 # Query # # BEGIN @@ -799,7 +817,9 @@ SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info # # Format_desc 1 # Server ver: #, Binlog ver: # # # Query 1 # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY) +# # Query 1 # BEGIN # # Query 1 # use `test`; INSERT INTO t1 VALUES (1) +# # Query 1 # COMMIT # # Query 1 # BEGIN # # Table_map 1 # table_id: # (test.t1) # # Write_rows 1 # table_id: # flags: STMT_END_F diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result index b7edf7fedb8..b91d7b4c836 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result @@ -5,15 +5,15 @@ reset master; insert into t2 values (@v); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # User var # # @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci master-bin.000001 # Query # # use `test`; insert into t2 values (@v) +master-bin.000001 # Query # # COMMIT flush logs; /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; -SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/; -use test/*!*/; SET TIMESTAMP=10000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; @@ -23,8 +23,16 @@ SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/ SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; +BEGIN +/*!*/; +SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`/*!*/; +use test/*!*/; +SET TIMESTAMP=10000/*!*/; insert into t2 values (@v) /*!*/; +SET TIMESTAMP=10000/*!*/; +COMMIT +/*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; diff --git a/mysql-test/suite/binlog/r/binlog_stm_do_db.result b/mysql-test/suite/binlog/r/binlog_stm_do_db.result index ab4ba7cdca1..63421a968a4 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_do_db.result +++ b/mysql-test/suite/binlog/r/binlog_stm_do_db.result @@ -25,11 +25,11 @@ use b42829; ### binlog-do-db is not filtering used database BEGIN; INSERT INTO t2 VALUES (1,2), (1,3), (1,4); -ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT' +ERROR HY000: Cannot execute statement: binlogging impossible since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED. UPDATE b42829_filtered.t1 ft1, b42829.t1 nft1 SET ft1.x=1, nft1.x=2; -ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT' +ERROR HY000: Cannot execute statement: binlogging impossible since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED. INSERT INTO t1 SELECT * FROM t2; -ERROR HY000: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT' +ERROR HY000: Cannot execute statement: binlogging impossible since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED. COMMIT; ### assertion: filtered events did not make into the binlog show binlog events from <binlog_start>; diff --git a/mysql-test/suite/binlog/r/binlog_stm_insert_select.result b/mysql-test/suite/binlog/r/binlog_stm_insert_select.result index a93a8edf4aa..72036d89b9e 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_insert_select.result +++ b/mysql-test/suite/binlog/r/binlog_stm_insert_select.result @@ -8,7 +8,9 @@ insert into t1 select * from t2; ERROR 23000: Duplicate entry '2' for key 'a' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 select * from t2 +master-bin.000001 # Query # # COMMIT select * from t1; a 1 diff --git a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result index 268d390a1a1..51316f12118 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result @@ -1,4 +1,5 @@ CALL mtr.add_suppression("Statement may not be safe to log in statement format."); +call mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT"); drop table if exists t1, t2; create table t1 (a int) engine=innodb; create table t2 (a int) engine=myisam; @@ -6,6 +7,8 @@ reset master; begin; insert into t1 values(1); insert into t2 select * from t1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info @@ -19,6 +22,8 @@ reset master; begin; insert into t1 values(2); insert into t2 select * from t1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. rollback; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back @@ -36,6 +41,8 @@ insert into t1 values(3); savepoint my_savepoint; insert into t1 values(4); insert into t2 select * from t1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. rollback to savepoint my_savepoint; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back @@ -57,6 +64,8 @@ insert into t1 values(5); savepoint my_savepoint; insert into t1 values(6); insert into t2 select * from t1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. rollback to savepoint my_savepoint; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back @@ -85,6 +94,8 @@ get_lock("a",10) begin; insert into t1 values(8); insert into t2 select * from t1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. select get_lock("a",10); get_lock("a",10) 1 @@ -99,24 +110,32 @@ delete from t2; reset master; insert into t1 values(9); insert into t2 select * from t1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(9) master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 +master-bin.000001 # Query # # COMMIT delete from t1; delete from t2; reset master; insert into t1 values(10); begin; insert into t2 select * from t1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(10) master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 +master-bin.000001 # Query # # COMMIT insert into t1 values(11); commit; show binlog events from <binlog_start>; @@ -124,7 +143,9 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(10) master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(11) master-bin.000001 # Xid # # COMMIT /* XID */ @@ -226,7 +247,7 @@ insert t0 select * from t1; set autocommit=1; insert into t0 select GET_LOCK("lock1",null); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. set autocommit=0; create table t2 (n int) engine=innodb; insert into t2 values (3); @@ -249,17 +270,29 @@ master-bin.000001 # Query # # use `test`; alter table t2 engine=MyISAM master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values (1) master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t2 values (20) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; drop table t1,t2 +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; create temporary table ti (a int) engine=innodb +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into ti values(1) master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; create temporary table t1 (a int) engine=myisam +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert t1 values (1) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; create table t0 (n int) +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert t0 select * from t1 +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t0 select GET_LOCK("lock1",null) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; create table t2 (n int) engine=innodb master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t1`,`ti` do release_lock("lock1"); @@ -343,24 +376,42 @@ a b DROP TABLE t1,t2; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (1,1),(1,2) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE if exists t2 +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (3,3) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t2 master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb -master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4,4) master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4,4) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; TRUNCATE table t2 -master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5,5) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE t2 +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (6,6) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)) engine=innodb +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (7,7) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (8,8) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (9,9) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; TRUNCATE table t2 +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (10,10) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t2 values (100,100) master-bin.000001 # Query # # COMMIT @@ -374,6 +425,8 @@ get_lock("a",10) begin; insert into t1 values(8); insert into t2 select * from t1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. select get_lock("a",10); get_lock("a",10) 1 @@ -399,6 +452,8 @@ begin; insert into ti values (1); insert into ti values (2) ; insert into tt select * from ti; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. rollback; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back @@ -416,6 +471,8 @@ select count(*) from ti /* zero */; count(*) 0 insert into ti select * from tt; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. select * from ti /* that is what slave would miss - a bug */; a 1 @@ -442,6 +499,8 @@ select count(*) from ti /* zero */; count(*) 0 insert into ti select * from tt; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. select * from tt /* that is what otherwise slave missed - the bug */; a 1 @@ -460,17 +519,19 @@ end| reset master; insert into t2 values (bug27417(1)); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. insert into t2 select bug27417(2); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. reset master; insert into t2 values (bug27417(2)); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=3 master-bin.000001 # Query # # use `test`; insert into t2 values (bug27417(2)) +master-bin.000001 # Query # # COMMIT /* only (!) with fixes for #23333 will show there is the query */; select count(*) from t1 /* must be 3 */; count(*) @@ -481,21 +542,23 @@ count(*) 2 delete from t2 where a=bug27417(3); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. select count(*) from t2 /* nothing got deleted */; count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=4 master-bin.000001 # Query # # use `test`; delete from t2 where a=bug27417(3) +master-bin.000001 # Query # # COMMIT /* the query must be in regardless of #23333 */; select count(*) from t1 /* must be 5 */; count(*) 5 delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. affected rows: 0 select count(*) from t1 /* must be 7 */; count(*) @@ -543,8 +606,10 @@ update t3 set b=b+bug27417(1); ERROR 23000: Duplicate entry '4' for key 'b' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=4 master-bin.000001 # Query # # use `test`; update t3 set b=b+bug27417(1) +master-bin.000001 # Query # # COMMIT /* the output must denote there is the query */; select count(*) from t1 /* must be 2 */; count(*) @@ -651,6 +716,8 @@ begin; insert into ti values (1); insert into ti values (2) ; insert into tt select * from ti; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. rollback; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back @@ -668,6 +735,8 @@ select count(*) from ti /* zero */; count(*) 0 insert into ti select * from tt; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. select * from ti /* that is what slave would miss - bug#28960 */; a 1 @@ -694,6 +763,8 @@ select count(*) from ti /* zero */; count(*) 0 insert into ti select * from tt; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Non-transactional reads or writes are unsafe if they occur after transactional reads or writes inside a transaction. select * from tt /* that is what otherwise slave missed - the bug */; a 1 @@ -712,17 +783,19 @@ end| reset master; insert into t2 values (bug27417(1)); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. insert into t2 select bug27417(2); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. reset master; insert into t2 values (bug27417(2)); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=3 master-bin.000001 # Query # # use `test`; insert into t2 values (bug27417(2)) +master-bin.000001 # Query # # COMMIT select count(*) from t1 /* must be 3 */; count(*) 3 @@ -732,20 +805,22 @@ count(*) 2 delete from t2 where a=bug27417(3); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. select count(*) from t2 /* nothing got deleted */; count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=4 master-bin.000001 # Query # # use `test`; delete from t2 where a=bug27417(3) +master-bin.000001 # Query # # COMMIT select count(*) from t1 /* must be 5 */; count(*) 5 delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. affected rows: 0 select count(*) from t1 /* must be 7 */; count(*) @@ -791,8 +866,10 @@ update t3 set b=b+bug27417(1); ERROR 23000: Duplicate entry '4' for key 'b' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=4 master-bin.000001 # Query # # use `test`; update t3 set b=b+bug27417(1) +master-bin.000001 # Query # # COMMIT select count(*) from t1 /* must be 2 */; count(*) 2 diff --git a/mysql-test/suite/binlog/r/binlog_stm_ps.result b/mysql-test/suite/binlog/r/binlog_stm_ps.result index 3af525e297c..43e8af8a272 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ps.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ps.result @@ -11,12 +11,18 @@ prepare s from "insert into t1 select 100 limit ?"; set @a=100; execute s using @a; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (a int) +master-bin.000001 # Query # # BEGIN master-bin.000001 # User var # # @`a`=98 master-bin.000001 # Query # # use `test`; insert into t1 values (@a),(98) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values (99) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 select 100 limit 100 +master-bin.000001 # Query # # COMMIT drop table t1; diff --git a/mysql-test/suite/binlog/r/binlog_stm_row.result b/mysql-test/suite/binlog/r/binlog_stm_row.result index e74a05e8827..08be2d10bc3 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_row.result +++ b/mysql-test/suite/binlog/r/binlog_stm_row.result @@ -1,4 +1,4 @@ -CALL mtr.add_suppression("Statement may not be safe to log in statement format."); +CALL mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT"); DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t2; set @saved_global_binlog_format = @@global.binlog_format; @@ -31,7 +31,7 @@ RELEASE_LOCK('Bug#34306') 1 # con2 Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. SELECT RELEASE_LOCK('Bug#34306'); RELEASE_LOCK('Bug#34306') 1 @@ -63,11 +63,21 @@ master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t1 master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t2 master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT) master-bin.000001 # Query # # use `test`; CREATE TABLE t2 LIKE t1 +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(1) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES(2) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (3) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (4) +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F diff --git a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result index edbd878982b..3186f29f106 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result +++ b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result @@ -4,10 +4,10 @@ CREATE TABLE t1 (a int, b int, primary key (a)); INSERT INTO t1 VALUES (1,2), (2,3); UPDATE t1 SET b='4' WHERE a=1 LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. DROP TABLE t1; ### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown SET SQL_LOG_BIN= 0; @@ -38,11 +38,11 @@ CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(10)); SET GLOBAL LOG_WARNINGS = 0; INSERT INTO t1 VALUES(UUID(), 'Bug#46265'); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. SET GLOBAL LOG_WARNINGS = 1; INSERT INTO t1 VALUES(UUID(), 'Bug#46265'); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. DROP TABLE t1; SET GLOBAL log_warnings = @old_log_warnings; # Count the number of times the "Unsafe" message was printed diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index c3ce1783f95..7845ec93b44 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -1,210 +1,2985 @@ -==== Setup tables ==== -CREATE TABLE t1 (a INT); -CREATE TABLE t2 (a CHAR(40)); -CREATE TABLE t3 (a INT AUTO_INCREMENT PRIMARY KEY); -CREATE TABLE trigger_table (a CHAR(7)); -CREATE TABLE trigger_table2 (a INT); -==== Non-deterministic statements ==== -INSERT DELAYED INTO t1 VALUES (5); -==== Some variables that *should* be unsafe ==== ----- Insert directly ---- -INSERT INTO t1 VALUES (@@global.sync_binlog); +#### Setup tables #### +CREATE TABLE t0 (a CHAR(100)); +CREATE TABLE t1 (a CHAR(100)); +CREATE TABLE t2 (a CHAR(100)); +CREATE TABLE t3 (a CHAR(100)); +CREATE TABLE ta0 (a CHAR(100)); +CREATE TABLE ta1 (a CHAR(100)); +CREATE TABLE ta2 (a CHAR(100)); +CREATE TABLE ta3 (a CHAR(100)); +CREATE TABLE autoinc_table (a INT PRIMARY KEY AUTO_INCREMENT); +CREATE TABLE data_table (a CHAR(100)); +INSERT INTO data_table VALUES ('foo'); +CREATE TABLE trigger_table_1 (a INT); +CREATE TABLE trigger_table_2 (a INT); +CREATE TABLE trigger_table_3 (a INT); +CREATE TABLE double_autoinc_table (a INT PRIMARY KEY AUTO_INCREMENT); +CREATE TRIGGER double_autoinc_trig +BEFORE INSERT ON double_autoinc_table FOR EACH ROW +BEGIN +INSERT INTO autoinc_table VALUES (NULL); +END| +CREATE FUNCTION multi_unsafe_func() RETURNS INT +BEGIN +INSERT INTO t0 VALUES(CONCAT(@@hostname, @@hostname)); +INSERT INTO t0 VALUES(0); +INSERT INTO t0 VALUES(CONCAT(UUID(), @@hostname)); +RETURN 1; +END| +CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; + +==== Testing UUID() unsafeness ==== + +Invoking function func_retval_1 returning value from unsafe UUID() function. +CREATE FUNCTION func_retval_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); RETURN UUID(); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 VALUES (func_retval_1()); Warnings: -Note 1592 Statement may not be safe to log in statement format. -INSERT INTO t1 VALUES (@@session.insert_id); +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT func_retval_1(); + +Invoking function func_retval_2 returning value from function func_retval_1 returning value from unsafe UUID() function. +CREATE FUNCTION func_retval_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); RETURN func_retval_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 VALUES (func_retval_2()); Warnings: -Note 1592 Statement may not be safe to log in statement format. -INSERT INTO t1 VALUES (@@global.auto_increment_increment); +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT func_retval_2(); +DROP FUNCTION func_retval_2; + +Invoking function func_sidef_2 invoking function func_retval_1 returning value from unsafe UUID() function. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 VALUES (func_retval_1()); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); Warnings: -Note 1592 Statement may not be safe to log in statement format. -INSERT INTO t2 SELECT UUID(); +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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_retval_1 returning value from unsafe UUID() function. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 VALUES (func_retval_1()); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); Warnings: -Note 1592 Statement may not be safe to log in statement format. -INSERT INTO t2 VALUES (@@session.sql_mode); +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_retval_1 returning value from unsafe UUID() function. +CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 VALUES (func_retval_1()); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); Warnings: -Note 1592 Statement may not be safe to log in statement format. -INSERT INTO t2 VALUES (@@global.init_slave); +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_retval_2 returning value from function func_retval_1 returning value from unsafe UUID() function. +CREATE VIEW view_retval_2 AS SELECT func_retval_1(); Warnings: -Note 1592 Statement may not be safe to log in statement format. -INSERT INTO t2 VALUES (@@hostname); +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_retval_2; Warnings: -Note 1592 Statement may not be safe to log in statement format. ----- Insert from stored procedure ---- -CREATE PROCEDURE proc() -BEGIN -INSERT INTO t1 VALUES (@@global.sync_binlog); -INSERT INTO t1 VALUES (@@session.insert_id); -INSERT INTO t1 VALUES (@@global.auto_increment_increment); -INSERT INTO t2 SELECT UUID(); -INSERT INTO t2 VALUES (@@session.sql_mode); -INSERT INTO t2 VALUES (@@global.init_slave); -INSERT INTO t2 VALUES (@@hostname); -END| -CALL proc(); -Warnings: -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. ----- Insert from stored function ---- -CREATE FUNCTION func() -RETURNS INT -BEGIN -INSERT INTO t1 VALUES (@@global.sync_binlog); -INSERT INTO t1 VALUES (@@session.insert_id); -INSERT INTO t1 VALUES (@@global.auto_increment_increment); -INSERT INTO t2 SELECT UUID(); -INSERT INTO t2 VALUES (@@session.sql_mode); -INSERT INTO t2 VALUES (@@global.init_slave); -INSERT INTO t2 VALUES (@@hostname); -RETURN 0; -END| -SELECT func(); -func() -0 +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM view_retval_2; +DROP VIEW view_retval_2; + +Invoking prepared statement prep_2 invoking function func_retval_1 returning value from unsafe UUID() function. +PREPARE prep_2 FROM "INSERT INTO t1 VALUES (func_retval_1())"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; Warnings: -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. ----- Insert from trigger ---- -CREATE TRIGGER trig -BEFORE INSERT ON trigger_table -FOR EACH ROW -BEGIN -INSERT INTO t1 VALUES (@@global.sync_binlog); -INSERT INTO t1 VALUES (@@session.insert_id); -INSERT INTO t1 VALUES (@@global.auto_increment_increment); -INSERT INTO t2 SELECT UUID(); -INSERT INTO t2 VALUES (@@session.sql_mode); -INSERT INTO t2 VALUES (@@global.init_slave); -INSERT INTO t2 VALUES (@@hostname); -END| -INSERT INTO trigger_table VALUES ('bye.'); +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +DROP FUNCTION func_retval_1; + +Invoking function func_sidef_1 invoking unsafe UUID() function. +CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 VALUES (UUID()); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT func_sidef_1(); Warnings: -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. ----- Insert from prepared statement ---- -PREPARE p1 FROM 'INSERT INTO t1 VALUES (@@global.sync_binlog)'; -PREPARE p2 FROM 'INSERT INTO t1 VALUES (@@session.insert_id)'; -PREPARE p3 FROM 'INSERT INTO t1 VALUES (@@global.auto_increment_increment)'; -PREPARE p4 FROM 'INSERT INTO t2 SELECT UUID()'; -PREPARE p5 FROM 'INSERT INTO t2 VALUES (@@session.sql_mode)'; -PREPARE p6 FROM 'INSERT INTO t2 VALUES (@@global.init_slave)'; -PREPARE p7 FROM 'INSERT INTO t2 VALUES (@@hostname)'; -EXECUTE p1; -Warnings: -Note 1592 Statement may not be safe to log in statement format. -EXECUTE p2; -Warnings: -Note 1592 Statement may not be safe to log in statement format. -EXECUTE p3; -Warnings: -Note 1592 Statement may not be safe to log in statement format. -EXECUTE p4; -Warnings: -Note 1592 Statement may not be safe to log in statement format. -EXECUTE p5; -Warnings: -Note 1592 Statement may not be safe to log in statement format. -EXECUTE p6; -Warnings: -Note 1592 Statement may not be safe to log in statement format. -EXECUTE p7; -Warnings: -Note 1592 Statement may not be safe to log in statement format. ----- Insert from nested call of triggers / functions / procedures ---- -CREATE PROCEDURE proc1() -INSERT INTO trigger_table VALUES ('ha!')| -CREATE FUNCTION func2() -RETURNS INT -BEGIN -CALL proc1(); -RETURN 0; -END| -CREATE TRIGGER trig3 -BEFORE INSERT ON trigger_table2 -FOR EACH ROW -BEGIN -DECLARE tmp INT; -SELECT func2() INTO tmp; -END| -CREATE PROCEDURE proc4() -INSERT INTO trigger_table2 VALUES (1)| -CREATE FUNCTION func5() -RETURNS INT -BEGIN -CALL proc4; -RETURN 0; -END| -PREPARE prep6 FROM 'SELECT func5()'| -EXECUTE prep6; -func5() -0 +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); Warnings: -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -==== Variables that should *not* be unsafe ==== -INSERT INTO t1 VALUES (@@session.pseudo_thread_id); -INSERT INTO t1 VALUES (@@session.pseudo_thread_id); +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_sidef_1 invoking unsafe UUID() function. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_sidef_2 invoking function func_sidef_1 invoking unsafe UUID() function. +CREATE VIEW view_sidef_2 AS SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +DROP FUNCTION func_sidef_1; + +Invoking procedure proc_1 invoking unsafe UUID() function. +CREATE PROCEDURE proc_1() BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 VALUES (UUID()); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking procedure proc_1 invoking unsafe UUID() function. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +PREPARE prep_2 FROM "CALL proc_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +DROP PROCEDURE proc_1; + +Invoking trigger trig_1 invoking unsafe UUID() function. +CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 VALUES (UUID()); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_1 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.trigger_table_1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking trigger trig_1 invoking unsafe UUID() function. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +DROP TRIGGER trig_1; + +Invoking view view_retval_1 returning value from unsafe UUID() function. +CREATE VIEW view_retval_1 AS SELECT UUID(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT * FROM view_retval_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM view_retval_1; + +Invoking function func_sidef_2 invoking view view_retval_1 returning value from unsafe UUID() function. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_retval_1; RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_retval_1 returning value from unsafe UUID() function. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_retval_1; END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking view view_retval_1 returning value from unsafe UUID() function. +CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_retval_1; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_retval_2 returning value from view view_retval_1 returning value from unsafe UUID() function. +CREATE VIEW view_retval_2 AS SELECT * FROM view_retval_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_retval_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM view_retval_2; +DROP VIEW view_retval_2; + +Invoking prepared statement prep_2 invoking view view_retval_1 returning value from unsafe UUID() function. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT * FROM view_retval_1"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +DROP VIEW view_retval_1; + +Invoking prepared statement prep_1 invoking unsafe UUID() function. +PREPARE prep_1 FROM "INSERT INTO t0 VALUES (UUID())"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 unsafe UUID() function. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t0 VALUES (UUID()); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT UUID(); + +==== Testing @@hostname unsafeness ==== + +Invoking function func_retval_1 returning value from unsafe @@hostname variable. +CREATE FUNCTION func_retval_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); RETURN @@hostname; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 VALUES (func_retval_1()); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT func_retval_1(); + +Invoking function func_retval_2 returning value from function func_retval_1 returning value from unsafe @@hostname variable. +CREATE FUNCTION func_retval_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); RETURN func_retval_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 VALUES (func_retval_2()); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT func_retval_2(); +DROP FUNCTION func_retval_2; + +Invoking function func_sidef_2 invoking function func_retval_1 returning value from unsafe @@hostname variable. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 VALUES (func_retval_1()); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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_retval_1 returning value from unsafe @@hostname variable. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 VALUES (func_retval_1()); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_retval_1 returning value from unsafe @@hostname variable. +CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 VALUES (func_retval_1()); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 view view_retval_2 returning value from function func_retval_1 returning value from unsafe @@hostname variable. +CREATE VIEW view_retval_2 AS SELECT func_retval_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_retval_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM view_retval_2; +DROP VIEW view_retval_2; + +Invoking prepared statement prep_2 invoking function func_retval_1 returning value from unsafe @@hostname variable. +PREPARE prep_2 FROM "INSERT INTO t1 VALUES (func_retval_1())"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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; +DROP FUNCTION func_retval_1; + +Invoking function func_sidef_1 invoking unsafe @@hostname variable. +CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 VALUES (@@hostname); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_sidef_1 invoking unsafe @@hostname variable. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 view view_sidef_2 invoking function func_sidef_1 invoking unsafe @@hostname variable. +CREATE VIEW view_sidef_2 AS SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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; +DROP FUNCTION func_sidef_1; + +Invoking procedure proc_1 invoking unsafe @@hostname variable. +CREATE PROCEDURE proc_1() BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 VALUES (@@hostname); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking procedure proc_1 invoking unsafe @@hostname variable. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +PREPARE prep_2 FROM "CALL proc_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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; +DROP PROCEDURE proc_1; + +Invoking trigger trig_1 invoking unsafe @@hostname variable. +CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 VALUES (@@hostname); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_1 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.trigger_table_1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking trigger trig_1 invoking unsafe @@hostname variable. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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; +DROP TRIGGER trig_1; + +Invoking prepared statement prep_1 invoking unsafe @@hostname variable. +PREPARE prep_1 FROM "INSERT INTO t0 VALUES (@@hostname)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on 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 unsafe @@hostname variable. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t0 VALUES (@@hostname); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. + +==== Testing SELECT...LIMIT unsafeness ==== + +Invoking function func_sidef_1 invoking unsafe SELECT...LIMIT statement. +CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 SELECT * FROM data_table LIMIT 1; RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_sidef_1 invoking unsafe SELECT...LIMIT statement. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 view view_sidef_2 invoking function func_sidef_1 invoking unsafe SELECT...LIMIT statement. +CREATE VIEW view_sidef_2 AS SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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; +DROP FUNCTION func_sidef_1; + +Invoking procedure proc_1 invoking unsafe SELECT...LIMIT statement. +CREATE PROCEDURE proc_1() BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 SELECT * FROM data_table LIMIT 1; END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking procedure proc_1 invoking unsafe SELECT...LIMIT statement. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +PREPARE prep_2 FROM "CALL proc_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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; +DROP PROCEDURE proc_1; + +Invoking trigger trig_1 invoking unsafe SELECT...LIMIT statement. +CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 SELECT * FROM data_table LIMIT 1; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_1 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.trigger_table_1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking trigger trig_1 invoking unsafe SELECT...LIMIT statement. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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; +DROP TRIGGER trig_1; + +Invoking view view_retval_1 returning value from unsafe SELECT...LIMIT statement. +CREATE VIEW view_retval_1 AS SELECT * FROM data_table LIMIT 1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT * FROM view_retval_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM view_retval_1; + +Invoking function func_sidef_2 invoking view view_retval_1 returning value from unsafe SELECT...LIMIT statement. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_retval_1; RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 view view_retval_1 returning value from unsafe SELECT...LIMIT statement. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_retval_1; END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking view view_retval_1 returning value from unsafe SELECT...LIMIT statement. +CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_retval_1; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 view view_retval_2 returning value from view view_retval_1 returning value from unsafe SELECT...LIMIT statement. +CREATE VIEW view_retval_2 AS SELECT * FROM view_retval_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_retval_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM view_retval_2; +DROP VIEW view_retval_2; + +Invoking prepared statement prep_2 invoking view view_retval_1 returning value from unsafe SELECT...LIMIT statement. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT * FROM view_retval_1"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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; +DROP VIEW view_retval_1; + +Invoking prepared statement prep_1 invoking unsafe SELECT...LIMIT statement. +PREPARE prep_1 FROM "INSERT INTO t0 SELECT * FROM data_table LIMIT 1"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* 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 unsafe SELECT...LIMIT statement. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t0 SELECT * FROM data_table LIMIT 1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM data_table LIMIT 1; + +==== Testing INSERT DELAYED unsafeness ==== + +Invoking function func_sidef_1 invoking unsafe INSERT DELAYED statement. +CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO t0 VALUES (1), (2); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_sidef_1 invoking unsafe INSERT DELAYED statement. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 view view_sidef_2 invoking function func_sidef_1 invoking unsafe INSERT DELAYED statement. +CREATE VIEW view_sidef_2 AS SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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; +DROP FUNCTION func_sidef_1; + +Invoking procedure proc_1 invoking unsafe INSERT DELAYED statement. +CREATE PROCEDURE proc_1() BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO t0 VALUES (1), (2); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking procedure proc_1 invoking unsafe INSERT DELAYED statement. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +PREPARE prep_2 FROM "CALL proc_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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; +DROP PROCEDURE proc_1; + +Invoking trigger trig_1 invoking unsafe INSERT DELAYED statement. +CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT DELAYED INTO t0 VALUES (1), (2); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_1 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.trigger_table_1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking trigger trig_1 invoking unsafe INSERT DELAYED statement. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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; +DROP TRIGGER trig_1; + +Invoking prepared statement prep_1 invoking unsafe INSERT DELAYED statement. +PREPARE prep_1 FROM "INSERT DELAYED INTO t0 VALUES (1), (2)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* 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 unsafe INSERT DELAYED statement. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT DELAYED INTO t0 VALUES (1), (2); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. + +==== Testing unsafeness of insert of two autoinc values ==== + +Invoking function func_sidef_1 invoking unsafe update of two autoinc columns. +CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO double_autoinc_table VALUES (NULL); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 unsafe update of two autoinc columns. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 unsafe update of two autoinc columns. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.double_autoinc_table) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Table_map # # table_id: # (test.autoinc_table) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_sidef_1 invoking unsafe update of two autoinc columns. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 view view_sidef_2 invoking function func_sidef_1 invoking unsafe update of two autoinc columns. +CREATE VIEW view_sidef_2 AS SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 unsafe update of two autoinc columns. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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; +DROP FUNCTION func_sidef_1; + +Invoking procedure proc_1 invoking unsafe update of two autoinc columns. +CREATE PROCEDURE proc_1() BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO double_autoinc_table VALUES (NULL); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta1 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.double_autoinc_table) +master-bin.000001 # Table_map # # table_id: # (test.autoinc_table) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT + +Invoking function func_sidef_2 invoking procedure proc_1 invoking unsafe update of two autoinc columns. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 unsafe update of two autoinc columns. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta1 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.double_autoinc_table) +master-bin.000001 # Table_map # # table_id: # (test.autoinc_table) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking procedure proc_1 invoking unsafe update of two autoinc columns. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 unsafe update of two autoinc columns. +PREPARE prep_2 FROM "CALL proc_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta1 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.double_autoinc_table) +master-bin.000001 # Table_map # # table_id: # (test.autoinc_table) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PREPARE prep_2; +DROP PROCEDURE proc_1; + +Invoking trigger trig_1 invoking unsafe update of two autoinc columns. +CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO double_autoinc_table VALUES (NULL); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_1 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 unsafe update of two autoinc columns. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 unsafe update of two autoinc columns. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.trigger_table_1) +master-bin.000001 # Table_map # # table_id: # (test.double_autoinc_table) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Table_map # # table_id: # (test.autoinc_table) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking trigger trig_1 invoking unsafe update of two autoinc columns. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 unsafe update of two autoinc columns. +PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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; +DROP TRIGGER trig_1; + +Invoking prepared statement prep_1 invoking unsafe update of two autoinc columns. +PREPARE prep_1 FROM "INSERT INTO double_autoinc_table VALUES (NULL)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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 unsafe update of two autoinc columns. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO double_autoinc_table VALUES (NULL); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. + +==== Testing unsafeness of UDF's ==== + +Invoking function func_retval_1 returning value from unsafe UDF. +CREATE FUNCTION func_retval_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); RETURN myfunc_int(10); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 VALUES (func_retval_1()); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT func_retval_1(); + +Invoking function func_retval_2 returning value from function func_retval_1 returning value from unsafe UDF. +CREATE FUNCTION func_retval_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); RETURN func_retval_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 VALUES (func_retval_2()); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT func_retval_2(); +DROP FUNCTION func_retval_2; + +Invoking function func_sidef_2 invoking function func_retval_1 returning value from unsafe UDF. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 VALUES (func_retval_1()); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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_retval_1 returning value from unsafe UDF. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 VALUES (func_retval_1()); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_retval_1 returning value from unsafe UDF. +CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 VALUES (func_retval_1()); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 view view_retval_2 returning value from function func_retval_1 returning value from unsafe UDF. +CREATE VIEW view_retval_2 AS SELECT func_retval_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_retval_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM view_retval_2; +DROP VIEW view_retval_2; + +Invoking prepared statement prep_2 invoking function func_retval_1 returning value from unsafe UDF. +PREPARE prep_2 FROM "INSERT INTO t1 VALUES (func_retval_1())"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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; +DROP FUNCTION func_retval_1; + +Invoking function func_sidef_1 invoking unsafe UDF. +CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 VALUES (myfunc_int(10)); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_sidef_1 invoking unsafe UDF. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 view view_sidef_2 invoking function func_sidef_1 invoking unsafe UDF. +CREATE VIEW view_sidef_2 AS SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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; +DROP FUNCTION func_sidef_1; + +Invoking procedure proc_1 invoking unsafe UDF. +CREATE PROCEDURE proc_1() BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 VALUES (myfunc_int(10)); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking procedure proc_1 invoking unsafe UDF. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +PREPARE prep_2 FROM "CALL proc_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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; +DROP PROCEDURE proc_1; + +Invoking trigger trig_1 invoking unsafe UDF. +CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 VALUES (myfunc_int(10)); END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_1 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.trigger_table_1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking trigger trig_1 invoking unsafe UDF. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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; +DROP TRIGGER trig_1; + +Invoking view view_sidef_1 invoking unsafe UDF. +CREATE VIEW view_sidef_1 AS SELECT myfunc_int(10); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT * FROM view_sidef_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 view view_sidef_1 invoking unsafe UDF. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_sidef_1; RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 view view_sidef_1 invoking unsafe UDF. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_sidef_1; END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking view view_sidef_1 invoking unsafe UDF. +CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_sidef_1; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 view view_sidef_2 invoking view view_sidef_1 invoking unsafe UDF. +CREATE VIEW view_sidef_2 AS SELECT * FROM view_sidef_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 view view_sidef_1 invoking unsafe UDF. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT * FROM view_sidef_1"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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; +DROP VIEW view_sidef_1; + +Invoking prepared statement prep_1 invoking unsafe UDF. +PREPARE prep_1 FROM "INSERT INTO t0 VALUES (myfunc_int(10))"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on 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 unsafe UDF. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t0 VALUES (myfunc_int(10)); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. + +==== Testing unsafeness of access to mysql.general_log ==== + +Invoking function func_sidef_1 invoking unsafe use of mysql.general_log. +CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 SELECT COUNT(*) FROM mysql.general_log; RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 unsafe use of mysql.general_log. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 unsafe use of mysql.general_log. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_sidef_1 invoking unsafe use of mysql.general_log. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 view view_sidef_2 invoking function func_sidef_1 invoking unsafe use of mysql.general_log. +CREATE VIEW view_sidef_2 AS SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 unsafe use of mysql.general_log. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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; +DROP FUNCTION func_sidef_1; + +Invoking procedure proc_1 invoking unsafe use of mysql.general_log. +CREATE PROCEDURE proc_1() BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 SELECT COUNT(*) FROM mysql.general_log; END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta1 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT + +Invoking function func_sidef_2 invoking procedure proc_1 invoking unsafe use of mysql.general_log. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 unsafe use of mysql.general_log. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta1 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking procedure proc_1 invoking unsafe use of mysql.general_log. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 unsafe use of mysql.general_log. +PREPARE prep_2 FROM "CALL proc_1()"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta1 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PREPARE prep_2; +DROP PROCEDURE proc_1; + +Invoking trigger trig_1 invoking unsafe use of mysql.general_log. +CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO t0 SELECT COUNT(*) FROM mysql.general_log; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_1 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 unsafe use of mysql.general_log. +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 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 unsafe use of mysql.general_log. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.trigger_table_1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking trigger trig_1 invoking unsafe use of mysql.general_log. +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 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 unsafe use of mysql.general_log. +PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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; +DROP TRIGGER trig_1; + +Invoking view view_retval_1 returning value from unsafe use of mysql.general_log. +CREATE VIEW view_retval_1 AS SELECT COUNT(*) FROM mysql.general_log; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t1 SELECT * FROM view_retval_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM view_retval_1; + +Invoking function func_sidef_2 invoking view view_retval_1 returning value from unsafe use of mysql.general_log. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_retval_1; RETURN 0; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 view view_retval_1 returning value from unsafe use of mysql.general_log. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_retval_1; END; +* binlog_format = STATEMENT: expect 1 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking view view_retval_1 returning value from unsafe use of mysql.general_log. +CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_retval_1; END; +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 view view_retval_2 returning value from view view_retval_1 returning value from unsafe use of mysql.general_log. +CREATE VIEW view_retval_2 AS SELECT * FROM view_retval_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t2 SELECT * FROM view_retval_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT * FROM view_retval_2; +DROP VIEW view_retval_2; + +Invoking prepared statement prep_2 invoking view view_retval_1 returning value from unsafe use of mysql.general_log. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT * FROM view_retval_1"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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; +DROP VIEW view_retval_1; + +Invoking prepared statement prep_1 invoking unsafe use of mysql.general_log. +PREPARE prep_1 FROM "INSERT INTO t0 SELECT COUNT(*) FROM mysql.general_log"; +* binlog_format = STATEMENT: expect 1 warnings. +EXECUTE prep_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on 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 unsafe use of mysql.general_log. +* binlog_format = STATEMENT: expect 1 warnings. +INSERT INTO t0 SELECT COUNT(*) FROM mysql.general_log; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +* Invoke statement so that return value is dicarded: expect no warning. +SELECT COUNT(*) FROM mysql.general_log; + +==== Testing a statement that is unsafe in many ways ==== + +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. +INSERT INTO t1 SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; +* binlog_format = STATEMENT: expect 7 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Table_map # # table_id: # (test.double_autoinc_table) +master-bin.000001 # Table_map # # table_id: # (test.autoinc_table) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +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. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_sidef_2 invoking function func_sidef_1 invoking statement that is unsafe in many ways. +CREATE VIEW view_sidef_2 AS SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* binlog_format = STATEMENT: expect 7 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +DROP FUNCTION func_sidef_1; + +Invoking procedure proc_1 invoking statement that is unsafe in many ways. +CREATE PROCEDURE proc_1() 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. +CALL proc_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 INSERT INTO ta2 VALUES (47); CALL proc_1(); END; +* binlog_format = STATEMENT: expect 7 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.double_autoinc_table) +master-bin.000001 # Table_map # # table_id: # (test.autoinc_table) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +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. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by 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; +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. +INSERT INTO trigger_table_1 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; +* binlog_format = STATEMENT: expect 7 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.trigger_table_1) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Table_map # # table_id: # (test.double_autoinc_table) +master-bin.000001 # Table_map # # table_id: # (test.autoinc_table) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +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. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +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. +EXECUTE prep_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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. +INSERT DELAYED INTO double_autoinc_table SELECT CONCAT(UUID(), @@hostname, myfunc_int(), NULL) FROM mysql.general_log LIMIT 1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses INSERT DELAYED. This is unsafe because the time when rows are inserted cannot be predicted. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses the general_log or slow_log table. This is unsafe because system tables may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a UDF. It cannot be determined if the UDF will return the same value on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. + +==== Testing a statement that is unsafe several times ==== + +Invoking function func_sidef_1 invoking statement that is unsafe several times. +CREATE FUNCTION func_sidef_1() RETURNS VARCHAR(100) BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO ta0 VALUES (multi_unsafe_func()); RETURN 0; END; +* binlog_format = STATEMENT: expect 2 warnings. +INSERT INTO t1 SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 several times. +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 2 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 several times. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT func_sidef_1(); END; +* binlog_format = STATEMENT: expect 2 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.ta0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking function func_sidef_1 invoking statement that is unsafe several times. +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 2 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_sidef_2 invoking function func_sidef_1 invoking statement that is unsafe several times. +CREATE VIEW view_sidef_2 AS SELECT func_sidef_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* binlog_format = STATEMENT: expect 2 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 several times. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT func_sidef_1()"; +* binlog_format = STATEMENT: expect 2 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +DROP FUNCTION func_sidef_1; + +Invoking procedure proc_1 invoking statement that is unsafe several times. +CREATE PROCEDURE proc_1() BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO ta0 VALUES (multi_unsafe_func()); END; +* binlog_format = STATEMENT: expect 2 warnings. +CALL proc_1(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta1 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.ta0) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT + +Invoking function func_sidef_2 invoking procedure proc_1 invoking statement that is unsafe several times. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); RETURN 0; END; +* binlog_format = STATEMENT: expect 2 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 several times. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); CALL proc_1(); END; +* binlog_format = STATEMENT: expect 2 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta1 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.ta0) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking procedure proc_1 invoking statement that is unsafe several times. +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 2 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 several times. +PREPARE prep_2 FROM "CALL proc_1()"; +* binlog_format = STATEMENT: expect 2 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta1 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.ta0) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PREPARE prep_2; +DROP PROCEDURE proc_1; + +Invoking trigger trig_1 invoking statement that is unsafe several times. +CREATE TRIGGER trig_1 BEFORE INSERT ON trigger_table_1 FOR EACH ROW BEGIN INSERT INTO ta1 VALUES (47); INSERT INTO ta0 VALUES (multi_unsafe_func()); END; +* binlog_format = STATEMENT: expect 2 warnings. +INSERT INTO trigger_table_1 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 several times. +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 2 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 several times. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO trigger_table_1 VALUES (1); END; +* binlog_format = STATEMENT: expect 2 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.trigger_table_1) +master-bin.000001 # Table_map # # table_id: # (test.ta0) +master-bin.000001 # Table_map # # table_id: # (test.ta1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking trigger trig_1 invoking statement that is unsafe several times. +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 2 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 several times. +PREPARE prep_2 FROM "INSERT INTO trigger_table_1 VALUES (1)"; +* binlog_format = STATEMENT: expect 2 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +DROP TRIGGER trig_1; + +Invoking view view_sidef_1 invoking statement that is unsafe several times. +CREATE VIEW view_sidef_1 AS SELECT multi_unsafe_func(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* binlog_format = STATEMENT: expect 2 warnings. +INSERT INTO t1 SELECT * FROM view_sidef_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_sidef_1 invoking statement that is unsafe several times. +CREATE FUNCTION func_sidef_2() RETURNS VARCHAR(100) BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_sidef_1; RETURN 0; END; +* binlog_format = STATEMENT: expect 2 warnings. +INSERT INTO t2 SELECT func_sidef_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_sidef_1 invoking statement that is unsafe several times. +CREATE PROCEDURE proc_2() BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_sidef_1; END; +* binlog_format = STATEMENT: expect 2 warnings. +CALL proc_2(); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +******** Failure! Event number 3 was a 'Query', not a 'Table_map'. ******** +SHOW BINLOG EVENTS FROM <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO ta2 VALUES (47) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Table_map # # table_id: # (test.t0) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP PROCEDURE proc_2; + +Invoking trigger trig_2 invoking view view_sidef_1 invoking statement that is unsafe several times. +CREATE TRIGGER trig_2 BEFORE INSERT ON trigger_table_2 FOR EACH ROW BEGIN INSERT INTO ta2 VALUES (47); INSERT INTO t1 SELECT * FROM view_sidef_1; END; +* binlog_format = STATEMENT: expect 2 warnings. +INSERT INTO trigger_table_2 VALUES (1); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_sidef_2 invoking view view_sidef_1 invoking statement that is unsafe several times. +CREATE VIEW view_sidef_2 AS SELECT * FROM view_sidef_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* binlog_format = STATEMENT: expect 2 warnings. +INSERT INTO t2 SELECT * FROM view_sidef_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 view view_sidef_1 invoking statement that is unsafe several times. +PREPARE prep_2 FROM "INSERT INTO t1 SELECT * FROM view_sidef_1"; +* binlog_format = STATEMENT: expect 2 warnings. +EXECUTE prep_2; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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; +DROP VIEW view_sidef_1; + +Invoking prepared statement prep_1 invoking statement that is unsafe several times. +PREPARE prep_1 FROM "INSERT INTO ta0 VALUES (multi_unsafe_func())"; +* binlog_format = STATEMENT: expect 2 warnings. +EXECUTE prep_1; +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on 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 several times. +* binlog_format = STATEMENT: expect 2 warnings. +INSERT INTO ta0 VALUES (multi_unsafe_func()); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. +* SQL_LOG_BIN = 0: expect nothing logged and no warning. +* binlog_format = MIXED: expect row events in binlog and no warning. +DROP TRIGGER double_autoinc_trig; +DROP TABLE t0, t1, t2, t3, ta0, ta1, ta2, ta3, +autoinc_table, double_autoinc_table, +data_table, +trigger_table_1, trigger_table_2, trigger_table_3; +DROP FUNCTION myfunc_int; +DROP FUNCTION multi_unsafe_func; +==== Special system variables that should *not* be unsafe ==== +CREATE TABLE t1 (a VARCHAR(1000)); +CREATE TABLE autoinc_table (a INT PRIMARY KEY AUTO_INCREMENT); +INSERT INTO t1 VALUES (@@session.auto_increment_increment); +INSERT INTO t1 VALUES (@@session.auto_increment_offset); +INSERT INTO t1 VALUES (@@session.character_set_client); +INSERT INTO t1 VALUES (@@session.character_set_connection); +INSERT INTO t1 VALUES (@@session.character_set_database); +INSERT INTO t1 VALUES (@@session.character_set_server); +INSERT INTO t1 VALUES (@@session.collation_connection); +INSERT INTO t1 VALUES (@@session.collation_database); +INSERT INTO t1 VALUES (@@session.collation_server); INSERT INTO t1 VALUES (@@session.foreign_key_checks); +INSERT INTO t1 VALUES (@@session.identity); +INSERT INTO t1 VALUES (@@session.last_insert_id); +INSERT INTO t1 VALUES (@@session.lc_time_names); +INSERT INTO t1 VALUES (@@session.pseudo_thread_id); INSERT INTO t1 VALUES (@@session.sql_auto_is_null); +INSERT INTO t1 VALUES (@@session.timestamp); +INSERT INTO t1 VALUES (@@session.time_zone); INSERT INTO t1 VALUES (@@session.unique_checks); -INSERT INTO t1 VALUES (@@session.auto_increment_increment); -INSERT INTO t1 VALUES (@@session.auto_increment_offset); -INSERT INTO t2 VALUES (@@session.character_set_client); -INSERT INTO t2 VALUES (@@session.collation_connection); -INSERT INTO t2 VALUES (@@session.collation_server); -INSERT INTO t2 VALUES (@@session.time_zone); -INSERT INTO t2 VALUES (@@session.lc_time_names); -INSERT INTO t2 VALUES (@@session.collation_database); -INSERT INTO t2 VALUES (@@session.timestamp); -INSERT INTO t2 VALUES (@@session.last_insert_id); SET @my_var= 4711; INSERT INTO t1 VALUES (@my_var); -SET insert_id=12; -INSERT INTO t3 VALUES (NULL); -==== Clean up ==== -DROP PROCEDURE proc; -DROP FUNCTION func; -DROP TRIGGER trig; -DROP PROCEDURE proc1; -DROP FUNCTION func2; -DROP TRIGGER trig3; -DROP PROCEDURE proc4; -DROP FUNCTION func5; -DROP PREPARE prep6; -DROP TABLE t1, t2, t3, trigger_table, trigger_table2; +SET insert_id= 12; +INSERT INTO autoinc_table VALUES (NULL); +The following variables *should* give a warning, despite they are replicated. +INSERT INTO t1 VALUES (@@session.sql_mode); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +INSERT INTO t1 VALUES (@@session.insert_id); +Warnings: +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. +DROP TABLE t1, autoinc_table; CREATE TABLE t1(a INT, b INT, KEY(a), PRIMARY KEY(b)); INSERT INTO t1 SELECT * FROM t1 LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. REPLACE INTO t1 SELECT * FROM t1 LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. UPDATE t1 SET a=1 LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. DELETE FROM t1 LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. CREATE PROCEDURE p1() BEGIN INSERT INTO t1 SELECT * FROM t1 LIMIT 1; @@ -214,10 +2989,7 @@ DELETE FROM t1 LIMIT 1; END| CALL p1(); Warnings: -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. DROP PROCEDURE p1; DROP TABLE t1; DROP TABLE IF EXISTS t1; @@ -225,7 +2997,7 @@ CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100)); INSERT INTO t1 VALUES ('a','b'); UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. DROP TABLE t1; DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1(i INT PRIMARY KEY); @@ -234,7 +3006,7 @@ CREATE TABLE t3(i INT, ch CHAR(50)); "Should issue message Statement may not be safe to log in statement format." INSERT INTO t1 SELECT * FROM t2 LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. CREATE FUNCTION func6() RETURNS INT BEGIN @@ -246,7 +3018,7 @@ END| "Should issue message Statement may not be safe to log in statement format only once" INSERT INTO t3 VALUES(func6(), UUID()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. "Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements" CREATE FUNCTION fun_check_log_bin() RETURNS INT BEGIN @@ -259,7 +3031,7 @@ SELECT fun_check_log_bin(); fun_check_log_bin() 100 Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. "SQL_LOG_BIN should be ON still" SHOW VARIABLES LIKE "SQL_LOG_BIN"; Variable_name Value @@ -315,18 +3087,52 @@ CREATE TABLE t1(i INT PRIMARY KEY); CREATE TABLE t2(i INT PRIMARY KEY); INSERT INTO t1 SELECT * FROM t2 LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. INSERT INTO t1 VALUES(@@global.sync_binlog); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system variable whose value may differ on slave. UPDATE t1 SET i = 999 LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. DELETE FROM t1 LIMIT 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. DROP TABLE t1, t2; SET @@SESSION.SQL_MODE = @save_sql_mode; +SET @old_binlog_format = @@session.binlog_format; +SET binlog_format = MIXED; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (1), (2); +CREATE PROCEDURE proc_insert_delayed () +BEGIN +INSERT DELAYED INTO t1 VALUES (1), (2); +END| +CREATE FUNCTION func_limit () +RETURNS INT +BEGIN +INSERT INTO t1 SELECT * FROM t2 LIMIT 1; +RETURN 1; +END| +RESET MASTER; +CALL proc_insert_delayed(); +SELECT func_limit(); +func_limit() +1 +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +SET @@session.binlog_format = @old_binlog_format; +DROP TABLE t1, t2; +DROP PROCEDURE proc_insert_delayed; +DROP FUNCTION func_limit; CREATE TABLE t1 (a INT, b INT PRIMARY KEY AUTO_INCREMENT); CREATE TABLE t2 (a INT, b INT PRIMARY KEY AUTO_INCREMENT); CREATE FUNCTION func_modify_t1 () @@ -340,18 +3146,18 @@ END| # so it should produce unsafe warning. INSERT INTO t2 SET a = func_modify_t1(); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. SET SESSION binlog_format = MIXED; # Check if the statement is logged in row format. INSERT INTO t2 SET a = func_modify_t1(); -SHOW BINLOG EVENTS FROM 12283; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 12283 Query 1 12351 BEGIN -master-bin.000001 12351 Table_map 1 12393 table_id: 44 (test.t2) -master-bin.000001 12393 Table_map 1 12435 table_id: 45 (test.t1) -master-bin.000001 12435 Write_rows 1 12473 table_id: 45 -master-bin.000001 12473 Write_rows 1 12511 table_id: 44 flags: STMT_END_F -master-bin.000001 12511 Query 1 12580 COMMIT +SHOW BINLOG EVENTS FROM 1493; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 1493 Query 1 1561 BEGIN +master-bin.000001 1561 Table_map 1 1603 table_id: 205 (test.t2) +master-bin.000001 1603 Table_map 1 1645 table_id: 206 (test.t1) +master-bin.000001 1645 Write_rows 1 1683 table_id: 206 +master-bin.000001 1683 Write_rows 1 1721 table_id: 205 flags: STMT_END_F +master-bin.000001 1721 Query 1 1790 COMMIT DROP TABLE t1,t2; DROP FUNCTION func_modify_t1; SET SESSION binlog_format = STATEMENT; @@ -367,74 +3173,74 @@ end | # so it should produce unsafe warning INSERT INTO t1 SET a = 1; Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement updates two AUTO_INCREMENT columns. This is unsafe because the generated value cannot be predicted by slave. SET SESSION binlog_format = MIXED; # Check if the statement is logged in row format. INSERT INTO t1 SET a = 2; -SHOW BINLOG EVENTS FROM 13426; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 13426 Query 1 13494 BEGIN -master-bin.000001 13494 Table_map 1 13535 table_id: 47 (test.t1) -master-bin.000001 13535 Table_map 1 13577 table_id: 48 (test.t3) -master-bin.000001 13577 Table_map 1 13619 table_id: 49 (test.t2) -master-bin.000001 13619 Write_rows 1 13657 table_id: 49 -master-bin.000001 13657 Write_rows 1 13695 table_id: 48 -master-bin.000001 13695 Write_rows 1 13729 table_id: 47 flags: STMT_END_F -master-bin.000001 13729 Query 1 13798 COMMIT +SHOW BINLOG EVENTS FROM 2773; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 2773 Query 1 2841 BEGIN +master-bin.000001 2841 Table_map 1 2882 table_id: 208 (test.t1) +master-bin.000001 2882 Table_map 1 2924 table_id: 209 (test.t3) +master-bin.000001 2924 Table_map 1 2966 table_id: 210 (test.t2) +master-bin.000001 2966 Write_rows 1 3004 table_id: 210 +master-bin.000001 3004 Write_rows 1 3042 table_id: 209 +master-bin.000001 3042 Write_rows 1 3076 table_id: 208 flags: STMT_END_F +master-bin.000001 3076 Query 1 3145 COMMIT DROP TABLE t1,t2,t3; SET SESSION binlog_format = STATEMENT; CREATE TABLE t1 (a VARCHAR(1000)); INSERT INTO t1 VALUES (CURRENT_USER()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (FOUND_ROWS()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (GET_LOCK('tmp', 1)); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (IS_FREE_LOCK('tmp')); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (IS_USED_LOCK('tmp')); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (LOAD_FILE('../../std_data/words2.dat')); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (MASTER_POS_WAIT('dummy arg', 4711, 1)); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (RELEASE_LOCK('tmp')); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (ROW_COUNT()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (SESSION_USER()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (SLEEP(1)); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (SYSDATE()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (SYSTEM_USER()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (USER()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (UUID()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (UUID_SHORT()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. INSERT INTO t1 VALUES (VERSION()); Warnings: -Note 1592 Statement may not be safe to log in statement format. +Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave. DELETE FROM t1; SET TIMESTAMP=1000000; INSERT INTO t1 VALUES |