| 1 |
############################################################################### |
| 2 |
# Bug#21317739: APPLYING CREATE TEMPORARY TABLE SQL ON A SLAVE WITH |
| 3 |
# REPLICATE-REWRITE-DB FAILS |
| 4 |
# |
| 5 |
# Problem: |
| 6 |
# ======= |
| 7 |
# As part of fix for BUG#16290902, at the time of writing the 'DROP TEMPORARY |
| 8 |
# TABLE IF EXISTS' query into the binlog, the query will not be preceded by a |
| 9 |
# 'use `db`' statement. The query will have a fully qualified table name. |
| 10 |
# Eg: |
| 11 |
# 'USE `db`; DROP TEMPORARY TABLE IF EXISTS `t1`;' |
| 12 |
# will be logged as |
| 13 |
# 'DROP TEMPORARY TABLE IF EXISTS `db`.`t1`;'. |
| 14 |
# |
| 15 |
# Because of this change application of 'replicate-rewrite-db' filter rule |
| 16 |
# will fail on slave, as it works only on default database specified in 'use' |
| 17 |
# statement. This causes slave to break when the 'CREATE TEMPORARY TABLE' is |
| 18 |
# re-executed on slave. |
| 19 |
# |
| 20 |
# Test: |
| 21 |
# ===== |
| 22 |
# Specify replicate-rewrite-db=test->new_test on slave. On master use 'test' |
| 23 |
# database and 'CREATE TEMPORARY TABLE 't1'. Then drop the temporary table and |
| 24 |
# recreate it on master. Now sync master with slave. Slave should be in sync |
| 25 |
# and up and running. |
| 26 |
############################################################################### |
| 27 |
--source include/master-slave.inc |
| 28 |
--source include/have_binlog_format_statement.inc |
| 29 |
|
| 30 |
# Database 'test' on master is mapped with 'new_test' on slave by using |
| 31 |
# replicate_rewrite_db filter |
| 32 |
--source include/rpl_connection_slave.inc |
| 33 |
CREATE DATABASE new_test; |
| 34 |
|
| 35 |
# Create a temporary table on the default database. |
| 36 |
--source include/rpl_connection_master.inc |
| 37 |
use test; |
| 38 |
CREATE TEMPORARY TABLE t1(id int); |
| 39 |
--source include/sync_slave_sql_with_master.inc |
| 40 |
|
| 41 |
# On slave verify that all the queries are rewritten as per the rewrite db |
| 42 |
# rules. |
| 43 |
--source include/show_binlog_events.inc |
| 44 |
|
| 45 |
# On slave verify that one temporary table is created. |
| 46 |
SHOW STATUS LIKE 'Replica_open_temp_tables'; |
| 47 |
|
| 48 |
# On master drop the temporary table. |
| 49 |
--source include/rpl_connection_master.inc |
| 50 |
use test; |
| 51 |
DROP TEMPORARY TABLE IF EXISTS t1; |
| 52 |
|
| 53 |
--source include/sync_slave_sql_with_master.inc |
| 54 |
--source include/show_binlog_events.inc |
| 55 |
# On slave verify that temporary table is dropped. Hence output should |
| 56 |
# be 0. |
| 57 |
SHOW STATUS LIKE 'Replica_open_temp_tables'; |
| 58 |
|
| 59 |
# On master recreate the temporary tables once again. |
| 60 |
--source include/rpl_connection_master.inc |
| 61 |
use test; |
| 62 |
CREATE TEMPORARY TABLE t1(id int); |
| 63 |
--source include/sync_slave_sql_with_master.inc |
| 64 |
|
| 65 |
# On slave temporary table should be recreated. |
| 66 |
SHOW STATUS LIKE 'Replica_open_temp_tables'; |
| 67 |
|
| 68 |
# Disconnect the master, temp table on slave should dissapear |
| 69 |
disconnect master; |
| 70 |
|
| 71 |
--source include/rpl_connection_slave.inc |
| 72 |
# Wait until drop of temp tables appers in slave's binlog |
| 73 |
let $wait_binlog_event= DROP; |
| 74 |
source include/wait_for_binlog_event.inc; |
| 75 |
|
| 76 |
# On slave verify that temporary table is dropped. Hence output should |
| 77 |
# be 0. |
| 78 |
SHOW STATUS LIKE 'Replica_open_temp_tables'; |
| 79 |
|
| 80 |
# ===========Clean up========== |
| 81 |
DROP DATABASE new_test; |
| 82 |
|
| 83 |
--source include/rpl_end.inc |