List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:April 8 2011 5:20pm
Subject:bzr commit into mysql-trunk branch (alfranio.correia:3773) Bug#11763126
View as plain text  
#At file:///home/acorreia/workspace.oracle/repository.mysql/bzrwork/bug-11763126/mysql-trunk/ based on revid:alfranio.correia@stripped

 3773 Alfranio Correia	2011-04-08
      BUG#11763126
     @ mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc
        Improved the test case to cover the following cases:
        
        . beging (drop/create temporary table) (failed statement on T, N) commit/rollback
     @ mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test
        Improved the test case to cover the following cases:
        
        . beging (drop/create temporary table) (failed statement on T, N) commit/rollback
     @ mysql-test/extra/rpl_tests/rpl_temp_error.test
        Fixed typo.
     @ mysql-test/suite/rpl/r/rpl_DML_error.result
        Fixed typo.
     @ mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result
        Fixed typo and improved the test case according to the review suggestions.
     @ mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result
        Improved the test case to cover the following cases:
        
        . beging (drop/create temporary table) (failed statement on T, N) commit/rollback
     @ mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result
        Improved the test case to cover the following cases:
        
        . beging (drop/create temporary table) (failed statement on T, N) commit/rollback
     @ mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result
        Improved the test case to cover the following cases:
        
        . beging (drop/create temporary table) (failed statement on T, N) commit/rollback
     @ mysql-test/suite/rpl/t/rpl_DML_error.test
        Fixed typo.
     @ mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test
        Fixed typo and improved the test case according to the review suggestions.
     @ sql/binlog.cc
        Put a comment as requested in the review suggestions
        and improved/fixed the binlog_rollback().
     @ sql/ha_ndbcluster.cc
        Put a comment because we are not able to evaluate if
        all.mark_modified_non_trans_table is really necessary.
     @ sql/handler.h
        Moved both Ha_trx_info and THD_TRANS to sql_class.h.
     @ sql/log_event.cc
        Put a comment as requested in the review suggestions.
     @ sql/sql_class.h
        Moved both Ha_trx_info and THD_TRANS to sql_class.h and
        and changed modified_non_trans_table to mark_modified_non_trans_table.
     @ sql/sql_delete.cc
        Changed modified_non_trans_table to mark_modified_non_trans_table
     @ sql/sql_insert.cc
        Put a comment as requested in the review suggestions and 
        changed modified_non_trans_table to mark_modified_non_trans_table.
     @ sql/sql_load.cc
        Removed the unnecessary call to remark.
     @ sql/sql_parse.cc
        Put a comment as requested in the review suggestions.
     @ sql/sql_priv.h
        Put a comment as requested in the review suggestions.
     @ sql/sql_table.cc
        Fixed the error while dropping temporary tables with IF EXISTS.
     @ sql/sql_update.cc
        Changed modified_non_trans_table to mark_modified_non_trans_table.

    modified:
      mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc
      mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test
      mysql-test/extra/rpl_tests/rpl_temp_error.test
      mysql-test/r/read_only_innodb.result
      mysql-test/suite/rpl/r/rpl_DML_error.result
      mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result
      mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result
      mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result
      mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result
      mysql-test/suite/rpl/t/rpl_DML_error.test
      mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test
      sql/binlog.cc
      sql/binlog.h
      sql/ha_ndbcluster.cc
      sql/handler.h
      sql/log_event.cc
      sql/sql_class.h
      sql/sql_delete.cc
      sql/sql_insert.cc
      sql/sql_load.cc
      sql/sql_parse.cc
      sql/sql_priv.h
      sql/sql_table.cc
      sql/sql_update.cc
