File: rpl_drop_temp_tbl_with_rewrite_db.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (83 lines) | stat: -rw-r--r-- 2,927 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
###############################################################################
# Bug#21317739: APPLYING CREATE TEMPORARY TABLE SQL ON A SLAVE WITH
# REPLICATE-REWRITE-DB FAILS
#
# Problem:
# =======
# As part of fix for BUG#16290902, at the time of writing the 'DROP TEMPORARY
# TABLE IF EXISTS' query into the binlog, the query will not be preceded by a
# 'use `db`' statement. The query will have a fully qualified table name.
# Eg:
# 'USE `db`; DROP TEMPORARY TABLE IF EXISTS `t1`;'
# will be logged as
# 'DROP TEMPORARY TABLE IF EXISTS `db`.`t1`;'.
#
# Because of this change application of 'replicate-rewrite-db' filter rule
# will fail on slave, as it works only on default database specified in 'use'
# statement. This causes slave to break when the 'CREATE TEMPORARY TABLE' is
# re-executed on slave.
#
# Test:
# =====
# Specify replicate-rewrite-db=test->new_test on slave. On master use 'test'
# database and 'CREATE TEMPORARY TABLE 't1'. Then drop the temporary table and
# recreate it on master. Now sync master with slave. Slave should be in sync
# and up and running.
###############################################################################
--source include/master-slave.inc
--source include/have_binlog_format_statement.inc

# Database 'test' on master is mapped with 'new_test' on slave by using
# replicate_rewrite_db filter
--source include/rpl_connection_slave.inc
CREATE DATABASE new_test;

# Create a temporary table on the default database.
--source include/rpl_connection_master.inc
use test;
CREATE TEMPORARY TABLE t1(id int);
--source include/sync_slave_sql_with_master.inc

# On slave verify that all the queries are rewritten as per the rewrite db
# rules.
--source include/show_binlog_events.inc

# On slave verify that one temporary table is created.
SHOW STATUS LIKE 'Replica_open_temp_tables';

# On master drop the temporary table.
--source include/rpl_connection_master.inc
use test;
DROP TEMPORARY TABLE IF EXISTS t1;

--source include/sync_slave_sql_with_master.inc
--source include/show_binlog_events.inc
# On slave verify that  temporary table is dropped. Hence output should
# be 0.
SHOW STATUS LIKE 'Replica_open_temp_tables';

# On master recreate the temporary tables once again.
--source include/rpl_connection_master.inc
use test;
CREATE TEMPORARY TABLE t1(id int);
--source include/sync_slave_sql_with_master.inc

# On slave temporary table should be recreated.
SHOW STATUS LIKE 'Replica_open_temp_tables';

# Disconnect the master, temp table on slave should dissapear
disconnect master;

--source include/rpl_connection_slave.inc
# Wait until drop of temp tables appers in slave's binlog
let $wait_binlog_event= DROP;
source include/wait_for_binlog_event.inc;

# On slave verify that  temporary table is dropped. Hence output should
# be 0.
SHOW STATUS LIKE 'Replica_open_temp_tables';

# ===========Clean up==========
DROP DATABASE new_test;

--source include/rpl_end.inc