List:Commits« Previous MessageNext Message »
From:Dao-Gang.Qu Date:January 5 2010 10:00am
Subject:bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3302) Bug#49132
View as plain text  
#At file:///home/daogangqu/mysql/bzrwork/bug49132/mysql-5.1-bugteam/ based on revid:ramil@stripped

 3302 Dao-Gang.Qu@stripped	2010-01-05
      Bug #49132  	Replication failure on temporary table + DDL
      
      In RBR, DDL statement will change binlog format to non row-based
      format, and then manipulating a temporary table can not reset binlog
      format to row-based format rightly. So that the manipulated statement
      is binlogged with statement-based format.
      
      To fix the problem, restore the state of binlog format after the DDL
      statement is binlogged.
     @ mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test
        Added test file to execute DDL statement when a temporary table is open.
     @ mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL_ACL.test
        Added the test file to verify if executing ACL statement before
        trying to manipulate a temporary table causes row-based replication
        to break with error 'table does not exist'.
     @ mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
        Correct the test result, all the above binlog event
        should be row-based after the bug49132 is fixed IN RBR.
     @ mysql-test/suite/ndb/r/ndb_tmp_table_and_DDL.result
        Test result for bug#49132 base on ndb engine.
     @ mysql-test/suite/ndb/t/ndb_tmp_table_and_DDL.test
        Added the test file to verify if executing DDL statement before
        trying to manipulate a temporary table causes row-based replication
        to break with error 'table does not exist' base on ndb engine.
     @ mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result
        Test result for bug#49132 base on myisam engine.
     @ mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test
        Added the test file to verify if executing DDL statement before
        trying to manipulate a temporary table causes row-based replication
        to break with error 'table does not exist' base on myisam engine.
     @ sql/event_db_repository.cc
        Added code to restore the state of binlog format after the DDL
        statement is binlogged.
     @ sql/events.cc
        Added code to restore the state of binlog format after the DDL
        statement is binlogged.
     @ sql/sp.cc
        Added code to restore the state of binlog format after the DDL
        statement is binlogged.
     @ sql/sql_acl.cc
        Added code to restore the state of binlog format after the DDL
        statement is binlogged.
     @ sql/sql_udf.cc
        Added code to restore the state of binlog format after the DDL
        statement is binlogged.

    added:
      mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test
      mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL_ACL.test
      mysql-test/suite/ndb/r/ndb_tmp_table_and_DDL.result
      mysql-test/suite/ndb/t/ndb_tmp_table_and_DDL.test
      mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result
      mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test
    modified:
      mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
      sql/event_db_repository.cc
      sql/events.cc
      sql/sp.cc
      sql/sql_acl.cc
      sql/sql_udf.cc
=== added file 'mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test'
--- a/mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test	2010-01-05 10:00:31 +0000
@@ -0,0 +1,8 @@
+#
+# Execute DDL statement when a temporary table is open.
+#
+
+CREATE TEMPORARY TABLE t1 (a int);
+eval $query;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;

=== added file 'mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL_ACL.test'
--- a/mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL_ACL.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL_ACL.test	2010-01-05 10:00:31 +0000
@@ -0,0 +1,96 @@
+#
+# This test verify if executing ACL statement before trying to manipulate
+# a temporary table causes row-based replication to break with error 'table
+# does not exist'.
+#
+
+# CREATE USER when a temporary table is open. 
+let $query= CREATE USER test_1@localhost;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# TABLE TABLE when a temporary table is open.
+let $query= create table t2 (a int, b int) engine= $engine_type;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# TABLE GRANT when a temporary table is open.
+let $query= grant select on t2 to test_1@localhost;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# MYSQL GRANT when a temporary table is open.
+let $query= grant usage on *.* to test_1@localhost;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# REVOKE ALL PRIVILEGES when a temporary table is open.
+let $query= revoke all privileges on t2 from test_1@localhost;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# REVOKE PRIVILEGE when a temporary table is open.
+let $query= revoke usage on *.* from test_1@localhost;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# DROP TABLE when a temporary table is open.
+let $query= DROP TABLE t2;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# RENAME USER when a temporary table is open.
+let $query= RENAME USER test_1@localhost TO test_2@localhost;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# DROP USER when a temporary table is open.
+let $query= drop user test_2@localhost;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# Test ACL statement in sub statement
+delimiter |;
+CREATE PROCEDURE p1()
+BEGIN
+    # CREATE USER when a temporary table is open. 
+    CREATE TEMPORARY TABLE t1 (a int);
+    CREATE USER test_1@localhost;
+    insert into t1 values (1);
+    DROP TEMPORARY TABLE t1;
+
+    # TABLE GRANT when a temporary table is open.
+    CREATE TEMPORARY TABLE t1 (a int);
+    create table t2 (a int, b int);
+    grant select on t2 to test_1@localhost;
+    insert into t1 values (1);
+    DROP TEMPORARY TABLE t1;
+
+    # MYSQL GRANT when a temporary table is open.
+    CREATE TEMPORARY TABLE t1 (a int);
+    grant usage on *.* to test_1@localhost;
+    insert into t1 values (1);
+    DROP TEMPORARY TABLE t1;
+
+    # REVOKE PRIVILEGES when a temporary table is open.
+    CREATE TEMPORARY TABLE t1 (a int);
+    revoke all privileges on t2 from test_1@localhost;
+    revoke usage on *.* from test_1@localhost;
+    insert into t1 values (1);
+    DROP TEMPORARY TABLE t1;
+
+    # RENAME USER when a temporary table is open.
+    CREATE TEMPORARY TABLE t1 (a int);
+    RENAME USER test_1@localhost TO test_2@localhost;
+    insert into t1 values (1);
+    DROP TEMPORARY TABLE t1;
+
+    # DROP USER when a temporary table is open.
+    CREATE TEMPORARY TABLE t1 (a int);
+    drop user test_2@localhost;
+    insert into t1 values (1);
+    DROP TEMPORARY TABLE t1;
+
+    # DROP TABLE when a temporary table is open.
+    CREATE TEMPORARY TABLE t1 (a int);
+    drop table t2;
+    insert into t1 values (1);
+    DROP TEMPORARY TABLE t1;
+END |
+delimiter ;|
+DROP PROCEDURE p1;
+
+
+
+

=== modified file 'mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result'
--- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2009-10-06 10:25:36 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2010-01-05 10:00:31 +0000
@@ -772,8 +772,11 @@ 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	#	Intvar	#	#	INSERT_ID=3
-master-bin.000001	#	Query	#	#	use `test`; insert into t2 values (bug27417(2))
+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
 select count(*) from t1 /* must be 3 */;
 count(*)
 3
@@ -787,8 +790,11 @@ count(*)
 2
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Intvar	#	#	INSERT_ID=4
-master-bin.000001	#	Query	#	#	use `test`; delete from t2 where a=bug27417(3)
+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	#	#	COMMIT
 select count(*) from t1 /* must be 5 */;
 count(*)
 5
@@ -810,8 +816,9 @@ ERROR 23000: Duplicate entry '1' for key
 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	#	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
 select count(*) from t1 /* must be 1 */;
 count(*)
@@ -825,8 +832,10 @@ ERROR 23000: Duplicate entry '2' for key
 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	#	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
 select count(*) from t1 /* must be 2 */;
 count(*)
@@ -838,8 +847,13 @@ 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	#	Intvar	#	#	INSERT_ID=4
-master-bin.000001	#	Query	#	#	use `test`; update t3 set b=b+bug27417(1)
+master-bin.000001	#	Query	#	#	BEGIN
+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: #
+master-bin.000001	#	Update_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	ROLLBACK
 select count(*) from t1 /* must be 2 */;
 count(*)
 2
@@ -853,8 +867,9 @@ ERROR 23000: Duplicate entry '2' for key
 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	#	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
 select count(*) from t1 /* must be 4 */;
 count(*)
@@ -869,7 +884,7 @@ UPDATE t3,t4 SET t3.a=t4.a + bug27417(1)
 ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
 select count(*) from t1 /* must be 1 */;
 count(*)
-1
+2
 drop table t4;
 delete from t1;
 delete from t2;
@@ -884,8 +899,10 @@ ERROR 23000: Duplicate entry '1' for key
 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	#	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
 select count(*) from t1 /* must be 1 */;
 count(*)
