Commit 151b8ec4 authored by Venkatesh Duggirala's avatar Venkatesh Duggirala

Bug #20439913 CREATE TABLE DB.TABLE LIKE TMPTABLE IS BINLOGGED INCORRECTLY - BREAKS A SLAVE

Analysis:
In row based replication, Master does not send temp table information
to Slave. If there are any DDLs that involves in regular table that needs
to be sent to Slave and a temp tables (which will not be available at Slave),
the Master rewrites the query replacing temp table with it's defintion.
Eg: create table regular_table like temptable.
In rewrite logic, server is ignoring the database of regular table
which can cause problems mentioned in this bug.

Fix: dont ignore database information (if available) while
rewriting the query
parent 96974ea7
......@@ -182,6 +182,9 @@ DROP USER test_3@localhost;
ERROR HY000: Table 'user' was not locked with LOCK TABLES
INSERT INTO t2 VALUES ("DROP USER test_3@localhost with table locked");
UNLOCK TABLE;
CREATE DATABASE db;
CREATE TABLE db.t1 LIKE t2;
DROP DATABASE db;
DROP USER test_3@localhost;
DROP FUNCTION f2;
DROP PROCEDURE p2;
......
......@@ -150,6 +150,14 @@ DROP USER test_3@localhost;
INSERT INTO t2 VALUES ("DROP USER test_3@localhost with table locked");
UNLOCK TABLE;
# Bug #20439913 CREATE TABLE DB.TABLE LIKE TMPTABLE IS
# BINLOGGED INCORRECTLY - BREAKS A SLAVE
CREATE DATABASE db;
CREATE TABLE db.t1 LIKE t2;
DROP DATABASE db;
# end of Bug #20439913 test
DROP USER test_3@localhost;
DROP FUNCTION f2;
DROP PROCEDURE p2;
......
......@@ -4720,7 +4720,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
int result __attribute__((unused))=
store_create_info(thd, table, &query,
create_info, FALSE /* show_database */);
create_info,
table->db ? TRUE : FALSE/* show_database */);
DBUG_ASSERT(result == 0); // store_create_info() always return 0
if (write_bin_log(thd, TRUE, query.ptr(), query.length()))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment