summaryrefslogtreecommitdiff
path: root/mysql-test/suite/binlog
diff options
context:
space:
mode:
authorSven Sandberg <sven.sandberg@oracle.com>2010-12-19 18:15:12 +0100
committerSven Sandberg <sven.sandberg@oracle.com>2010-12-19 18:15:12 +0100
commite37c86de18ba627f8c055e4a1b0923fb1f0a55de (patch)
tree91a12675003778cd8ccbccea5ce47ee09fc46efc /mysql-test/suite/binlog
parent7d5df402778b7e5c1df06f3dcaf499612d628a7c (diff)
parent09c80e12c535b080eaf914ed25dbf79546494030 (diff)
downloadmariadb-git-e37c86de18ba627f8c055e4a1b0923fb1f0a55de.tar.gz
Merged BUG#49978 from 5.1-bugteam to 5.5-bugteam.
Diffstat (limited to 'mysql-test/suite/binlog')
-rw-r--r--mysql-test/suite/binlog/r/binlog_drop_if_exists.result98
-rw-r--r--mysql-test/suite/binlog/r/binlog_old_versions.result1
-rw-r--r--mysql-test/suite/binlog/r/binlog_query_filter_rules.result11
-rw-r--r--mysql-test/suite/binlog/r/binlog_server_id.result34
-rw-r--r--mysql-test/suite/binlog/r/binlog_sf.result68
-rw-r--r--mysql-test/suite/binlog/r/binlog_sql_mode.result8
-rw-r--r--mysql-test/suite/binlog/t/binlog_drop_if_exists.test115
-rw-r--r--mysql-test/suite/binlog/t/binlog_old_versions.test4
-rw-r--r--mysql-test/suite/binlog/t/binlog_query_filter_rules-master.opt1
-rw-r--r--mysql-test/suite/binlog/t/binlog_query_filter_rules.test32
-rw-r--r--mysql-test/suite/binlog/t/binlog_server_id.test29
-rw-r--r--mysql-test/suite/binlog/t/binlog_sf.test191
-rw-r--r--mysql-test/suite/binlog/t/binlog_sql_mode.test5
13 files changed, 583 insertions, 14 deletions
diff --git a/mysql-test/suite/binlog/r/binlog_drop_if_exists.result b/mysql-test/suite/binlog/r/binlog_drop_if_exists.result
new file mode 100644
index 00000000000..0c398bed440
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_drop_if_exists.result
@@ -0,0 +1,98 @@
+RESET MASTER;
+DROP PROCEDURE IF EXISTS db_bug_13684.p;
+DROP FUNCTION IF EXISTS db_bug_13684.f;
+DROP TRIGGER IF EXISTS db_bug_13684.tr;
+DROP VIEW IF EXISTS db_bug_13684.v;
+DROP EVENT IF EXISTS db_bug_13684.e;
+DROP TABLE IF EXISTS db_bug_13684.t;
+DROP DATABASE IF EXISTS db_bug_13684;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; DROP PROCEDURE IF EXISTS db_bug_13684.p
+master-bin.000001 # Query # # use `test`; DROP FUNCTION IF EXISTS db_bug_13684.f
+master-bin.000001 # Query # # use `test`; DROP TRIGGER IF EXISTS db_bug_13684.tr
+master-bin.000001 # Query # # use `test`; DROP VIEW IF EXISTS db_bug_13684.v
+master-bin.000001 # Query # # use `test`; DROP EVENT IF EXISTS db_bug_13684.e
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `db_bug_13684`.`t` /* generated by server */
+master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
+CREATE DATABASE db_bug_13684;
+CREATE TABLE db_bug_13684.t (a int);
+CREATE EVENT db_bug_13684.e
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
+DO
+UPDATE db_bug_13684.t SET a = a + 1;
+CREATE VIEW db_bug_13684.v
+AS SELECT * FROM db_bug_13684.t;
+CREATE TRIGGER db_bug_13684.tr BEFORE INSERT ON db_bug_13684.t
+FOR EACH ROW BEGIN
+END;
+CREATE PROCEDURE db_bug_13684.p (OUT p1 INT)
+BEGIN
+END;
+CREATE FUNCTION db_bug_13684.f (s CHAR(20))
+RETURNS CHAR(50) DETERMINISTIC
+RETURN s;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; DROP PROCEDURE IF EXISTS db_bug_13684.p
+master-bin.000001 # Query # # use `test`; DROP FUNCTION IF EXISTS db_bug_13684.f
+master-bin.000001 # Query # # use `test`; DROP TRIGGER IF EXISTS db_bug_13684.tr
+master-bin.000001 # Query # # use `test`; DROP VIEW IF EXISTS db_bug_13684.v
+master-bin.000001 # Query # # use `test`; DROP EVENT IF EXISTS db_bug_13684.e
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `db_bug_13684`.`t` /* generated by server */
+master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
+master-bin.000001 # Query # # CREATE DATABASE db_bug_13684
+master-bin.000001 # Query # # use `test`; CREATE TABLE db_bug_13684.t (a int)
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT db_bug_13684.e
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
+DO
+UPDATE db_bug_13684.t SET a = a + 1
+master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db_bug_13684`.`v` AS SELECT * FROM db_bug_13684.t
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER db_bug_13684.tr BEFORE INSERT ON db_bug_13684.t
+FOR EACH ROW BEGIN
+END
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `db_bug_13684`.`p`(OUT p1 INT)
+BEGIN
+END
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `db_bug_13684`.`f`(s CHAR(20)) RETURNS char(50) CHARSET latin1
+ DETERMINISTIC
+RETURN s
+DROP PROCEDURE IF EXISTS db_bug_13684.p;
+DROP FUNCTION IF EXISTS db_bug_13684.f;
+DROP TRIGGER IF EXISTS db_bug_13684.tr;
+DROP VIEW IF EXISTS db_bug_13684.v;
+DROP EVENT IF EXISTS db_bug_13684.e;
+DROP TABLE IF EXISTS db_bug_13684.t;
+DROP DATABASE IF EXISTS db_bug_13684;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; DROP PROCEDURE IF EXISTS db_bug_13684.p
+master-bin.000001 # Query # # use `test`; DROP FUNCTION IF EXISTS db_bug_13684.f
+master-bin.000001 # Query # # use `test`; DROP TRIGGER IF EXISTS db_bug_13684.tr
+master-bin.000001 # Query # # use `test`; DROP VIEW IF EXISTS db_bug_13684.v
+master-bin.000001 # Query # # use `test`; DROP EVENT IF EXISTS db_bug_13684.e
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `db_bug_13684`.`t` /* generated by server */
+master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
+master-bin.000001 # Query # # CREATE DATABASE db_bug_13684
+master-bin.000001 # Query # # use `test`; CREATE TABLE db_bug_13684.t (a int)
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT db_bug_13684.e
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
+DO
+UPDATE db_bug_13684.t SET a = a + 1
+master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db_bug_13684`.`v` AS SELECT * FROM db_bug_13684.t
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER db_bug_13684.tr BEFORE INSERT ON db_bug_13684.t
+FOR EACH ROW BEGIN
+END
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `db_bug_13684`.`p`(OUT p1 INT)
+BEGIN
+END
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `db_bug_13684`.`f`(s CHAR(20)) RETURNS char(50) CHARSET latin1
+ DETERMINISTIC
+RETURN s
+master-bin.000001 # Query # # use `test`; DROP PROCEDURE IF EXISTS db_bug_13684.p
+master-bin.000001 # Query # # use `test`; DROP FUNCTION IF EXISTS db_bug_13684.f
+master-bin.000001 # Query # # use `test`; DROP TRIGGER IF EXISTS db_bug_13684.tr
+master-bin.000001 # Query # # use `test`; DROP VIEW IF EXISTS db_bug_13684.v
+master-bin.000001 # Query # # use `test`; DROP EVENT IF EXISTS db_bug_13684.e
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `db_bug_13684`.`t` /* generated by server */
+master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
diff --git a/mysql-test/suite/binlog/r/binlog_old_versions.result b/mysql-test/suite/binlog/r/binlog_old_versions.result
index 77289252b4c..a4850b835c8 100644
--- a/mysql-test/suite/binlog/r/binlog_old_versions.result
+++ b/mysql-test/suite/binlog/r/binlog_old_versions.result
@@ -1,4 +1,3 @@
-DROP TABLE IF EXISTS t1, t2, t3;
==== Read modern binlog (version 5.1.23) ====
SELECT * FROM t1 ORDER BY a;
a b
diff --git a/mysql-test/suite/binlog/r/binlog_query_filter_rules.result b/mysql-test/suite/binlog/r/binlog_query_filter_rules.result
new file mode 100644
index 00000000000..520d500ed7c
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_query_filter_rules.result
@@ -0,0 +1,11 @@
+drop table if exists t1;
+reset master;
+create table t1 (a int);
+insert into t1 values (1);
+flush logs;
+drop table t1;
+*** must be 1 ***
+select * from t1;
+a
+1
+drop table t1;
diff --git a/mysql-test/suite/binlog/r/binlog_server_id.result b/mysql-test/suite/binlog/r/binlog_server_id.result
new file mode 100644
index 00000000000..f7d778a288b
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_server_id.result
@@ -0,0 +1,34 @@
+set global server_id=1;
+reset master;
+drop table if exists t1,t2,t3;
+create table t1 (a int);
+select @@server_id;
+@@server_id
+1
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query 1 # use `test`; DROP TABLE IF EXISTS `t1`,`t2`,`t3` /* generated by server */
+master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
+set global server_id=2;
+create table t2 (b int);
+select @@server_id;
+@@server_id
+2
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query 1 # use `test`; DROP TABLE IF EXISTS `t1`,`t2`,`t3` /* generated by server */
+master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
+master-bin.000001 # Query 2 # use `test`; create table t2 (b int)
+set global server_id=3;
+create table t3 (c int);
+select @@server_id;
+@@server_id
+3
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query 1 # use `test`; DROP TABLE IF EXISTS `t1`,`t2`,`t3` /* generated by server */
+master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
+master-bin.000001 # Query 2 # use `test`; create table t2 (b int)
+master-bin.000001 # Query 3 # use `test`; create table t3 (c int)
+set global server_id=1;
+drop table t1,t2,t3;
diff --git a/mysql-test/suite/binlog/r/binlog_sf.result b/mysql-test/suite/binlog/r/binlog_sf.result
new file mode 100644
index 00000000000..085ba1ebb8a
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_sf.result
@@ -0,0 +1,68 @@
+set global log_bin_trust_function_creators=0;
+set binlog_format=STATEMENT;
+create function fn16456()
+returns int
+begin
+return unix_timestamp();
+end|
+ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
+set global log_bin_trust_function_creators=1;
+create function fn16456()
+returns int
+begin
+return unix_timestamp();
+end|
+set global log_bin_trust_function_creators=0;
+set binlog_format=ROW;
+select fn16456();
+fn16456()
+timestamp
+set binlog_format=STATEMENT;
+select fn16456();
+ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
+drop function fn16456;
+set global log_bin_trust_function_creators=0;
+create function fn16456()
+returns int deterministic
+begin
+return unix_timestamp();
+end|
+set binlog_format=ROW;
+select fn16456();
+fn16456()
+timestamp
+set binlog_format=STATEMENT;
+select fn16456();
+fn16456()
+timestamp
+drop function fn16456;
+set global log_bin_trust_function_creators=0;
+create function fn16456()
+returns int no sql
+begin
+return unix_timestamp();
+end|
+set binlog_format=ROW;
+select fn16456();
+fn16456()
+timestamp
+set binlog_format=STATEMENT;
+select fn16456();
+fn16456()
+timestamp
+drop function fn16456;
+set global log_bin_trust_function_creators=0;
+create function fn16456()
+returns int reads sql data
+begin
+return unix_timestamp();
+end|
+set binlog_format=ROW;
+select fn16456();
+fn16456()
+timestamp
+set binlog_format=STATEMENT;
+select fn16456();
+fn16456()
+timestamp
+drop function fn16456;
diff --git a/mysql-test/suite/binlog/r/binlog_sql_mode.result b/mysql-test/suite/binlog/r/binlog_sql_mode.result
index e306040502d..4477c94a95e 100644
--- a/mysql-test/suite/binlog/r/binlog_sql_mode.result
+++ b/mysql-test/suite/binlog/r/binlog_sql_mode.result
@@ -1,9 +1,3 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
SET @old_sql_mode= @@global.sql_mode;
SET @old_binlog_format=@@session.binlog_format;
SET SESSION sql_mode=8;
@@ -27,7 +21,7 @@ DO
BEGIN
UPDATE t1 SET id = id +1;
END;|
-Chceck Result
+Check Result
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog"))
is not null;
diff --git a/mysql-test/suite/binlog/t/binlog_drop_if_exists.test b/mysql-test/suite/binlog/t/binlog_drop_if_exists.test
new file mode 100644
index 00000000000..6b2b37ae791
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_drop_if_exists.test
@@ -0,0 +1,115 @@
+# BUG#13684:
+# SP: DROP PROCEDURE|FUNCTION IF EXISTS not binlogged if routine
+# does not exist
+#
+# There is an inconsistency with DROP DATABASE IF EXISTS, DROP
+# TABLE IF EXISTS and DROP VIEW IF EXISTS: those are binlogged even
+# if the DB or TABLE does not exist, whereas DROP PROCEDURE IF
+# EXISTS does not. It would be nice or at least consistent if DROP
+# PROCEDURE/STATEMENT worked the same too.
+#
+# Description:
+# DROP PROCEDURE|FUNCTION IF EXISTS does not get binlogged whereas DROP
+# DATABASE|TABLE|TRIGGER|... IF EXISTS do.
+#
+# Fixed DROP PROCEDURE|FUNCTION IF EXISTS by adding a call to
+# write_bin_log in mysql_execute_command. Checked also if all
+# documented "DROP (...) IF EXISTS" get binlogged. Left out DROP
+# SERVER IF EXISTS because it seems that it only gets binlogged when
+# using row event (see BUG#25705).
+#
+# TODO: add DROP SERVER IF EXISTS to the test case when its
+# binlogging procedure gets fixed (BUG#25705). Furthermore, when
+# logging in RBR format the events that get logged are effectively in
+# RBR format and not in STATEMENT format meaning that one must needs
+# to be extra careful when writing a test for it, or change the CREATE
+# SERVER logging to always log as STATEMENT. You can quickly check this
+# by enabling the flag below $fixed_bug_25705=1 and watch the diff on
+# the STDOUT. More detail may be found on the generated reject file.
+#
+# Test is implemented as follows:
+#
+# i) test each "drop if exists" (DDL), found in MySQL 5.1 manual,
+# on inexistent objects (except for DROP SERVER);
+# ii) show binlog events;
+# iii) create an object for each drop if exists statement;
+# iv) issue "drop if exists" in existent objects.
+# v) show binlog events;
+#
+# References:
+# http://dev.mysql.com/doc/refman/5.1/en/sql-syntax-data-definition.html
+#
+--source include/have_log_bin.inc
+RESET MASTER;
+
+disable_warnings;
+
+# test all "drop if exists" in manual with inexistent objects
+DROP PROCEDURE IF EXISTS db_bug_13684.p;
+DROP FUNCTION IF EXISTS db_bug_13684.f;
+DROP TRIGGER IF EXISTS db_bug_13684.tr;
+DROP VIEW IF EXISTS db_bug_13684.v;
+DROP EVENT IF EXISTS db_bug_13684.e;
+DROP TABLE IF EXISTS db_bug_13684.t;
+DROP DATABASE IF EXISTS db_bug_13684;
+
+let $fixed_bug_25705 = 0;
+
+if($fixed_bug_25705)
+{
+ DROP SERVER IF EXISTS s_bug_13684;
+}
+--source include/show_binlog_events.inc
+
+# test drop with existing values
+
+# create
+CREATE DATABASE db_bug_13684;
+
+CREATE TABLE db_bug_13684.t (a int);
+
+CREATE EVENT db_bug_13684.e
+ ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
+ DO
+ UPDATE db_bug_13684.t SET a = a + 1;
+
+CREATE VIEW db_bug_13684.v
+ AS SELECT * FROM db_bug_13684.t;
+
+CREATE TRIGGER db_bug_13684.tr BEFORE INSERT ON db_bug_13684.t
+ FOR EACH ROW BEGIN
+ END;
+
+CREATE PROCEDURE db_bug_13684.p (OUT p1 INT)
+ BEGIN
+ END;
+
+CREATE FUNCTION db_bug_13684.f (s CHAR(20))
+ RETURNS CHAR(50) DETERMINISTIC
+ RETURN s;
+
+if($fixed_bug_25705)
+{
+ CREATE SERVER s_bug_13684
+ FOREIGN DATA WRAPPER mysql
+ OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
+}
+
+--source include/show_binlog_events.inc
+
+# drop existing
+DROP PROCEDURE IF EXISTS db_bug_13684.p;
+DROP FUNCTION IF EXISTS db_bug_13684.f;
+DROP TRIGGER IF EXISTS db_bug_13684.tr;
+DROP VIEW IF EXISTS db_bug_13684.v;
+DROP EVENT IF EXISTS db_bug_13684.e;
+DROP TABLE IF EXISTS db_bug_13684.t;
+DROP DATABASE IF EXISTS db_bug_13684;
+if($fixed_bug_25705)
+{
+ DROP SERVER IF EXISTS s_bug_13684;
+}
+
+--source include/show_binlog_events.inc
+
+enable_warnings;
diff --git a/mysql-test/suite/binlog/t/binlog_old_versions.test b/mysql-test/suite/binlog/t/binlog_old_versions.test
index 0ccea406a82..b294adbc69d 100644
--- a/mysql-test/suite/binlog/t/binlog_old_versions.test
+++ b/mysql-test/suite/binlog/t/binlog_old_versions.test
@@ -24,9 +24,6 @@
source include/not_embedded.inc;
---disable_warnings
-DROP TABLE IF EXISTS t1, t2, t3;
-
--echo ==== Read modern binlog (version 5.1.23) ====
@@ -161,3 +158,4 @@ DROP TABLE t1, t2, t3;
#SELECT * FROM t1 ORDER BY a;
#SELECT * FROM t2 ORDER BY a;
#SELECT COUNT(*) FROM t3;
+#--source include/rpl_end.inc
diff --git a/mysql-test/suite/binlog/t/binlog_query_filter_rules-master.opt b/mysql-test/suite/binlog/t/binlog_query_filter_rules-master.opt
new file mode 100644
index 00000000000..33632bf98e8
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_query_filter_rules-master.opt
@@ -0,0 +1 @@
+--replicate-do-db='impossible_database'
diff --git a/mysql-test/suite/binlog/t/binlog_query_filter_rules.test b/mysql-test/suite/binlog/t/binlog_query_filter_rules.test
new file mode 100644
index 00000000000..d56a32ce2bd
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_query_filter_rules.test
@@ -0,0 +1,32 @@
+# regression test for
+# Bug#36099 replicate-do-db affects replaying RBR events with mysqlbinlog
+# The test verifies that the slave side filtering rule does not affect
+# applying of row-events on master via mysqlbinlog
+
+-- source include/have_log_bin.inc
+-- source include/not_embedded.inc
+-- source include/have_binlog_format_row.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+reset master;
+
+create table t1 (a int);
+insert into t1 values (1);
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+flush logs;
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug36099.sql
+
+drop table t1;
+--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/bug36099.sql"
+
+--echo *** must be 1 ***
+select * from t1;
+
+# cleanup
+
+drop table t1;
+remove_file $MYSQLTEST_VARDIR/tmp/bug36099.sql;
diff --git a/mysql-test/suite/binlog/t/binlog_server_id.test b/mysql-test/suite/binlog/t/binlog_server_id.test
new file mode 100644
index 00000000000..6e98ec6ee6d
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_server_id.test
@@ -0,0 +1,29 @@
+# Test for BUG#28908 Replication: set global server_id is not setting the session server_id
+
+-- source include/have_log_bin.inc
+
+let $saved_server_id=`select @@server_id`;
+set global server_id=1;
+reset master;
+
+-- disable_warnings
+drop table if exists t1,t2,t3;
+-- enable_warnings
+
+create table t1 (a int);
+select @@server_id;
+source include/show_binlog_events2.inc;
+
+set global server_id=2;
+create table t2 (b int);
+select @@server_id;
+source include/show_binlog_events2.inc;
+
+set global server_id=3;
+create table t3 (c int);
+select @@server_id;
+source include/show_binlog_events2.inc;
+
+# cleanup
+eval set global server_id=$saved_server_id;
+drop table t1,t2,t3;
diff --git a/mysql-test/suite/binlog/t/binlog_sf.test b/mysql-test/suite/binlog/t/binlog_sf.test
new file mode 100644
index 00000000000..05b31afcb58
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_sf.test
@@ -0,0 +1,191 @@
+-- source include/have_log_bin.inc
+
+# We change binlog format inside the test, so no need to re-run with
+# more than one binlog_format.
+-- source include/have_binlog_format_statement.inc
+
+# Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
+# BUG#41166 stored function requires "deterministic" if binlog_format is "statement"
+
+# save status
+
+let $oblf=`select @@SESSION.BINLOG_FORMAT`;
+let $otfc=`select @@log_bin_trust_function_creators`;
+
+set global log_bin_trust_function_creators=0;
+
+
+
+# fail *on definition*
+
+set binlog_format=STATEMENT;
+
+delimiter |;
+--error ER_BINLOG_UNSAFE_ROUTINE
+create function fn16456()
+ returns int
+begin
+ return unix_timestamp();
+end|
+delimiter ;|
+
+
+
+# force in definition, so we can see whether we fail on call
+
+set global log_bin_trust_function_creators=1;
+
+delimiter |;
+create function fn16456()
+ returns int
+begin
+ return unix_timestamp();
+end|
+delimiter ;|
+
+set global log_bin_trust_function_creators=0;
+
+
+
+# allow funcall in RBR
+
+set binlog_format=ROW;
+
+--replace_column 1 timestamp
+select fn16456();
+
+
+
+# fail funcall in SBR
+
+set binlog_format=STATEMENT;
+
+--error ER_BINLOG_UNSAFE_ROUTINE
+select fn16456();
+
+
+
+# clean
+
+drop function fn16456;
+
+
+
+# success in definition with deterministic
+
+set global log_bin_trust_function_creators=0;
+
+delimiter |;
+create function fn16456()
+ returns int deterministic
+begin
+ return unix_timestamp();
+end|
+delimiter ;|
+
+
+
+# allow funcall in RBR
+
+set binlog_format=ROW;
+
+--replace_column 1 timestamp
+select fn16456();
+
+
+
+# allow funcall in SBR
+
+set binlog_format=STATEMENT;
+
+--replace_column 1 timestamp
+select fn16456();
+
+
+
+# clean
+
+drop function fn16456;
+
+
+# success in definition with NO SQL
+
+set global log_bin_trust_function_creators=0;
+
+delimiter |;
+create function fn16456()
+ returns int no sql
+begin
+ return unix_timestamp();
+end|
+delimiter ;|
+
+
+
+# allow funcall in RBR
+
+set binlog_format=ROW;
+
+--replace_column 1 timestamp
+select fn16456();
+
+
+
+# allow funcall in SBR
+
+set binlog_format=STATEMENT;
+
+--replace_column 1 timestamp
+select fn16456();
+
+
+# clean
+
+drop function fn16456;
+
+
+
+# success in definition with reads sql data
+
+set global log_bin_trust_function_creators=0;
+
+delimiter |;
+create function fn16456()
+ returns int reads sql data
+begin
+ return unix_timestamp();
+end|
+delimiter ;|
+
+
+
+# allow funcall in RBR
+
+set binlog_format=ROW;
+
+--replace_column 1 timestamp
+select fn16456();
+
+
+
+# allow funcall in SBR
+
+set binlog_format=STATEMENT;
+
+--replace_column 1 timestamp
+select fn16456();
+
+
+
+# clean
+
+drop function fn16456;
+
+
+
+# restore status
+
+--disable_query_log
+eval set binlog_format=$oblf;
+eval set global log_bin_trust_function_creators=$otfc;
+--enable_query_log
diff --git a/mysql-test/suite/binlog/t/binlog_sql_mode.test b/mysql-test/suite/binlog/t/binlog_sql_mode.test
index 1777f8cb561..ab4f6450543 100644
--- a/mysql-test/suite/binlog/t/binlog_sql_mode.test
+++ b/mysql-test/suite/binlog/t/binlog_sql_mode.test
@@ -8,7 +8,6 @@
# Scan binlog file to check if the sql_mode is still set to 0 before generating binlog event
#
--- source include/master-slave.inc
-- source include/have_log_bin.inc
# BUG#39526 sql_mode not retained in binary log for CREATE PROCEDURE
@@ -50,10 +49,10 @@ CREATE EVENT testEvent ON SCHEDULE
END;|
DELIMITER ;|
---echo Chceck Result
+--echo Check Result
let $MYSQLD_DATADIR= `select @@datadir`;
---exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog
+--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog"))