@@ -904,7 +921,11 @@ ERROR 23000: Duplicate entry '1' for key
 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	#	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
 select count(*) from t1 /* must be 1 */;
 count(*)
@@ -924,12 +945,11 @@ 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	#	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	#	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
 drop trigger trg_del_t2;
 drop table t1,t2,t3,t4,t5;

=== added file 'mysql-test/suite/ndb/r/ndb_tmp_table_and_DDL.result'
--- a/mysql-test/suite/ndb/r/ndb_tmp_table_and_DDL.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/r/ndb_tmp_table_and_DDL.result	2010-01-05 10:00:31 +0000
@@ -0,0 +1,77 @@
+CREATE TEMPORARY TABLE t1 (a int);
+CREATE USER test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+create table t2 (a int, b int) engine= ndb;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+grant select on t2 to test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+grant usage on *.* to test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+revoke all privileges on t2 from test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+revoke usage on *.* from test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+DROP TABLE t2;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+RENAME USER test_1@localhost TO test_2@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+drop user test_2@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE PROCEDURE p1()
+BEGIN
+# CREATE USER when a temporary table is open. 
+CREATE TEMPORARY TABLE t1 (a int);
+CREATE USER test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# TABLE GRANT when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+create table t2 (a int, b int);
+grant select on t2 to test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# MYSQL GRANT when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+grant usage on *.* to test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# REVOKE PRIVILEGES when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+revoke all privileges on t2 from test_1@localhost;
+revoke usage on *.* from test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# RENAME USER when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+RENAME USER test_1@localhost TO test_2@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# DROP USER when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+drop user test_2@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# DROP TABLE when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+drop table t2;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+END |
+DROP PROCEDURE p1;

=== added file 'mysql-test/suite/ndb/t/ndb_tmp_table_and_DDL.test'
--- a/mysql-test/suite/ndb/t/ndb_tmp_table_and_DDL.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/t/ndb_tmp_table_and_DDL.test	2010-01-05 10:00:31 +0000
@@ -0,0 +1,11 @@
+#
+# Bug#49132 
+# This test verifies if executing DDL statement before trying to manipulate
+# a temporary table causes row-based replication to break with error 'table
+# does not exist'.
+#
+
+source include/have_ndb.inc;
+
+let $engine_type= ndb;
+source extra/rpl_tests/rpl_tmp_table_and_DDL_ACL.test;

=== added file 'mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result'
--- a/mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result	2010-01-05 10:00:31 +0000
@@ -0,0 +1,127 @@
+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;
+CREATE TEMPORARY TABLE t1 (a int);
+CREATE USER test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+create table t2 (a int, b int) engine= myisam;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+grant select on t2 to test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+grant usage on *.* to test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+revoke all privileges on t2 from test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+revoke usage on *.* from test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+DROP TABLE t2;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+RENAME USER test_1@localhost TO test_2@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+drop user test_2@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE PROCEDURE p1()
+BEGIN
+# CREATE USER when a temporary table is open. 
+CREATE TEMPORARY TABLE t1 (a int);
+CREATE USER test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# TABLE GRANT when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+create table t2 (a int, b int);
+grant select on t2 to test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# MYSQL GRANT when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+grant usage on *.* to test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# REVOKE PRIVILEGES when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+revoke all privileges on t2 from test_1@localhost;
+revoke usage on *.* from test_1@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# RENAME USER when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+RENAME USER test_1@localhost TO test_2@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# DROP USER when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+drop user test_2@localhost;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+# DROP TABLE when a temporary table is open.
+CREATE TEMPORARY TABLE t1 (a int);
+drop table t2;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+END |
+DROP PROCEDURE p1;
+CREATE TEMPORARY TABLE t1 (a int);
+CREATE EVENT e1 ON SCHEDULE EVERY 10 HOUR DO SELECT 1;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+ALTER EVENT e1 ON SCHEDULE EVERY 20 HOUR DO SELECT 1;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+DROP EVENT IF EXISTS e1;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+CREATE PROCEDURE p1() SELECT 1;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+ALTER PROCEDURE p1 SQL SECURITY INVOKER;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+DROP PROCEDURE p1;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+CREATE FUNCTION f1() RETURNS INT RETURN 123;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+ALTER FUNCTION f1 SQL SECURITY INVOKER;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+DROP FUNCTION f1;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+CREATE DATABASE mysqltest1;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;
+CREATE TEMPORARY TABLE t1 (a int);
+DROP DATABASE mysqltest1;
+insert into t1 values (1);
+DROP TEMPORARY TABLE t1;

