#
# Test if dynamic replication wild table filter rules are properly evaluated.
#

source include/have_binlog_format_statement.inc;
source include/master-slave.inc;

connection slave;
--error ER_SLAVE_MUST_STOP
SET @@GLOBAL.replicate_wild_do_table="test.a%";
--error ER_SLAVE_MUST_STOP
SET @@GLOBAL.replicate_wild_ignore_table="test.b%";

connection slave;
source include/stop_slave.inc;
SET @@GLOBAL.replicate_wild_do_table="test.a%";
SET @@GLOBAL.replicate_wild_ignore_table="test.b%";
source include/start_slave.inc;
connection master;

# Table is mentioned in wild-do-table rules
CREATE TABLE a1 (a INT);

# Table is mentioned in wild-ignore-table rules
CREATE TABLE b1 (a INT);

# Table is not mentioned in wild-do-table or wild-ignore-table rules
CREATE TABLE c1 (a INT);

INSERT INTO a1 VALUES (1);
INSERT INTO b1 VALUES (2);
INSERT INTO c1 VALUES (3);

# Only a1 should be replicated to slave
sync_slave_with_master;
echo [on slave];
SHOW TABLES LIKE '%1';

connection master;
echo [on master];

# Clean up
connection master;
echo [on master];
DROP TABLE IF EXISTS a1,b1,c1;
--source include/rpl_end.inc

connection slave;
SET @@GLOBAL.replicate_wild_do_table="";
SET @@GLOBAL.replicate_wild_ignore_table="";
