From 9819885177059fd75f3250b917142eb9d6ae5b8c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Nov 2009 17:00:41 +0800 Subject: [PATCH] BUG#48216 Replication fails on all slaves after upgrade to 5.0.86 on master When a sessione is closed, all temporary tables of the session are automatically dropped and are binlogged. But it will be binlogged with wrong database names when the length of the temporary tables' database names are greater than the length of the current database name or the current database is not set. Query_log_event's db_len is forgot to set when Query_log_event's db is set. This patch wrote code to set db_len immediately after db has set. --- mysql-test/r/drop_temp_table.result | 1 + mysql-test/t/drop_temp_table.test | 11 +++++++++++ sql/sql_base.cc | 1 + 3 files changed, 13 insertions(+) diff --git a/mysql-test/r/drop_temp_table.result b/mysql-test/r/drop_temp_table.result index ff200d09de4..6a566aa646e 100644 --- a/mysql-test/r/drop_temp_table.result +++ b/mysql-test/r/drop_temp_table.result @@ -8,6 +8,7 @@ create temporary table shortn2 (a int); select get_lock("a",10); get_lock("a",10) 1 +USE test; select get_lock("a",10); get_lock("a",10) 1 diff --git a/mysql-test/t/drop_temp_table.test b/mysql-test/t/drop_temp_table.test index b456e75576b..6c99d566d77 100644 --- a/mysql-test/t/drop_temp_table.test +++ b/mysql-test/t/drop_temp_table.test @@ -14,6 +14,17 @@ create temporary table shortn1 (a int); create temporary table `table:name` (a int); create temporary table shortn2 (a int); select get_lock("a",10); + +# +# BUG48216 Replication fails on all slaves after upgrade to 5.0.86 on master +# +# When the session is closed, any temporary tables of the session are dropped +# and are binlogged. But it will be binlogged with a wrong database name when +# the length of the database name('drop-temp-table-test') is greater than the +# current database name('test'). +# +USE test; + disconnect con1; connection con2; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index db4ab29d6de..178c3e12e23 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -798,6 +798,7 @@ void close_temporary_tables(THD *thd) s_query.length() - 1 /* to remove trailing ',' */, 0, FALSE, THD::NOT_KILLED); qinfo.db= db.ptr(); + qinfo.db_len= db.length(); thd->variables.character_set_client= cs_save; DBUG_ASSERT(qinfo.error_code == 0); mysql_bin_log.write(&qinfo);