=== added file 'mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test'
--- a/mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test	2010-01-05 10:00:31 +0000
@@ -0,0 +1,57 @@
+#
+# Bug#49132 
+# This test verifies if executing DDL statement before trying to manipulate
+# a temporary table causes row-based replication to break with error 'table
+# does not exist'.
+#
+
+source include/master-slave.inc;
+source include/have_binlog_format_row.inc;
+
+let $engine_type= myisam;
+source extra/rpl_tests/rpl_tmp_table_and_DDL_ACL.test;
+
+# CREATE EVENT when a temporary table is open.
+let $query= CREATE EVENT e1 ON SCHEDULE EVERY 10 HOUR DO SELECT 1;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# ALTER EVENT when a temporary table is open.
+let $query= ALTER EVENT e1 ON SCHEDULE EVERY 20 HOUR DO SELECT 1;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# DROP EVENT when a temporary table is open.
+let $query= DROP EVENT IF EXISTS e1;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# CREATE PROCEDURE when a temporary table is open.
+let $query= CREATE PROCEDURE p1() SELECT 1;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# Alter PROCEDURE when a temporary table is open.
+let $query= ALTER PROCEDURE p1 SQL SECURITY INVOKER;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# DROP PROCEDURE when a temporary table is open.
+let $query= DROP PROCEDURE p1;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# CREATE FUNCTION when a temporary table is open.
+let $query= CREATE FUNCTION f1() RETURNS INT RETURN 123;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# ALTER FUNCTION when a temporary table is open.
+let $query= ALTER FUNCTION f1 SQL SECURITY INVOKER;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# DROP FUNCTION when a temporary table is open.
+let $query= DROP FUNCTION f1;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# CREATE DATABASE when a temporary table is open.
+let $query= CREATE DATABASE mysqltest1;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+
+# DROP DATABASE when a temporary table is open.
+let $query= DROP DATABASE mysqltest1;
+source extra/rpl_tests/rpl_tmp_table_and_DDL.test;
+