=== modified file 'mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc'
--- a/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc	2011-01-05 05:21:07 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.inc	2011-04-08 17:20:14 +0000
@@ -6,6 +6,12 @@ if (`SELECT HEX(@commands) = HEX('config
   connection master;
 
   #
+  # Index that is used as an Id to tables that trigger errors.
+  #
+  --let $tt_error_counter=0
+  --let $nt_error_counter=0
+
+  #
   # Creates a T-table that is never dropped.
   #
   --eval CREATE TABLE tt_xx_1 ( id INT ) ENGINE = Innodb
@@ -16,6 +22,37 @@ if (`SELECT HEX(@commands) = HEX('config
   --eval CREATE TABLE nt_xx_1 ( id INT ) ENGINE = MyIsam
 
   #
+  # Creates a T-table that is never dropped.
+  #
+  --eval CREATE TABLE tt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb
+
+  #
+  # Creates a N-table that is never dropped.
+  #
+  --eval CREATE TABLE nt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam
+
+  #
+  # Creates a T-table that is never dropped.
+  #
+  --eval CREATE TABLE tt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb
+
+  #
+  # Creates a N-table that is never dropped.
+  #
+  --eval CREATE TABLE nt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam
+
+  #
+  # Create a trigger nt_error_2 --> tt_error_2
+  #
+  DELIMITER |;
+  CREATE TRIGGER tr_i_nt_2_to_tt_2 AFTER INSERT ON nt_error_2 FOR EACH ROW
+  BEGIN
+    DECLARE in_stmt_id INTEGER;
+    INSERT INTO tt_error_2(id) VALUES (NEW.id);
+  END|
+  DELIMITER ;|
+
+  #
   # Creates a Temporary N-table that is never dropped.
   #
   --eval CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id INT ) ENGINE = MyIsam
@@ -162,6 +199,14 @@ if (`SELECT HEX(@commands) = HEX('clean'
 
   DROP TABLE IF EXISTS nt_xx_1;
 
+  DROP TABLE IF EXISTS tt_error_1;
+
+  DROP TABLE IF EXISTS nt_error_1;
+
+  DROP TABLE IF EXISTS tt_error_2;
+
+  DROP TABLE IF EXISTS nt_error_2;
+
   --let $n= $tot_table
   while ($n)
   { 
@@ -280,6 +325,30 @@ while (`SELECT HEX(@commands) != HEX('')
    --disable_query_log
   }
 
+  if (`SELECT HEX(@command) = HEX('Te')`)
+  {
+    --enable_query_log
+    --inc $tt_error_counter
+    eval INSERT INTO tt_error_1() VALUES ($tt_error_counter), ($tt_error_counter);
+   --disable_query_log
+  }
+
+  if (`SELECT HEX(@command) = HEX('Ne')`)
+  {
+    --enable_query_log
+    --inc $nt_error_counter
+    eval INSERT INTO nt_error_1() VALUES ($nt_error_counter), ($nt_error_counter);
+   --disable_query_log
+  }
+
+  if (`SELECT HEX(@command) = HEX('NeT-trig')`)
+  {
+    --enable_query_log
+    --inc $nt_error_counter
+    eval INSERT INTO nt_error_1() VALUES ($nt_error_counter), ($nt_error_counter);
+   --disable_query_log
+  }
+
   if (`SELECT HEX(@command) = HEX('N-Temp')`)
   {
     --enable_query_log

=== modified file 'mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test'
--- a/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test	2010-08-20 02:59:58 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_drop_create_temp_table.test	2011-04-08 17:20:14 +0000
@@ -2,7 +2,67 @@
 #  In this test case, we check how changes to temporary tables are written
 #  to the binary log.
 #
-#  (TODO --- GET INFO AS SOON AS THE SITE IS AVAILABLE)
+#
+# B - Begin
+# C - Commit
+# R - Rollback
+#
+#
+# T - Inserts a row into a T-table
+# N-Temp - Inserts a row into a temporary N-table.
+#
+#
+# T-SELECT-N-Temp - Selects from a temporary N-table and inserts
+#                   into a T-table.
+# N-SELECT-N-Temp - Selects from a temporary N-table and inserts
+#                   into a N-table.
+# T-SELECT-T-Temp - Selects from a temporary T-table and inserts
+#                   into a T-table.
+# N-SELECT-T-Temp - Selects from a temporary T-table and inserts
+#                   into a N-table.
+
+# Create-N-Temp - Creates a temporary N-table if a temporary N-table
+#                 was dropped before
+# Create-T-Temp - Creates a temporary T-table if a temporary T-table
+#                 was dropped before
+#
+#
+# Drop-Temp-T-Temp - Drops a temporary T-table if there is any
+# Drop-Temp-N-Temp - Drops a temporary N-table if there is any
+# Drop-Temp-TN-Temp - Drops both a temporary T-table and N-table if there
+#                     is any
+# Drop-Temp-TT-Temp - Drops two temporary T-tables if there is any
+# Drop-Temp-NN-Temp - Drops two temporary N-tables if there is any
+# Drop-Temp-Xe-Temp - Tries to drop a temporary table that does not exist
+# Drop-Temp-NXe-Temp - Drops a temporary N-table if there is any and
+#                      a temporary table that does not exist
+# Drop-Temp-TXe-Temp - Drops a temporary T-table if there is any and
+#                      a temporary table that does not exist
+#
+#
+# Drop-Temp-If-Xe-Temp - Tries to drop a temporary table that does not exist
+# Drop-Temp-If-TXe-Temp - Drops a temporary T-table if there is any and
+#                         a temporary table that does not exist
+#
+#
+# Drop-T - Drops a T-table if there is any
+# Drop-N - Drops a  N-table if there is any
+# Drop-Xe - Tries to drop a table that does not exist
+# Drop-TXe - Drops a T-table if there is any and a table that does
+#            not exist
+# Drop-NXe - Drops a N-table if there is any and a table that does
+#            not exist
+# Drop-TN - Drops both a T-table and N-table if there is any
+# Drop-TT - Drops two T-tables if there is any
+# Drop-NN - Drops two N-tables if there is any
+# Drop-N-TN-Temp - Drops a N-table and both a temporary T-table and
+#                  N-table if there is any
+#
+#
+# Drop-If-Xe - Tries to drop a table that does not exist
+# Drop-If-TXe - Drops a T-table if there is any and a table that does
+#               not exist
+#
 #
 # This test uses the commands available at:
 #   extra/rpl_tests/rpl_drop_create_temp_table.inc
@@ -62,7 +122,6 @@ SET @commands= 'Drop-Temp-TT-Temp';
 SET @commands= 'Drop-Temp-NN-Temp';
 --source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
-
 --echo
 --echo #
 --echo #2) Generates in the binlog what follows:
@@ -133,6 +192,14 @@ SET @commands= 'B T Drop-Temp-NN-Temp C'
 SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp C';
 --source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
 --echo
 --echo #
@@ -204,6 +271,14 @@ SET @commands= 'B T Drop-Temp-NN-Temp R'
 SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp R';
 --source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
 --echo #########################################################################
 --echo #                   2 - Tables dropped by "DROP TABLE"
@@ -321,6 +396,15 @@ SET @commands= 'B T Drop-Temp-N-Temp Cre
 SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp C';
 --source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
 --echo
 --echo #
 --echo #3) Generates in the binlog what follows:
@@ -331,6 +415,14 @@ SET @commands= 'B T Drop-Temp-N-Temp Cre
 SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp R';
 --source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
 --echo #########################################################################
 --echo #                     4 -  CHANGING TEMPORARY TABLES
@@ -353,6 +445,15 @@ SET @commands= 'B N N-Temp N-SELECT-T-Te
 SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp C';
 --source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Ne C';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Te C';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
 --echo
 --echo
 --echo #
@@ -370,6 +471,15 @@ SET @commands= 'B N N-Temp N-SELECT-T-Te
 SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp R';
 --source extra/rpl_tests/rpl_drop_create_temp_table.inc
 
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Ne R';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Te R';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R';
+--source extra/rpl_tests/rpl_drop_create_temp_table.inc
+
 --echo ###################################################################################
 --echo #                               CHECK CONSISTENCY
 --echo ###################################################################################

=== modified file 'mysql-test/extra/rpl_tests/rpl_temp_error.test'
--- a/mysql-test/extra/rpl_tests/rpl_temp_error.test	2011-01-05 05:21:07 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_temp_error.test	2011-04-08 17:20:14 +0000
@@ -1,4 +1,4 @@
-# An auxaliary file for causing temporary error on slave SQL thread.
+# An auxiliary file for causing temporary error on slave SQL thread.
 
 --echo # [ on slave ]
 connection slave;

=== modified file 'mysql-test/r/read_only_innodb.result'
--- a/mysql-test/r/read_only_innodb.result	2011-01-05 05:21:07 +0000
+++ b/mysql-test/r/read_only_innodb.result	2011-04-08 17:20:14 +0000
@@ -97,7 +97,7 @@ a
 2
 ROLLBACK;
 Warnings:
-Warning	1726	The creation of some temporary tables could not be rolled back.
+Warning	1732	The creation of some temporary tables could not be rolled back.
 SELECT * FROM temp;
 a
 DROP TABLE temp;

=== modified file 'mysql-test/suite/rpl/r/rpl_DML_error.result'
--- a/mysql-test/suite/rpl/r/rpl_DML_error.result	2011-01-05 05:21:07 +0000
+++ b/mysql-test/suite/rpl/r/rpl_DML_error.result	2011-04-08 17:20:14 +0000
@@ -1,6 +1,6 @@
 include/master-slave.inc
 [connection master]
-# Verify the statments can be binlogged correctly when error happens
+# Verify the statements can be binlogged correctly when error happens
 # ------------------------------------------------------------------
 CREATE TABLE t1(c1 INT KEY) ENGINE=MyISAM;
 CREATE TABLE t2(c1 INT KEY) ENGINE=MyISAM;

=== modified file 'mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result'
--- a/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result	2011-01-05 05:21:07 +0000
+++ b/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result	2011-04-08 17:20:14 +0000
@@ -190,13 +190,14 @@ INSERT INTO t1 VALUES(1, "master");
 SET @@session.binlog_direct_non_transactional_updates= FALSE;
 # [ on slave ]
 USE db1;
+SET @timeout_old= @@GLOBAL.innodb_lock_wait_timeout;
 SET GLOBAL innodb_lock_wait_timeout= 1;
 STOP SLAVE SQL_THREAD;
 include/wait_for_slave_sql_to_stop.inc
 START SLAVE SQL_THREAD;
 include/wait_for_slave_sql_to_start.inc
-# Verify the SQL thread don't retry the transaction when different
-# sort of statements has modified a non-transactional table.
+# Verify the SQL thread doesn't retry the transaction when one of
+# its statements has modified a non-transactional table.
 # ----------------------------------------------------------------
 
 # INSERT statement inserts a row to a non-transactional table.
@@ -335,8 +336,8 @@ ROLLBACK;
 START SLAVE SQL_THREAD;
 include/wait_for_slave_sql_to_start.inc
 
-# Verify the SQL thread don't retry the transaction if one of the
-# sub-statement has modified a non-transactional table.
+# Verify that the SQL thread doesn't retry the transaction if one
+# of the sub-statements has modified a non-transactional table.
 # ----------------------------------------------------------------
 CREATE FUNCTION f_insert()
 RETURNS INT
@@ -475,7 +476,7 @@ Last_SQL_Error = 'Error 'Lock wait timeo
 ROLLBACK;
 START SLAVE SQL_THREAD;
 include/wait_for_slave_sql_to_start.inc
-SET GLOBAL innodb_lock_wait_timeout= 50;
+SET @@global.innodb_lock_wait_timeout= @timeout_old;
 #
 # Clean up
 #

=== modified file 'mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result'
--- a/mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result	2011-01-05 05:21:07 +0000
+++ b/mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result	2011-04-08 17:20:14 +0000
@@ -7,6 +7,15 @@ call mtr.add_suppression("Unsafe stateme
 SET @commands= 'configure';
 CREATE TABLE tt_xx_1 ( id INT ) ENGINE = Innodb;
 CREATE TABLE nt_xx_1 ( id INT ) ENGINE = MyIsam;
+CREATE TABLE tt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb;
+CREATE TABLE nt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam;
+CREATE TABLE tt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb;
+CREATE TABLE nt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam;
+CREATE TRIGGER tr_i_nt_2_to_tt_2 AFTER INSERT ON nt_error_2 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+INSERT INTO tt_error_2(id) VALUES (NEW.id);
+END|
 CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id INT ) ENGINE = MyIsam;
 CREATE TEMPORARY TABLE tt_tmp_xx_1 ( id INT ) ENGINE = Innodb;
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2;
@@ -546,6 +555,75 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp C << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (1), (1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (1), (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1() VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (1), (1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1() VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (2), (2);
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (2), (2)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1() VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
 
 #
 #3) Generates in the binlog what follows:
@@ -659,8 +737,14 @@ DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
 Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
+Warnings:
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 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_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-If-Xe-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
 SET @commands= 'B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R';
@@ -676,11 +760,17 @@ Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
 Warnings:
 Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
 master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
 SET @commands= 'B T Drop-Temp-TXe-Temp R';
@@ -972,6 +1062,75 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (3), (3);
+ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (3), (3)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (2), (2);
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (4), (4);
+ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (4), (4)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R << -e-e-e-e-e-e-e-e-e-e-e-
+
 #########################################################################
 #                   2 - Tables dropped by "DROP TABLE"
 #########################################################################
@@ -1333,6 +1492,69 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp C << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (5), (5);
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (5), (5)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO tt_error_1() VALUES (3), (3);
+ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (6), (6);
+ERROR 23000: Duplicate entry '6' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (6), (6)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
 
 #
 #3) Generates in the binlog what follows:
@@ -1384,6 +1606,80 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	ROLLBACK
 -e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (7), (7);
+ERROR 23000: Duplicate entry '7' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	The creation of some temporary tables could not be rolled back.
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (7), (7)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO tt_error_1() VALUES (4), (4);
+ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	The creation of some temporary tables could not be rolled back.
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (8), (8);
+ERROR 23000: Duplicate entry '8' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	The creation of some temporary tables could not be rolled back.
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (8), (8)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R << -e-e-e-e-e-e-e-e-e-e-e-
+
 #########################################################################
 #                     4 -  CHANGING TEMPORARY TABLES
 #########################################################################
@@ -1465,6 +1761,65 @@ master-bin.000001	#	Write_rows	#	#	table
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp C << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Ne C';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (9), (9);
+ERROR 23000: Duplicate entry '9' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne C << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Te C';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (5), (5);
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Te C << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Te C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (10), (10);
+ERROR 23000: Duplicate entry '10' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
 
 
 #
@@ -1542,6 +1897,71 @@ master-bin.000001	#	Write_rows	#	#	table
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Ne R';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (11), (11);
+ERROR 23000: Duplicate entry '11' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne R << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Te R';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (6), (6);
+ERROR 23000: Duplicate entry '6' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Te R << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Te R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (12), (12);
+ERROR 23000: Duplicate entry '12' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R << -e-e-e-e-e-e-e-e-e-e-e-
+
 ###################################################################################
 #                               CHECK CONSISTENCY
 ###################################################################################
@@ -1551,6 +1971,10 @@ master-bin.000001	#	Query	#	#	COMMIT
 SET @commands= 'clean';
 DROP TABLE IF EXISTS tt_xx_1;
 DROP TABLE IF EXISTS nt_xx_1;
+DROP TABLE IF EXISTS tt_error_1;
+DROP TABLE IF EXISTS nt_error_1;
+DROP TABLE IF EXISTS tt_error_2;
+DROP TABLE IF EXISTS nt_error_2;
 DROP TABLE IF EXISTS nt_2;
 DROP TABLE IF EXISTS nt_1;
 DROP TABLE IF EXISTS tt_2;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result'
--- a/mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result	2011-01-05 05:21:07 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_drop_create_temp_table.result	2011-04-08 17:20:14 +0000
@@ -7,6 +7,15 @@ call mtr.add_suppression("Unsafe stateme
 SET @commands= 'configure';
 CREATE TABLE tt_xx_1 ( id INT ) ENGINE = Innodb;
 CREATE TABLE nt_xx_1 ( id INT ) ENGINE = MyIsam;
+CREATE TABLE tt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb;
+CREATE TABLE nt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam;
+CREATE TABLE tt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb;
+CREATE TABLE nt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam;
+CREATE TRIGGER tr_i_nt_2_to_tt_2 AFTER INSERT ON nt_error_2 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+INSERT INTO tt_error_2(id) VALUES (NEW.id);
+END|
 CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id INT ) ENGINE = MyIsam;
 CREATE TEMPORARY TABLE tt_tmp_xx_1 ( id INT ) ENGINE = Innodb;
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2;
@@ -579,6 +588,83 @@ master-bin.000001	#	Write_rows	#	#	table
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp C << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (1), (1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_xx_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_error_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_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (1), (1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_xx_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_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (2), (2);
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_xx_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_error_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_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
 
 #
 #3) Generates in the binlog what follows:
@@ -697,8 +783,15 @@ DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
 Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
+Warnings:
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 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_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-If-Xe-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
 SET @commands= 'B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R';
@@ -714,12 +807,19 @@ Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
 Warnings:
 Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 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_xx_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_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
 SET @commands= 'B T Drop-Temp-TXe-Temp R';
@@ -1028,6 +1128,80 @@ master-bin.000001	#	Write_rows	#	#	table
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (3), (3);
+ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (2), (2);
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (4), (4);
+ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.nt_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R << -e-e-e-e-e-e-e-e-e-e-e-
+
 #########################################################################
 #                   2 - Tables dropped by "DROP TABLE"
 #########################################################################
@@ -1397,6 +1571,68 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp C << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (5), (5);
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C << -b-b-b-b-b-b-b-b-b-b-b-
+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_error_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	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO tt_error_1() VALUES (3), (3);
+ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (6), (6);
+ERROR 23000: Duplicate entry '6' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+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_error_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	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
 
 #
 #3) Generates in the binlog what follows:
@@ -1444,6 +1680,79 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	ROLLBACK
 -e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (7), (7);
+ERROR 23000: Duplicate entry '7' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	The creation of some temporary tables could not be rolled back.
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R << -b-b-b-b-b-b-b-b-b-b-b-
+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_error_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	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO tt_error_1() VALUES (4), (4);
+ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	The creation of some temporary tables could not be rolled back.
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (8), (8);
+ERROR 23000: Duplicate entry '8' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	The creation of some temporary tables could not be rolled back.
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R << -b-b-b-b-b-b-b-b-b-b-b-
+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_error_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	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R << -e-e-e-e-e-e-e-e-e-e-e-
+
 #########################################################################
 #                     4 -  CHANGING TEMPORARY TABLES
 #########################################################################
@@ -1519,6 +1828,65 @@ master-bin.000001	#	Write_rows	#	#	table
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp C << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Ne C';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (9), (9);
+ERROR 23000: Duplicate entry '9' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne C << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Te C';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (5), (5);
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Te C << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Te C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (10), (10);
+ERROR 23000: Duplicate entry '10' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
 
 
 #
@@ -1596,6 +1964,71 @@ master-bin.000001	#	Write_rows	#	#	table
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Ne R';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (11), (11);
+ERROR 23000: Duplicate entry '11' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne R << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Te R';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (6), (6);
+ERROR 23000: Duplicate entry '6' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Te R << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Te R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (12), (12);
+ERROR 23000: Duplicate entry '12' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R << -b-b-b-b-b-b-b-b-b-b-b-
+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_xx_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_error_1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R << -e-e-e-e-e-e-e-e-e-e-e-
+
 ###################################################################################
 #                               CHECK CONSISTENCY
 ###################################################################################
@@ -1605,6 +2038,10 @@ master-bin.000001	#	Query	#	#	COMMIT
 SET @commands= 'clean';
 DROP TABLE IF EXISTS tt_xx_1;
 DROP TABLE IF EXISTS nt_xx_1;
+DROP TABLE IF EXISTS tt_error_1;
+DROP TABLE IF EXISTS nt_error_1;
+DROP TABLE IF EXISTS tt_error_2;
+DROP TABLE IF EXISTS nt_error_2;
 DROP TABLE IF EXISTS nt_2;
 DROP TABLE IF EXISTS nt_1;
 DROP TABLE IF EXISTS tt_2;

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result	2011-01-05 05:21:07 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_drop_create_temp_table.result	2011-04-08 17:20:14 +0000
@@ -7,6 +7,15 @@ call mtr.add_suppression("Unsafe stateme
 SET @commands= 'configure';
 CREATE TABLE tt_xx_1 ( id INT ) ENGINE = Innodb;
 CREATE TABLE nt_xx_1 ( id INT ) ENGINE = MyIsam;
+CREATE TABLE tt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb;
+CREATE TABLE nt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam;
+CREATE TABLE tt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb;
+CREATE TABLE nt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam;
+CREATE TRIGGER tr_i_nt_2_to_tt_2 AFTER INSERT ON nt_error_2 FOR EACH ROW
+BEGIN
+DECLARE in_stmt_id INTEGER;
+INSERT INTO tt_error_2(id) VALUES (NEW.id);
+END|
 CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id INT ) ENGINE = MyIsam;
 CREATE TEMPORARY TABLE tt_tmp_xx_1 ( id INT ) ENGINE = Innodb;
 DROP TEMPORARY TABLE IF EXISTS nt_tmp_2;
@@ -546,6 +555,75 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp C << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (1), (1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (1), (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1() VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (1), (1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1() VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (2), (2);
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (2), (2)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1() VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
 
 #
 #3) Generates in the binlog what follows:
@@ -659,8 +737,14 @@ DROP TEMPORARY TABLE IF EXISTS tt_xx_1;
 Warnings:
 Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
+Warnings:
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 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_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-If-Xe-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
 SET @commands= 'B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R';
@@ -676,11 +760,17 @@ Note	1051	Unknown table 'test.tt_xx_1'
 ROLLBACK;
 Warnings:
 Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
 -b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R << -b-b-b-b-b-b-b-b-b-b-b-
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
 master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE IF EXISTS `tt_xx_1` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
 SET @commands= 'B T Drop-Temp-TXe-Temp R';
@@ -972,6 +1062,75 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (3), (3);
+ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (3), (3)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Ne R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (2), (2);
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp Te R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R';
+BEGIN;
+INSERT INTO tt_xx_1() VALUES (1);
+DROP TEMPORARY TABLE nt_tmp_1, nt_tmp_2;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (4), (4);
+ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `nt_tmp_1`,`nt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (4), (4)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp NeT-trig R << -e-e-e-e-e-e-e-e-e-e-e-
+
 #########################################################################
 #                   2 - Tables dropped by "DROP TABLE"
 #########################################################################
@@ -1333,6 +1492,69 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp C << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (5), (5);
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (5), (5)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO tt_error_1() VALUES (3), (3);
+ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (6), (6);
+ERROR 23000: Duplicate entry '6' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (6), (6)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
 
 #
 #3) Generates in the binlog what follows:
@@ -1384,6 +1606,80 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	ROLLBACK
 -e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (7), (7);
+ERROR 23000: Duplicate entry '7' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	The creation of some temporary tables could not be rolled back.
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (7), (7)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Ne R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO tt_error_1() VALUES (4), (4);
+ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	The creation of some temporary tables could not be rolled back.
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp Te R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R';
+BEGIN;
+DROP TEMPORARY TABLE tt_tmp_2;
+CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb;
+DROP TEMPORARY TABLE tt_tmp_1;
+DROP TEMPORARY TABLE tt_tmp_2;
+INSERT INTO nt_error_1() VALUES (8), (8);
+ERROR 23000: Duplicate entry '8' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+Warning	#	The creation of some temporary tables could not be rolled back.
+Warning	#	Some temporary tables were dropped, but these operations could not be rolled back.
+-b-b-b-b-b-b-b-b-b-b-b- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (8), (8)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tt_tmp_2 ( id INT ) engine= Innodb
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_1` /* generated by server */
+master-bin.000001	#	Query	#	#	use `test`; DROP TEMPORARY TABLE `tt_tmp_2` /* generated by server */
+master-bin.000001	#	Query	#	#	ROLLBACK
+-e-e-e-e-e-e-e-e-e-e-e- >> B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp NeT-trig R << -e-e-e-e-e-e-e-e-e-e-e-
+
 #########################################################################
 #                     4 -  CHANGING TEMPORARY TABLES
 #########################################################################
@@ -1485,6 +1781,87 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp C << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Ne C';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (9), (9);
+ERROR 23000: Duplicate entry '9' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (9), (9)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Te C';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (5), (5);
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Te C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Te C << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (10), (10);
+ERROR 23000: Duplicate entry '10' for key 'PRIMARY'
+COMMIT;
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (10), (10)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig C << -e-e-e-e-e-e-e-e-e-e-e-
+
 
 
 #
@@ -1586,6 +1963,84 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	COMMIT
 -e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp R << -e-e-e-e-e-e-e-e-e-e-e-
 
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Ne R';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (11), (11);
+ERROR 23000: Duplicate entry '11' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (11), (11)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Ne R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp Te R';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_error_1() VALUES (6), (6);
+ERROR 23000: Duplicate entry '6' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp Te R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp Te R << -e-e-e-e-e-e-e-e-e-e-e-
+
+SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R';
+BEGIN;
+INSERT INTO nt_xx_1() VALUES (1);
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
+INSERT INTO nt_tmp_xx_1() VALUES (1);
+INSERT INTO nt_error_1() VALUES (12), (12);
+ERROR 23000: Duplicate entry '12' for key 'PRIMARY'
+ROLLBACK;
+Warnings:
+Warning	#	Some non-transactional changed tables couldn't be rolled back
+-b-b-b-b-b-b-b-b-b-b-b- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R << -b-b-b-b-b-b-b-b-b-b-b-
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_tmp_xx_1() VALUES (1)
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO nt_error_1() VALUES (12), (12)
+master-bin.000001	#	Query	#	#	COMMIT
+-e-e-e-e-e-e-e-e-e-e-e- >> B N N-Temp T-SELECT-T-Temp N-Temp NeT-trig R << -e-e-e-e-e-e-e-e-e-e-e-
+
 ###################################################################################
 #                               CHECK CONSISTENCY
 ###################################################################################
@@ -1595,6 +2050,10 @@ master-bin.000001	#	Query	#	#	COMMIT
 SET @commands= 'clean';
 DROP TABLE IF EXISTS tt_xx_1;
 DROP TABLE IF EXISTS nt_xx_1;
+DROP TABLE IF EXISTS tt_error_1;
+DROP TABLE IF EXISTS nt_error_1;
+DROP TABLE IF EXISTS tt_error_2;
+DROP TABLE IF EXISTS nt_error_2;
 DROP TABLE IF EXISTS nt_2;
 DROP TABLE IF EXISTS nt_1;
 DROP TABLE IF EXISTS tt_2;

=== modified file 'mysql-test/suite/rpl/t/rpl_DML_error.test'
--- a/mysql-test/suite/rpl/t/rpl_DML_error.test	2011-01-05 05:21:07 +0000
+++ b/mysql-test/suite/rpl/t/rpl_DML_error.test	2011-04-08 17:20:14 +0000
@@ -1,7 +1,7 @@
 source include/master-slave.inc;
 source include/have_innodb.inc;
 
---echo # Verify the statments can be binlogged correctly when error happens
+--echo # Verify the statements can be binlogged correctly when error happens
 --echo # ------------------------------------------------------------------
 CREATE TABLE t1(c1 INT KEY) ENGINE=MyISAM;
 CREATE TABLE t2(c1 INT KEY) ENGINE=MyISAM;
@@ -72,4 +72,4 @@ UPDATE t1, t2 SET t1.c1= 5, t2.c1=5;
 source include/show_binlog_events.inc;
 
 DROP TABLE t1, t2;
-source include/rpl_end.inc;
\ No newline at end of file
+source include/rpl_end.inc;

=== modified file 'mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test'
--- a/mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test	2011-01-05 05:21:07 +0000
+++ b/mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test	2011-04-08 17:20:14 +0000
@@ -195,7 +195,7 @@ sync_slave_with_master;
 --echo # [ on slave ]
 USE db1;
 
-let $timeout_old= `SELECT @@GLOBAL.innodb_lock_wait_timeout`;
+SET @timeout_old= @@GLOBAL.innodb_lock_wait_timeout;
 SET GLOBAL innodb_lock_wait_timeout= 1;
 
 STOP SLAVE SQL_THREAD;
@@ -203,8 +203,8 @@ source include/wait_for_slave_sql_to_sto
 START SLAVE SQL_THREAD;
 source include/wait_for_slave_sql_to_start.inc;
 
---echo # Verify the SQL thread don't retry the transaction when different
---echo # sort of statements has modified a non-transactional table.
+--echo # Verify the SQL thread doesn't retry the transaction when one of
+--echo # its statements has modified a non-transactional table.
 --echo # ----------------------------------------------------------------
 --echo
 --echo # INSERT statement inserts a row to a non-transactional table.
@@ -245,8 +245,8 @@ let $statement= DROP TEMPORARY TABLE IF
 source extra/rpl_tests/rpl_temp_error.test;
 
 --echo
---echo # Verify the SQL thread don't retry the transaction if one of the
---echo # sub-statement has modified a non-transactional table.
+--echo # Verify that the SQL thread doesn't retry the transaction if one
+--echo # of the sub-statements has modified a non-transactional table.
 --echo # ----------------------------------------------------------------
 
 connection master;
@@ -323,7 +323,7 @@ connection master;
 let $statement= INSERT INTO t3 VALUES(f_delete());
 source extra/rpl_tests/rpl_temp_error.test;
 
-eval SET GLOBAL innodb_lock_wait_timeout= $timeout_old;
+SET @@global.innodb_lock_wait_timeout= @timeout_old;
 
 --echo #
 --echo # Clean up

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2011-03-16 09:37:35 +0000
+++ b/sql/binlog.cc	2011-04-08 17:20:14 +0000
@@ -288,7 +288,7 @@ public:
   void restore_savepoint(my_off_t pos)
   {
     truncate(pos);
-    if (pos < before_stmt_pos)
+    if (pos <= before_stmt_pos)
       before_stmt_pos= MY_OFF_T_UNDEF;
   }
 
@@ -809,20 +809,55 @@ static int binlog_rollback(handlerton *h
     DBUG_RETURN(error);
   }
 
-  if (cache_mngr->trx_cache_cannot_rollback())
+  if (ending_trans(thd, all)) 
   {
-    if (ending_trans(thd, all))
+    if (trans_cannot_safely_rollback(thd))
     {
+      /*
+        If the transaction is being rolled back and contains changes that
+        cannot be rolled back, the trx-cache's content is flushed.
+      */
       error= binlog_rollback_flush_trx_cache(thd, cache_mngr);
     }
     else
     {
-      /* The statement should be kept in trx_cache. */
-      cache_mngr->trx_cache.set_prev_position(MY_OFF_T_UNDEF);
+      /*
+        If the transaction is being rolled back and its changes can be
+        rolled back, the trx-cache's content is truncated.
+      */
+      error= binlog_truncate_trx_cache(thd, cache_mngr, all);
     }
   }
   else
-    error= binlog_truncate_trx_cache(thd, cache_mngr, all);
+  {
+    /*
+      If a statement is being rolled back, it is necessary to know
+      exactly why a statement may not be safely rolled back as in
+      some specific situations the statement can be rolled back.
+    */
+
+    if (thd->transaction.stmt.has_dropped_temp_table() ||
+        thd->transaction.stmt.has_created_temp_table() ||
+        (thd->transaction.stmt.has_modified_non_trans_table() &&
+        thd->variables.binlog_format == BINLOG_FORMAT_STMT))
+    {
+      /*
+        If the statement is being rolled back and dropped or created a
+        temporary table or modified a non-transactional table and the
+        statement-based replication is in use, the statement's changes
+        in the trx-cache are preserved.
+      */
+      cache_mngr->trx_cache.set_prev_position(MY_OFF_T_UNDEF);
+    }
+    else
+    {
+      /*
+        Otherwise, the statement's changes in the trx-cache are
+        truncated.
+      */
+      error= binlog_truncate_trx_cache(thd, cache_mngr, all);
+    }
+  }
 
   DBUG_RETURN(error);
 }
@@ -894,10 +929,7 @@ static int binlog_savepoint_rollback(han
     non-transactional table. Otherwise, truncate the binlog cache starting
     from the SAVEPOINT command.
   */
-  binlog_cache_mngr *const cache_mngr=
-    (binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
-
-  if (unlikely(cache_mngr->trx_cache_cannot_rollback()))
+  if (trans_cannot_safely_rollback(thd))
   {
     String log_query;
     if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
@@ -1161,11 +1193,26 @@ bool ending_single_stmt_trans(THD* thd,
 }
 
 /**
+  This function checks if a transaction cannot be rolled back safely.
+
+  @param thd The client thread that executed the current statement.
+  @return
+    @c true if cannot be safely rolled back, @c false otherwise.
+*/
+bool trans_cannot_safely_rollback(const THD* thd)
+{
+  binlog_cache_mngr *const cache_mngr=
+    (binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
+
+  return cache_mngr->trx_cache_cannot_rollback();
+}
+
+/**
   This function checks if current statement cannot be rollded back safely.
 
   @param thd The client thread that executed the current statement.
   @return
-    @c true if a non-transactional table was updated, @c false otherwise.
+    @c true if cannot be safely rolled back, @c false otherwise.
 */
 bool stmt_cannot_safely_rollback(const THD* thd)
 {
@@ -3691,10 +3738,16 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
         DBUG_EVALUATE_IF("injecting_fault_writing", 1, 0))
       goto err;
 
-    error= 0;
-
+    /*
+      After writing the event, if the trx-cache was used and any unsafe
+      change was written into it, the cache is marked as cannot safely
+      roll back.
+    */
     if (is_trans_cache && stmt_cannot_safely_rollback(thd))
       cache_mngr->set_trx_cache_cannot_rollback();
+
+    error= 0;
+
 err:
     if (event_info->use_direct_logging())
     {

=== modified file 'sql/binlog.h'
--- a/sql/binlog.h	2011-03-16 09:37:35 +0000
+++ b/sql/binlog.h	2011-04-08 17:20:14 +0000
@@ -323,6 +323,7 @@ bool stmt_has_updated_trans_table(const
 bool use_trans_cache(const THD* thd, bool is_transactional);
 bool ending_trans(THD* thd, const bool all);
 bool ending_single_stmt_trans(THD* thd, const bool all);
+bool trans_cannot_safely_rollback(const THD* thd);
 bool stmt_cannot_safely_rollback(const THD* thd);
 
 int log_loaded_block(IO_CACHE* file);

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-01-05 05:21:07 +0000
+++ b/sql/ha_ndbcluster.cc	2011-04-08 17:20:14 +0000
@@ -4607,10 +4607,19 @@ void ha_ndbcluster::transaction_checks(T
 {
   if (thd->lex->sql_command == SQLCOM_LOAD)
   {
-    m_transaction_on= FALSE;
     /* Would be simpler if has_transactions() didn't always say "yes" */
-    thd->transaction.all.modified_non_trans_table();
-    thd->transaction.stmt.modified_non_trans_table();
+    m_transaction_on= FALSE;
+    /*
+      In the future, after integrating the ndb code-base into trunk,
+      make sure that it is necessary to mark that the transaction
+      has updated a non-transactional table and one cannot simply
+      rely on the fact that the statement's flag is propagated to
+      the transaction upon committing the statement.
+
+      \Alfranio
+    */
+    thd->transaction.all.mark_modified_non_trans_table();
+    thd->transaction.stmt.mark_modified_non_trans_table();
   }
   else if (!thd->transaction.on)
     m_transaction_on= FALSE;

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2011-03-16 09:37:35 +0000
+++ b/sql/handler.h	2011-04-08 17:20:14 +0000
@@ -830,202 +830,6 @@ struct handlerton
 */
 #define HTON_NO_BINLOG_ROW_OPT       (1 << 9)
 
-class Ha_trx_info;
-
-struct THD_TRANS
-{
-  /* true is not all entries in the ht[] support 2pc */
-  bool        no_2pc;
-  /* storage engines that registered in this transaction */
-  Ha_trx_info *ha_list;
-  /* 
-    The purpose of this flag is to keep track of statements which cannot be
-    rolled back safely(completely). For example, statements that modified
-    non-transactional tables, 'DROP TEMPORARY TABLE' and
-    'CREATE TEMPORARY TABLE' statements. The tracked statements are
-    modified in scope of:
-    - transaction, when the variable is a member of THD::transaction.all
-    - top-level statement or sub-statement, when the variable is a
-    member of THD::transaction.stmt
-    This member has the following life cycle:
-    * stmt.unsafe_rollback_flags is used to keep track of top-level statements
-    which cannot be rolled back safely. At the end of the previous statement
-    and at the beginning of the session, it is reset to 0.  If such functions
-    as mysql_insert, mysql_update, mysql_delete etc modify a non-transactional
-    table, flag MODIFIED_NON_TRANS_TABLE is set.  After 'CREATE TEMPORARY TABLE'
-    creates a table successfully, flag CREATED_TEMP_TABLE is set. After
-    'DROP TEMPORARY TABLE' drops a temporary table, flag DROPPED_TEMP_TABLE is
-    set.  At the end of the statement, the value of stmt.unsafe_rollback_flags
-    is merged with all.unsafe_rollback_flags and gets reset.
-    * all.cannot_safely_rollback is reset at the end of transaction
-
-    * Since we do not have a dedicated context for execution of a sub-statement,
-    to keep track of non-transactional changes in a sub-statement, we re-use
-    stmt.unsafe_rollback_flags.  At entrance into a sub-statement, a copy of the
-    value of stmt.unsafe_rollback_flags (containing the changes of the outer
-    statement) is saved on stack.  Then stmt.unsafe_rollback_flags is reset
-    to FALSE and the substatement is executed. Then the new value is merged with
-    the saved value.
-  */
-private:
-  unsigned int unsafe_rollback_flags;
-  /*
-    Define the type of statemens which cannot be rolled back safely.
-    Each type occupies one bit in unsafe_rollback_flags.
-  */
-  enum
-  {
-    MODIFIED_NON_TRANS_TABLE= 0x01,
-    CREATED_TEMP_TABLE= 0x02,
-    DROPPED_TEMP_TABLE= 0x04
-  };
-public:
-  bool cannot_safely_rollback() const
-  {
-    return unsafe_rollback_flags > 0;
-  }
-  unsigned int get_unsafe_rollback_flags() const
-  {
-    return unsafe_rollback_flags;
-  }
-  void set_unsafe_rollback_flags(unsigned int flags)
-  {
-    unsafe_rollback_flags= flags;
-  }
-  void add_unsafe_rollback_flags(unsigned int flags)
-  {
-    unsafe_rollback_flags|= flags;
-  }
-  void reset_unsafe_rollback_flags()
-  {
-    unsafe_rollback_flags= 0;
-  }
-  void modified_non_trans_table()
-  {
-    unsafe_rollback_flags|= MODIFIED_NON_TRANS_TABLE;
-  }
-  bool has_modified_non_trans_table() const
-  {
-    return unsafe_rollback_flags & MODIFIED_NON_TRANS_TABLE;
-  }
-  void created_temp_table()
-  {
-    unsafe_rollback_flags|= CREATED_TEMP_TABLE;
-  }
-  bool has_created_temp_table() const
-  {
-    return unsafe_rollback_flags & CREATED_TEMP_TABLE;
-  }
-  void dropped_temp_table()
-  {
-    unsafe_rollback_flags|= DROPPED_TEMP_TABLE;
-  }
-  bool has_dropped_temp_table() const
-  {
-    return unsafe_rollback_flags & DROPPED_TEMP_TABLE;
-  }
-
-  void reset() { no_2pc= FALSE; reset_unsafe_rollback_flags(); }
-  bool is_empty() const { return ha_list == NULL; }
-};
-
-
-/**
-  Either statement transaction or normal transaction - related
-  thread-specific storage engine data.
-
-  If a storage engine participates in a statement/transaction,
-  an instance of this class is present in
-  thd->transaction.{stmt|all}.ha_list. The addition to
-  {stmt|all}.ha_list is made by trans_register_ha().
-
-  When it's time to commit or rollback, each element of ha_list
-  is used to access storage engine's prepare()/commit()/rollback()
-  methods, and also to evaluate if a full two phase commit is
-  necessary.
-
-  @sa General description of transaction handling in handler.cc.
-*/
-
-class Ha_trx_info
-{
-public:
-  /** Register this storage engine in the given transaction context. */
-  void register_ha(THD_TRANS *trans, handlerton *ht_arg)
-  {
-    DBUG_ASSERT(m_flags == 0);
-    DBUG_ASSERT(m_ht == NULL);
-    DBUG_ASSERT(m_next == NULL);
-
-    m_ht= ht_arg;
-    m_flags= (int) TRX_READ_ONLY; /* Assume read-only at start. */
-
-    m_next= trans->ha_list;
-    trans->ha_list= this;
-  }
-
-  /** Clear, prepare for reuse. */
-  void reset()
-  {
-    m_next= NULL;
-    m_ht= NULL;
-    m_flags= 0;
-  }
-
-  Ha_trx_info() { reset(); }
-
-  void set_trx_read_write()
-  {
-    DBUG_ASSERT(is_started());
-    m_flags|= (int) TRX_READ_WRITE;
-  }
-  bool is_trx_read_write() const
-  {
-    DBUG_ASSERT(is_started());
-    return m_flags & (int) TRX_READ_WRITE;
-  }
-  bool is_started() const { return m_ht != NULL; }
-  /** Mark this transaction read-write if the argument is read-write. */
-  void coalesce_trx_with(const Ha_trx_info *stmt_trx)
-  {
-    /*
-      Must be called only after the transaction has been started.
-      Can be called many times, e.g. when we have many
-      read-write statements in a transaction.
-    */
-    DBUG_ASSERT(is_started());
-    if (stmt_trx->is_trx_read_write())
-      set_trx_read_write();
-  }
-  Ha_trx_info *next() const
-  {
-    DBUG_ASSERT(is_started());
-    return m_next;
-  }
-  handlerton *ht() const
-  {
-    DBUG_ASSERT(is_started());
-    return m_ht;
-  }
-private:
-  enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1 };
-  /** Auxiliary, used for ha_list management */
-  Ha_trx_info *m_next;
-  /**
-    Although a given Ha_trx_info instance is currently always used
-    for the same storage engine, 'ht' is not-NULL only when the
-    corresponding storage is a part of a transaction.
-  */
-  handlerton *m_ht;
-  /**
-    Transaction flags related to this engine.
-    Not-null only if this instance is a part of transaction.
-    May assume a combination of enum values above.
-  */
-  uchar       m_flags;
-};
-
-
 enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
 			 ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
 

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2011-03-16 09:37:35 +0000
+++ b/sql/log_event.cc	2011-04-08 17:20:14 +0000
@@ -8159,8 +8159,12 @@ int Rows_log_event::do_apply_event(Relay
  
       if (error == 0 && !transactional_table)
       {
-        thd->transaction.all.modified_non_trans_table();
-        thd->transaction.stmt.modified_non_trans_table();
+        /*
+          We rely on trans_commit_stmt() to propagate unsafe_rollback_flags
+          from statement to transaction level. For that reason, only the
+          statement level is set.
+        */
+        thd->transaction.stmt.mark_modified_non_trans_table();
       }
 
       if (m_curr_row == m_rows_end)

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-03-16 09:37:35 +0000
+++ b/sql/sql_class.h	2011-04-08 17:20:14 +0000
@@ -907,6 +907,208 @@ private:
   Statement *last_found_statement;
 };
 
+class Ha_trx_info;
+
+struct THD_TRANS
+{
+  /* true is not all entries in the ht[] support 2pc */
+  bool        no_2pc;
+  /* storage engines that registered in this transaction */
+  Ha_trx_info *ha_list;
+
+private:
+  /* 
+    The purpose of this member variable (i.e. flag) is to keep track of
+    statements which cannot be rolled back safely(completely).
+    For example,
+
+    * statements that modified non-transactional tables. The value
+    MODIFIED_NON_TRANS_TABLE is set within mysql_insert, mysql_update,
+    mysql_delete, etc if a non-transactional table is modified.
+
+    * 'DROP TEMPORARY TABLE' and 'CREATE TEMPORARY TABLE' statements.
+    The former sets the value CREATED_TEMP_TABLE is set and the latter
+    the value DROPPED_TEMP_TABLE.
+    
+    The tracked statements are modified in scope of:
+
+    * transaction, when the variable is a member of THD::transaction.all
+    
+    * top-level statement or sub-statement, when the variable is a
+    member of THD::transaction.stmt
+
+    This member has the following life cycle:
+
+    * stmt.m_unsafe_rollback_flags is used to keep track of top-level statements
+    which cannot be rolled back safely. At the end of the statement, the value
+    of stmt.m_unsafe_rollback_flags is merged with all.m_unsafe_rollback_flags
+    and gets reset.
+    
+    * all.cannot_safely_rollback is reset at the end of transaction
+
+    * Since we do not have a dedicated context for execution of a sub-statement,
+    to keep track of non-transactional changes in a sub-statement, we re-use
+    stmt.m_unsafe_rollback_flags. At entrance into a sub-statement, a copy of
+    the value of stmt.m_unsafe_rollback_flags (containing the changes of the
+    outer statement) is saved on stack.  Then stmt.m_unsafe_rollback_flags is
+    reset to 0 and the substatement is executed. Then the new value is merged
+    with the saved value.
+  */
+
+  unsigned int m_unsafe_rollback_flags;
+  /*
+    Define the type of statemens which cannot be rolled back safely.
+    Each type occupies one bit in m_unsafe_rollback_flags.
+  */
+  static unsigned int const MODIFIED_NON_TRANS_TABLE= 0x01;
+  static unsigned int const CREATED_TEMP_TABLE= 0x02;
+  static unsigned int const DROPPED_TEMP_TABLE= 0x04;
+
+public:
+  bool cannot_safely_rollback() const
+  {
+    return m_unsafe_rollback_flags > 0;
+  }
+  unsigned int get_unsafe_rollback_flags() const
+  {
+    return m_unsafe_rollback_flags;
+  }
+  void set_unsafe_rollback_flags(unsigned int flags)
+  {
+    m_unsafe_rollback_flags= flags;
+  }
+  void add_unsafe_rollback_flags(unsigned int flags)
+  {
+    m_unsafe_rollback_flags|= flags;
+  }
+  void reset_unsafe_rollback_flags()
+  {
+    m_unsafe_rollback_flags= 0;
+  }
+  void mark_modified_non_trans_table()
+  {
+    m_unsafe_rollback_flags|= MODIFIED_NON_TRANS_TABLE;
+  }
+  bool has_modified_non_trans_table() const
+  {
+    return m_unsafe_rollback_flags & MODIFIED_NON_TRANS_TABLE;
+  }
+  void mark_created_temp_table()
+  {
+    m_unsafe_rollback_flags|= CREATED_TEMP_TABLE;
+  }
+  bool has_created_temp_table() const
+  {
+    return m_unsafe_rollback_flags & CREATED_TEMP_TABLE;
+  }
+  void mark_dropped_temp_table()
+  {
+    m_unsafe_rollback_flags|= DROPPED_TEMP_TABLE;
+  }
+  bool has_dropped_temp_table() const
+  {
+    return m_unsafe_rollback_flags & DROPPED_TEMP_TABLE;
+  }
+
+  void reset() { no_2pc= FALSE; reset_unsafe_rollback_flags(); }
+  bool is_empty() const { return ha_list == NULL; }
+};
+
+/**
+  Either statement transaction or normal transaction - related
+  thread-specific storage engine data.
+
+  If a storage engine participates in a statement/transaction,
+  an instance of this class is present in
+  thd->transaction.{stmt|all}.ha_list. The addition to
+  {stmt|all}.ha_list is made by trans_register_ha().
+
+  When it's time to commit or rollback, each element of ha_list
+  is used to access storage engine's prepare()/commit()/rollback()
+  methods, and also to evaluate if a full two phase commit is
+  necessary.
+
+  @sa General description of transaction handling in handler.cc.
+*/
+
+class Ha_trx_info
+{
+public:
+  /** Register this storage engine in the given transaction context. */
+  void register_ha(THD_TRANS *trans, handlerton *ht_arg)
+  {
+    DBUG_ASSERT(m_flags == 0);
+    DBUG_ASSERT(m_ht == NULL);
+    DBUG_ASSERT(m_next == NULL);
+
+    m_ht= ht_arg;
+    m_flags= (int) TRX_READ_ONLY; /* Assume read-only at start. */
+
+    m_next= trans->ha_list;
+    trans->ha_list= this;
+  }
+
+  /** Clear, prepare for reuse. */
+  void reset()
+  {
+    m_next= NULL;
+    m_ht= NULL;
+    m_flags= 0;
+  }
+
+  Ha_trx_info() { reset(); }
+
+  void set_trx_read_write()
+  {
+    DBUG_ASSERT(is_started());
+    m_flags|= (int) TRX_READ_WRITE;
+  }
+  bool is_trx_read_write() const
+  {
+    DBUG_ASSERT(is_started());
+    return m_flags & (int) TRX_READ_WRITE;
+  }
+  bool is_started() const { return m_ht != NULL; }
+  /** Mark this transaction read-write if the argument is read-write. */
+  void coalesce_trx_with(const Ha_trx_info *stmt_trx)
+  {
+    /*
+      Must be called only after the transaction has been started.
+      Can be called many times, e.g. when we have many
+      read-write statements in a transaction.
+    */
+    DBUG_ASSERT(is_started());
+    if (stmt_trx->is_trx_read_write())
+      set_trx_read_write();
+  }
+  Ha_trx_info *next() const
+  {
+    DBUG_ASSERT(is_started());
+    return m_next;
+  }
+  handlerton *ht() const
+  {
+    DBUG_ASSERT(is_started());
+    return m_ht;
+  }
+private:
+  enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1 };
+  /** Auxiliary, used for ha_list management */
+  Ha_trx_info *m_next;
+  /**
+    Although a given Ha_trx_info instance is currently always used
+    for the same storage engine, 'ht' is not-NULL only when the
+    corresponding storage is a part of a transaction.
+  */
+  handlerton *m_ht;
+  /**
+    Transaction flags related to this engine.
+    Not-null only if this instance is a part of transaction.
+    May assume a combination of enum values above.
+  */
+  uchar       m_flags;
+};
+
 struct st_savepoint {
   struct st_savepoint *prev;
   char                *name;
@@ -1465,9 +1667,10 @@ private:
   MDL_ticket *m_mdl_blocks_commits_lock;
 };
 
-
 extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
 
+
+
 /**
   @class THD
   For each client connection we create a separate thread with THD serving as
@@ -3228,7 +3431,6 @@ class select_insert :public select_resul
   virtual int prepare2(void);
   bool send_data(List<Item> &items);
   virtual void store_values(List<Item> &values);
-  virtual bool can_rollback_data() { return 0; }
   void send_error(uint errcode,const char *err);
   bool send_eof();
   virtual void abort_result_set();
@@ -3268,7 +3470,6 @@ public:
   void send_error(uint errcode,const char *err);
   bool send_eof();
   virtual void abort_result_set();
-  virtual bool can_rollback_data() { return 1; }
 
   // Needed for access from local class MY_HOOKS in prepare(), since thd is proteted.
   const THD *get_thd(void) { return thd; }

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2011-03-16 09:37:35 +0000
+++ b/sql/sql_delete.cc	2011-04-08 17:20:14 +0000
@@ -374,7 +374,7 @@ cleanup:
   transactional_table= table->file->has_transactions();
 
   if (!transactional_table && deleted > 0)
-    thd->transaction.stmt.modified_non_trans_table();
+    thd->transaction.stmt.mark_modified_non_trans_table();
   
   /* See similar binlogging code in sql_update.cc, for comments */
   if ((error < 0) || thd->transaction.stmt.cannot_safely_rollback())
@@ -728,7 +728,7 @@ bool multi_delete::send_data(List<Item>
       {
         deleted++;
         if (!table->file->has_transactions())
-          thd->transaction.stmt.modified_non_trans_table();
+          thd->transaction.stmt.mark_modified_non_trans_table();
         if (table->triggers &&
             table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
                                               TRG_ACTION_AFTER, FALSE))
@@ -939,7 +939,7 @@ int multi_delete::do_table_deletes(TABLE
     }
   }
   if (last_deleted != deleted && !table->file->has_transactions())
-    thd->transaction.stmt.modified_non_trans_table();
+    thd->transaction.stmt.mark_modified_non_trans_table();
 
   end_read_record(&info);
 

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2011-03-16 09:37:35 +0000
+++ b/sql/sql_insert.cc	2011-04-08 17:20:14 +0000
@@ -1481,7 +1481,7 @@ static int last_uniq_key(TABLE *table,ui
     then both on update triggers will work instead. Similarly both on
     delete triggers will be invoked if we will delete conflicting records.
 
-    Call thd->transaction.stmt.modified_non_trans_table() if table is a
+    Call thd->transaction.stmt.mark_modified_non_trans_table() if table is a
     non-transactional table.
 
   RETURN VALUE
@@ -1699,7 +1699,7 @@ int write_record(THD *thd, TABLE *table,
             goto err;
           info->deleted++;
           if (!table->file->has_transactions())
-            thd->transaction.stmt.modified_non_trans_table();
+            thd->transaction.stmt.mark_modified_non_trans_table();
           if (table->triggers &&
               table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
                                                 TRG_ACTION_AFTER, TRUE))
@@ -1751,7 +1751,7 @@ ok_or_after_trg_err:
   if (key)
     my_safe_afree(key,table->s->max_unique_length,MAX_KEY_LENGTH);
   if (!table->file->has_transactions())
-    thd->transaction.stmt.modified_non_trans_table();
+    thd->transaction.stmt.mark_modified_non_trans_table();
   DBUG_RETURN(trg_error);
 
 err:
@@ -4059,8 +4059,13 @@ void select_create::send_error(uint errc
 
 bool select_create::send_eof()
 {
+  /*
+    The routine that write the statement in the binary log
+    is in select_insert::send_eof(). For that reason, we
+    mark the flag at this point.
+  */
   if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
-    thd->transaction.stmt.created_temp_table();
+    thd->transaction.stmt.mark_created_temp_table();
 
   bool tmp=select_insert::send_eof();
   if (tmp)

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2011-03-16 09:37:35 +0000
+++ b/sql/sql_load.cc	2011-04-08 17:20:14 +0000
@@ -1261,8 +1261,6 @@ read_xml_field(THD *thd, COPY_INFO &info
       We don't need to reset auto-increment field since we are restoring
       its default value at the beginning of each loop iteration.
     */
-    if (no_trans_update_stmt)
-      thd->transaction.stmt.modified_non_trans_table();
     thd->warning_info->inc_current_row_for_warning();
     continue_loop:;
   }

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-03-16 09:37:35 +0000
+++ b/sql/sql_parse.cc	2011-04-08 17:20:14 +0000
@@ -5259,6 +5259,15 @@ void THD::reset_for_next_command()
     beginning of each SQL statement.
   */
   thd->server_status&= ~SERVER_STATUS_CLEAR_SET;
+  /*
+    If in autocommit mode and not in a transaction, reset flag
+    that identifies if a transaction has done some operations
+    that cannot be safely rolled back.
+
+    If the flag is set an warning message is printed out in
+    ha_rollback_trans() saying that some tables couldn't be
+    rolled back.
+  */
   if (!thd->in_multi_stmt_transaction_mode())
   {
     thd->transaction.all.reset_unsafe_rollback_flags();

=== modified file 'sql/sql_priv.h'
--- a/sql/sql_priv.h	2011-03-16 09:37:35 +0000
+++ b/sql/sql_priv.h	2011-04-08 17:20:14 +0000
@@ -101,6 +101,7 @@
 #define OPTION_BEGIN            (1ULL << 20)    // THD, intern
 #define OPTION_TABLE_LOCK       (1ULL << 21)    // THD, intern
 #define OPTION_QUICK            (1ULL << 22)    // SELECT (for DELETE)
+/* 23rd bit is unused. It was occupied by OPTION_KEEP_LOG. */
 
 /* The following is used to detect a conflict with DISTINCT */
 #define SELECT_ALL              (1ULL << 24)    // SELECT, user, parser

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-03-16 09:37:35 +0000
+++ b/sql/sql_table.cc	2011-04-08 17:20:14 +0000
@@ -2250,14 +2250,6 @@ int mysql_rm_table_no_locks(THD *thd, TA
       goto err;
     }
 
-    /*
-      DROP TEMPORARY TABLE doesn't terminate a transaction. Calling
-      stmt.dropped_temp_table() guarantees the transaction can be binlogged
-      correctly.
-    */
-    if (!error && drop_temporary)
-      thd->transaction.stmt.dropped_temp_table();
-
     if ((drop_temporary && if_exists) || !error)
     {
       /*
@@ -2486,6 +2478,7 @@ err:
     {
       if (non_trans_tmp_table_deleted)
       {
+          thd->transaction.stmt.mark_dropped_temp_table();
           /* Chop of the last comma */
           built_non_trans_tmp_query.chop();
           built_non_trans_tmp_query.append(" /* generated by server */");
@@ -2496,6 +2489,7 @@ err:
       }
       if (trans_tmp_table_deleted)
       {
+          thd->transaction.stmt.mark_dropped_temp_table();
           /* Chop of the last comma */
           built_trans_tmp_query.chop();
           built_trans_tmp_query.append(" /* generated by server */");
@@ -4571,11 +4565,11 @@ bool mysql_create_table(THD *thd, TABLE_
   {
     /*
       CREATE TEMPORARY TABLE doesn't terminate a transaction. Calling
-      stmt.created_temp_table() guarantees the transaction can be binlogged
+      stmt.mark_created_temp_table() guarantees the transaction can be binlogged
       correctly.
     */
     if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
-      thd->transaction.stmt.created_temp_table();
+      thd->transaction.stmt.mark_created_temp_table();
 
     if (!thd->is_current_stmt_binlog_format_row() ||
         (thd->is_current_stmt_binlog_format_row() &&
@@ -4802,11 +4796,11 @@ bool mysql_create_like_table(THD* thd, T
                                              MDL_EXCLUSIVE));
   /*
     CREATE TEMPORARY TABLE doesn't terminate a transaction. Calling
-    stmt.created_temp_table() guarantees the transaction can be binlogged
+    stmt.mark_created_temp_table() guarantees the transaction can be binlogged
     correctly.
   */
   if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
-    thd->transaction.stmt.created_temp_table();
+    thd->transaction.stmt.mark_created_temp_table();
 
   /*
     We have to write the query before we unlock the tables.

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2011-03-16 09:37:35 +0000
+++ b/sql/sql_update.cc	2011-04-08 17:20:14 +0000
@@ -842,7 +842,7 @@ int mysql_update(THD *thd,
   table->file->try_semi_consistent_read(0);
 
   if (!transactional_table && updated > 0)
-    thd->transaction.stmt.modified_non_trans_table();
+    thd->transaction.stmt.mark_modified_non_trans_table();
 
   end_read_record(&info);
   delete select;
@@ -1878,7 +1878,7 @@ bool multi_update::send_data(List<Item>
           else
           {
             trans_safe= FALSE;
-            thd->transaction.stmt.modified_non_trans_table();
+            thd->transaction.stmt.mark_modified_non_trans_table();
           }
         }
       }
@@ -2125,7 +2125,7 @@ int multi_update::do_updates()
       else
       {
         trans_safe= FALSE;				// Can't do safe rollback
-        thd->transaction.stmt.modified_non_trans_table();
+        thd->transaction.stmt.mark_modified_non_trans_table();
       }
     }
     (void) table->file->ha_rnd_end();
@@ -2157,7 +2157,7 @@ err2:
     else
     {
       trans_safe= FALSE;
-      thd->transaction.stmt.modified_non_trans_table();
+      thd->transaction.stmt.mark_modified_non_trans_table();
     }
   }
   DBUG_RETURN(1);


Attachment: [text/bzr-bundle] bzr/alfranio.correia@oracle.com-20110408172014-8xqbo7eqda5bx15j.bundle
Thread
bzr commit into mysql-trunk branch (alfranio.correia:3773) Bug#11763126Alfranio Correia8 Apr
  • Re: bzr commit into mysql-trunk branch (alfranio.correia:3773)Bug#11763126Dmitry Lenev3 May
    • Re: bzr commit into mysql-trunk branch (alfranio.correia:3773) Bug#11763126Alfranio Correia12 May