diff options
author | Kristian Nielsen <knielsen@knielsen-hq.org> | 2015-04-20 12:59:46 +0200 |
---|---|---|
committer | Kristian Nielsen <knielsen@knielsen-hq.org> | 2015-04-20 12:59:46 +0200 |
commit | 519ad0f7e35ff4dd13aac3c13da44c649f724352 (patch) | |
tree | f266f58311df361b88ad35a87a04a2c9c520f211 | |
parent | 87d543831d2d1f89fd5b122de24591f9d9b91d13 (diff) | |
download | mariadb-git-519ad0f7e35ff4dd13aac3c13da44c649f724352.tar.gz |
MDEV-8016: Replication aborts on DROP /*!40005 TEMPORARY */ TABLE IF EXISTS
This was a regression from the patch for MDEV-7668.
A test was incorrect, so the slave would not properly handle re-using
temporary tables, which lead to replication failure in this case.
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_temp_table.result | 5 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_temp_table.test | 16 | ||||
-rw-r--r-- | sql/sql_base.cc | 7 |
3 files changed, 26 insertions, 2 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_temp_table.result b/mysql-test/suite/rpl/r/rpl_temp_table.result index 504b0471748..08504ce175d 100644 --- a/mysql-test/suite/rpl/r/rpl_temp_table.result +++ b/mysql-test/suite/rpl/r/rpl_temp_table.result @@ -39,7 +39,12 @@ sum(n) show status like 'Slave_open_temp_tables'; Variable_name Value Slave_open_temp_tables 0 +*** MDEV-8016: Replication aborts on DROP /*!40005 TEMPORARY */ TABLE IF EXISTS *** +INSERT INTO t2 VALUES (2000), (2001); +CREATE FUNCTION f() RETURNS INTEGER RETURN 1; +CREATE TEMPORARY TABLE t3 AS SELECT f() AS col FROM t2; drop table if exists t1,t2; Warnings: Note 1051 Unknown table 'test.t1' +drop function f; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_temp_table.test b/mysql-test/suite/rpl/t/rpl_temp_table.test index 92f8cef9c10..8b3af5d51cd 100644 --- a/mysql-test/suite/rpl/t/rpl_temp_table.test +++ b/mysql-test/suite/rpl/t/rpl_temp_table.test @@ -57,12 +57,28 @@ select count(*) from t2; select sum(n) from t2; show status like 'Slave_open_temp_tables'; +--echo *** MDEV-8016: Replication aborts on DROP /*!40005 TEMPORARY */ TABLE IF EXISTS *** +connect (master2,localhost,root,,); +INSERT INTO t2 VALUES (2000), (2001); +CREATE FUNCTION f() RETURNS INTEGER RETURN 1; +CREATE TEMPORARY TABLE t3 AS SELECT f() AS col FROM t2; +--let $gtid=`SELECT @@gtid_binlog_pos` +--disconnect master2 +--connection default +# Wait for implicit DROP TEMPORARY TABLE tmp to be binlogged. +--let $wait_condition= SELECT @@gtid_binlog_pos != '$gtid' +--source include/wait_condition.inc + +--sync_slave_with_master + + # # Clean up # connect (master2,localhost,root,,); connection master2; drop table if exists t1,t2; +drop function f; sync_slave_with_master; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 244791da23f..f337b3b6283 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -653,6 +653,7 @@ bool close_cached_connection_tables(THD *thd, LEX_STRING *connection) static void mark_temp_tables_as_free_for_reuse(THD *thd) { + rpl_group_info *rgi_slave; DBUG_ENTER("mark_temp_tables_as_free_for_reuse"); if (thd->query_id == 0) @@ -661,7 +662,9 @@ static void mark_temp_tables_as_free_for_reuse(THD *thd) DBUG_VOID_RETURN; } - if (thd->temporary_tables) + rgi_slave=thd->rgi_slave; + if ((!rgi_slave && thd->temporary_tables) || + (rgi_slave && unlikely(rgi_slave->rli->save_temporary_tables))) { thd->lock_temporary_tables(); for (TABLE *table= thd->temporary_tables ; table ; table= table->next) @@ -670,7 +673,7 @@ static void mark_temp_tables_as_free_for_reuse(THD *thd) mark_tmp_table_for_reuse(table); } thd->unlock_temporary_tables(); - if (thd->rgi_slave) + if (rgi_slave) { /* Temporary tables are shared with other by sql execution threads. |