=== modified file 'sql/event_db_repository.cc'
--- a/sql/event_db_repository.cc	2009-11-21 11:18:21 +0000
+++ b/sql/event_db_repository.cc	2010-01-05 10:00:31 +0000
@@ -1045,6 +1045,7 @@ update_timing_fields_for_event(THD *thd,
   TABLE *table= NULL;
   Field **fields;
   int ret= 1;
+  bool save_binlog_row_based;
 
   DBUG_ENTER("Event_db_repository::update_timing_fields_for_event");
 
@@ -1052,6 +1053,7 @@ update_timing_fields_for_event(THD *thd,
     Turn off row binlogging of event timing updates. These are not used
     for RBR of events replicated to the slave.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   if (thd->current_stmt_binlog_row_based)
     thd->clear_current_stmt_binlog_row_based();
 
@@ -1095,6 +1097,8 @@ update_timing_fields_for_event(THD *thd,
 end:
   if (table)
     close_thread_tables(thd);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
 
   DBUG_RETURN(test(ret));
 }

=== modified file 'sql/events.cc'
--- a/sql/events.cc	2009-10-16 10:29:42 +0000
+++ b/sql/events.cc	2010-01-05 10:00:31 +0000
@@ -389,6 +389,7 @@ Events::create_event(THD *thd, Event_par
                      bool if_not_exists)
 {
   int ret;
+  bool save_binlog_row_based;
   DBUG_ENTER("Events::create_event");
 
   /*
@@ -430,6 +431,7 @@ Events::create_event(THD *thd, Event_par
     Turn off row binlogging of this statement and use statement-based 
     so that all supporting tables are updated for CREATE EVENT command.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   if (thd->current_stmt_binlog_row_based)
     thd->clear_current_stmt_binlog_row_based();
 
@@ -471,6 +473,8 @@ Events::create_event(THD *thd, Event_par
       {
         sql_print_error("Event Error: An error occurred while creating query string, "
                         "before writing it into binary log.");
+        /* Restore the state of binlog format */
+        thd->current_stmt_binlog_row_based= save_binlog_row_based;
         DBUG_RETURN(TRUE);
       }
       /* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER 
@@ -479,6 +483,8 @@ Events::create_event(THD *thd, Event_par
     }
   }
   pthread_mutex_unlock(&LOCK_event_metadata);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
 
   DBUG_RETURN(ret);
 }
@@ -508,6 +514,7 @@ Events::update_event(THD *thd, Event_par
                      LEX_STRING *new_dbname, LEX_STRING *new_name)
 {
   int ret;
+  bool save_binlog_row_based;
   Event_queue_element *new_element;
 
   DBUG_ENTER("Events::update_event");
@@ -563,6 +570,7 @@ Events::update_event(THD *thd, Event_par
     Turn off row binlogging of this statement and use statement-based 
     so that all supporting tables are updated for UPDATE EVENT command.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   if (thd->current_stmt_binlog_row_based)
     thd->clear_current_stmt_binlog_row_based();
 
@@ -600,6 +608,8 @@ Events::update_event(THD *thd, Event_par
     }
   }
   pthread_mutex_unlock(&LOCK_event_metadata);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
 
   DBUG_RETURN(ret);
 }
@@ -633,6 +643,7 @@ bool
 Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
 {
   int ret;
+  bool save_binlog_row_based;
   DBUG_ENTER("Events::drop_event");
 
   /*
@@ -660,6 +671,7 @@ Events::drop_event(THD *thd, LEX_STRING 
     Turn off row binlogging of this statement and use statement-based so
     that all supporting tables are updated for DROP EVENT command.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   if (thd->current_stmt_binlog_row_based)
     thd->clear_current_stmt_binlog_row_based();
 
@@ -674,6 +686,8 @@ Events::drop_event(THD *thd, LEX_STRING 
     write_bin_log(thd, TRUE, thd->query(), thd->query_length());
   }
   pthread_mutex_unlock(&LOCK_event_metadata);
+  /* Restore the state of binlog format */
+    thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(ret);
 }
 

=== modified file 'sql/sp.cc'
--- a/sql/sp.cc	2009-12-02 11:17:08 +0000
+++ b/sql/sp.cc	2010-01-05 10:00:31 +0000
@@ -896,6 +896,8 @@ sp_create_routine(THD *thd, int type, sp
 
   bool store_failed= FALSE;
 
+  bool save_binlog_row_based;
+
   DBUG_ENTER("sp_create_routine");
   DBUG_PRINT("enter", ("type: %d  name: %.*s",type, (int) sp->m_name.length,
                        sp->m_name.str));
@@ -913,6 +915,7 @@ sp_create_routine(THD *thd, int type, sp
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
   saved_count_cuted_fields= thd->count_cuted_fields;
@@ -1118,6 +1121,8 @@ done:
   thd->variables.sql_mode= saved_mode;
 
   close_thread_tables(thd);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(ret);
 }
 
@@ -1142,6 +1147,7 @@ sp_drop_routine(THD *thd, int type, sp_n
 {
   TABLE *table;
   int ret;
+  bool save_binlog_row_based;
   DBUG_ENTER("sp_drop_routine");
   DBUG_PRINT("enter", ("type: %d  name: %.*s",
 		       type, (int) name->m_name.length, name->m_name.str));
@@ -1154,6 +1160,7 @@ sp_drop_routine(THD *thd, int type, sp_n
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
   if (!(table= open_proc_table_for_update(thd)))
@@ -1171,6 +1178,8 @@ sp_drop_routine(THD *thd, int type, sp_n
   }
 
   close_thread_tables(thd);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(ret);
 }
 
@@ -1197,6 +1206,7 @@ sp_update_routine(THD *thd, int type, sp
 {
   TABLE *table;
   int ret;
+  bool save_binlog_row_based;
   DBUG_ENTER("sp_update_routine");
   DBUG_PRINT("enter", ("type: %d  name: %.*s",
 		       type, (int) name->m_name.length, name->m_name.str));
@@ -1208,6 +1218,7 @@ sp_update_routine(THD *thd, int type, sp
     row-based replication. The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
   if (!(table= open_proc_table_for_update(thd)))
@@ -1241,6 +1252,8 @@ sp_update_routine(THD *thd, int type, sp
   }
 
   close_thread_tables(thd);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(ret);
 }
 

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2009-12-18 18:44:24 +0000
+++ b/sql/sql_acl.cc	2010-01-05 10:00:31 +0000
@@ -2973,6 +2973,7 @@ int mysql_table_grant(THD *thd, TABLE_LI
   TABLE_LIST tables[3];
   bool create_new_users=0;
   char *db_name, *table_name;
+  bool save_binlog_row_based;
   DBUG_ENTER("mysql_table_grant");
 
   if (!initialized)
@@ -3068,6 +3069,7 @@ int mysql_table_grant(THD *thd, TABLE_LI
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
 #ifdef HAVE_REPLICATION
@@ -3083,7 +3085,11 @@ int mysql_table_grant(THD *thd, TABLE_LI
     */
     tables[0].updating= tables[1].updating= tables[2].updating= 1;
     if (!(thd->spcont || rpl_filter->tables_ok(0, tables)))
+    {
+      /* Restore the state of binlog format */
+      thd->current_stmt_binlog_row_based= save_binlog_row_based;
       DBUG_RETURN(FALSE);
+    }
   }
 #endif
 
@@ -3096,6 +3102,8 @@ int mysql_table_grant(THD *thd, TABLE_LI
   if (simple_open_n_lock_tables(thd,tables))
   {						// Should never happen
     close_thread_tables(thd);			/* purecov: deadcode */
+    /* Restore the state of binlog format */
+    thd->current_stmt_binlog_row_based= save_binlog_row_based;
     DBUG_RETURN(TRUE);				/* purecov: deadcode */
   }
 
@@ -3222,6 +3230,8 @@ int mysql_table_grant(THD *thd, TABLE_LI
 
   /* Tables are automatically closed */
   thd->lex->restore_backup_query_tables_list(&backup);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(result);
 }
 
@@ -3250,6 +3260,7 @@ bool mysql_routine_grant(THD *thd, TABLE
   TABLE_LIST tables[2];
   bool create_new_users=0, result=0;
   char *db_name, *table_name;
+  bool save_binlog_row_based;
   DBUG_ENTER("mysql_routine_grant");
 
   if (!initialized)
@@ -3285,6 +3296,7 @@ bool mysql_routine_grant(THD *thd, TABLE
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
 #ifdef HAVE_REPLICATION
@@ -3300,13 +3312,19 @@ bool mysql_routine_grant(THD *thd, TABLE
     */
     tables[0].updating= tables[1].updating= 1;
     if (!(thd->spcont || rpl_filter->tables_ok(0, tables)))
+    {
+      /* Restore the state of binlog format */
+      thd->current_stmt_binlog_row_based= save_binlog_row_based;
       DBUG_RETURN(FALSE);
+    }
   }
 #endif
 
   if (simple_open_n_lock_tables(thd,tables))
   {						// Should never happen
     close_thread_tables(thd);
+    /* Restore the state of binlog format */
+    thd->current_stmt_binlog_row_based= save_binlog_row_based;
     DBUG_RETURN(TRUE);
   }
 
@@ -3382,6 +3400,8 @@ bool mysql_routine_grant(THD *thd, TABLE
   }
 
   rw_unlock(&LOCK_grant);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
 
   /* Tables are automatically closed */
   DBUG_RETURN(result);
@@ -3396,6 +3416,7 @@ bool mysql_grant(THD *thd, const char *d
   char tmp_db[NAME_LEN+1];
   bool create_new_users=0;
   TABLE_LIST tables[2];
+  bool save_binlog_row_based;
   DBUG_ENTER("mysql_grant");
   if (!initialized)
   {
@@ -3424,6 +3445,7 @@ bool mysql_grant(THD *thd, const char *d
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
 #ifdef HAVE_REPLICATION
@@ -3439,13 +3461,19 @@ bool mysql_grant(THD *thd, const char *d
     */
     tables[0].updating= tables[1].updating= 1;
     if (!(thd->spcont || rpl_filter->tables_ok(0, tables)))
+    {
+      /* Restore the state of binlog format */
+      thd->current_stmt_binlog_row_based= save_binlog_row_based;
       DBUG_RETURN(FALSE);
+    }
   }
 #endif
 
   if (simple_open_n_lock_tables(thd,tables))
   {						// This should never happen
     close_thread_tables(thd);			/* purecov: deadcode */
+    /* Restore the state of binlog format */
+    thd->current_stmt_binlog_row_based= save_binlog_row_based;
     DBUG_RETURN(TRUE);				/* purecov: deadcode */
   }
 
@@ -3505,6 +3533,8 @@ bool mysql_grant(THD *thd, const char *d
 
   if (!result)
     my_ok(thd);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
 
   DBUG_RETURN(result);
 }
@@ -5661,6 +5691,7 @@ bool mysql_create_user(THD *thd, List <L
   List_iterator <LEX_USER> user_list(list);
   TABLE_LIST tables[GRANT_TABLES];
   bool some_users_created= FALSE;
+  bool save_binlog_row_based;
   DBUG_ENTER("mysql_create_user");
 
   /*
@@ -5668,11 +5699,16 @@ bool mysql_create_user(THD *thd, List <L
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
   /* CREATE USER may be skipped on replication client. */
   if ((result= open_grant_tables(thd, tables)))
+  {
+    /* Restore the state of binlog format */
+    thd->current_stmt_binlog_row_based= save_binlog_row_based;
     DBUG_RETURN(result != 1);
+  }
 
   rw_wrlock(&LOCK_grant);
   VOID(pthread_mutex_lock(&acl_cache->lock));
@@ -5715,6 +5751,8 @@ bool mysql_create_user(THD *thd, List <L
 
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(result);
 }
 
@@ -5741,6 +5779,7 @@ bool mysql_drop_user(THD *thd, List <LEX
   TABLE_LIST tables[GRANT_TABLES];
   bool some_users_deleted= FALSE;
   ulong old_sql_mode= thd->variables.sql_mode;
+  bool save_binlog_row_based;
   DBUG_ENTER("mysql_drop_user");
 
   /*
@@ -5748,11 +5787,16 @@ bool mysql_drop_user(THD *thd, List <LEX
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
   /* DROP USER may be skipped on replication client. */
   if ((result= open_grant_tables(thd, tables)))
+  {
+    /* Restore the state of binlog format */
+    thd->current_stmt_binlog_row_based= save_binlog_row_based;
     DBUG_RETURN(result != 1);
+  }
 
   thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
 
@@ -5789,6 +5833,8 @@ bool mysql_drop_user(THD *thd, List <LEX
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
   thd->variables.sql_mode= old_sql_mode;
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(result);
 }
 
@@ -5815,6 +5861,7 @@ bool mysql_rename_user(THD *thd, List <L
   List_iterator <LEX_USER> user_list(list);
   TABLE_LIST tables[GRANT_TABLES];
   bool some_users_renamed= FALSE;
+  bool save_binlog_row_based;
   DBUG_ENTER("mysql_rename_user");
 
   /*
@@ -5822,11 +5869,16 @@ bool mysql_rename_user(THD *thd, List <L
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
   /* RENAME USER may be skipped on replication client. */
   if ((result= open_grant_tables(thd, tables)))
+  {
+    /* Restore the state of binlog format */
+    thd->current_stmt_binlog_row_based= save_binlog_row_based;
     DBUG_RETURN(result != 1);
+  }
 
   rw_wrlock(&LOCK_grant);
   VOID(pthread_mutex_lock(&acl_cache->lock));
@@ -5873,6 +5925,8 @@ bool mysql_rename_user(THD *thd, List <L
 
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(result);
 }
 
@@ -5897,6 +5951,7 @@ bool mysql_revoke_all(THD *thd,  List <L
   int result;
   ACL_DB *acl_db;
   TABLE_LIST tables[GRANT_TABLES];
+  bool save_binlog_row_based;
   DBUG_ENTER("mysql_revoke_all");
 
   /*
@@ -5904,10 +5959,15 @@ bool mysql_revoke_all(THD *thd,  List <L
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
   if ((result= open_grant_tables(thd, tables)))
+  {
+    /* Restore the state of binlog format */
+    thd->current_stmt_binlog_row_based= save_binlog_row_based;
     DBUG_RETURN(result != 1);
+  }
 
   rw_wrlock(&LOCK_grant);
   VOID(pthread_mutex_lock(&acl_cache->lock));
@@ -6058,6 +6118,8 @@ bool mysql_revoke_all(THD *thd,  List <L
 
   if (result)
     my_message(ER_REVOKE_GRANTS, ER(ER_REVOKE_GRANTS), MYF(0));
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
 
   DBUG_RETURN(result);
 }
@@ -6141,6 +6203,7 @@ bool sp_revoke_privileges(THD *thd, cons
   TABLE_LIST tables[GRANT_TABLES];
   HASH *hash= is_proc ? &proc_priv_hash : &func_priv_hash;
   Silence_routine_definer_errors error_handler;
+  bool save_binlog_row_based;
   DBUG_ENTER("sp_revoke_privileges");
 
   if ((result= open_grant_tables(thd, tables)))
@@ -6157,6 +6220,7 @@ bool sp_revoke_privileges(THD *thd, cons
     row-based replication.  The flag will be reset at the end of the
     statement.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   thd->clear_current_stmt_binlog_row_based();
 
   /* Remove procedure access */
@@ -6193,6 +6257,8 @@ bool sp_revoke_privileges(THD *thd, cons
   close_thread_tables(thd);
 
   thd->pop_internal_handler();
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
 
   DBUG_RETURN(error_handler.has_errors());
 }

=== modified file 'sql/sql_udf.cc'
--- a/sql/sql_udf.cc	2009-10-16 10:29:42 +0000
+++ b/sql/sql_udf.cc	2010-01-05 10:00:31 +0000
@@ -398,6 +398,7 @@ int mysql_create_function(THD *thd,udf_f
   TABLE *table;
   TABLE_LIST tables;
   udf_func *u_d;
+  bool save_binlog_row_based;
   DBUG_ENTER("mysql_create_function");
 
   if (!initialized)
@@ -437,6 +438,7 @@ int mysql_create_function(THD *thd,udf_f
     Turn off row binlogging of this statement and use statement-based 
     so that all supporting tables are updated for CREATE FUNCTION command.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   if (thd->current_stmt_binlog_row_based)
     thd->clear_current_stmt_binlog_row_based();
 
@@ -508,12 +510,16 @@ int mysql_create_function(THD *thd,udf_f
   /* Binlog the create function. */
   write_bin_log(thd, TRUE, thd->query(), thd->query_length());
 
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(0);
 
  err:
   if (new_dl)
     dlclose(dl);
   rw_unlock(&THR_LOCK_udf);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(1);
 }
 
@@ -525,6 +531,7 @@ int mysql_drop_function(THD *thd,const L
   udf_func *udf;
   char *exact_name_str;
   uint exact_name_len;
+  bool save_binlog_row_based;
   DBUG_ENTER("mysql_drop_function");
 
   if (!initialized)
@@ -540,6 +547,7 @@ int mysql_drop_function(THD *thd,const L
     Turn off row binlogging of this statement and use statement-based
     so that all supporting tables are updated for DROP FUNCTION command.
   */
+  save_binlog_row_based= thd->current_stmt_binlog_row_based;
   if (thd->current_stmt_binlog_row_based)
     thd->clear_current_stmt_binlog_row_based();
 
@@ -583,9 +591,13 @@ int mysql_drop_function(THD *thd,const L
   /* Binlog the drop function. */
   write_bin_log(thd, TRUE, thd->query(), thd->query_length());
 
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(0);
  err:
   rw_unlock(&THR_LOCK_udf);
+  /* Restore the state of binlog format */
+  thd->current_stmt_binlog_row_based= save_binlog_row_based;
   DBUG_RETURN(1);
 }
 


Attachment: [text/bzr-bundle] bzr/dao-gang.qu@sun.com-20100105100031-imxudah23cp1ymiw.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3302) Bug#49132Dao-Gang.Qu5 Jan
  • Re: bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3302)Bug#49132Libing Song8 Jan
    • Re: bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3302)Bug#49132Daogang Qu14 Jan
      • Re: bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3302)Bug#49132Libing Song14 Jan
        • Re: bzr commit into mysql-5.1-bugteam branch (Dao-Gang.Qu:3302)Bug#49132Daogang Qu14 Jan