summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSachin <sachin.setiya@mariadb.com>2018-12-20 04:44:04 +0530
committerSachin <sachin.setiya@mariadb.com>2018-12-20 04:46:10 +0530
commitf8fe84392dce5185d795cdc2cafe28911e5b530c (patch)
tree20f9bf7d7bbf0b25a7e744b136b558c7754665ac
parentdc9d3d08bc6a7cc3ba6b7fb68c4c433d86e2195c (diff)
downloadmariadb-git-bb-10.1-15839.tar.gz
MDEV-15839 replicate-filter for a connection name with a dotbb-10.1-15839
In replication channel name we can have name like a.b.c.replicate_do_db so instead of going for first '.' we should go for the '.' just before '=', Which is actual key_name
-rw-r--r--mysql-test/suite/multi_source/mdev_15839.cnf15
-rw-r--r--mysql-test/suite/multi_source/mdev_15839.result34
-rw-r--r--mysql-test/suite/multi_source/mdev_15839.test57
-rw-r--r--mysys/my_getopt.c6
4 files changed, 111 insertions, 1 deletions
diff --git a/mysql-test/suite/multi_source/mdev_15839.cnf b/mysql-test/suite/multi_source/mdev_15839.cnf
new file mode 100644
index 00000000000..b61c23855f7
--- /dev/null
+++ b/mysql-test/suite/multi_source/mdev_15839.cnf
@@ -0,0 +1,15 @@
+!include my.cnf
+
+[mysqld.1]
+log-bin
+log-slave-updates
+
+[mysqld.2]
+log-bin
+log-slave-updates
+
+[mysqld.3]
+log-bin
+log-slave-updates
+master.one.replicate_do_db="db1"
+master.two.2.replicate_do_db="db2"
diff --git a/mysql-test/suite/multi_source/mdev_15839.result b/mysql-test/suite/multi_source/mdev_15839.result
new file mode 100644
index 00000000000..e747258be60
--- /dev/null
+++ b/mysql-test/suite/multi_source/mdev_15839.result
@@ -0,0 +1,34 @@
+CHANGE MASTER 'master.one' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root';
+CHANGE MASTER 'master.two.2' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root';
+set default_master_connection = 'master.one';
+START SLAVE;
+include/wait_for_slave_to_start.inc
+set default_master_connection = 'master.two.2';
+START SLAVE;
+include/wait_for_slave_to_start.inc
+set default_master_connection = '';
+create database db1;
+create database not_replicated1;
+create database db2;
+create database not_replicated2;
+show databases;
+Database
+db1
+db2
+information_schema
+mtr
+mysql
+performance_schema
+test
+drop database db1;
+drop database not_replicated1;
+drop database db2;
+drop database not_replicated2;
+stop all slaves;
+Warnings:
+Note 1938 SLAVE 'master.one' stopped
+Note 1938 SLAVE 'master.two.2' stopped
+SET default_master_connection = "master.one";
+include/wait_for_slave_to_stop.inc
+SET default_master_connection = "master.two.2";
+include/wait_for_slave_to_stop.inc
diff --git a/mysql-test/suite/multi_source/mdev_15839.test b/mysql-test/suite/multi_source/mdev_15839.test
new file mode 100644
index 00000000000..7fe0b1f8b90
--- /dev/null
+++ b/mysql-test/suite/multi_source/mdev_15839.test
@@ -0,0 +1,57 @@
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/have_debug.inc
+
+--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
+--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2)
+--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
+
+--connection slave
+--replace_result $SERVER_MYPORT_1 MYPORT_1
+eval CHANGE MASTER 'master.one' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root';
+--replace_result $SERVER_MYPORT_2 MYPORT_2
+eval CHANGE MASTER 'master.two.2' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root';
+
+set default_master_connection = 'master.one';
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+
+set default_master_connection = 'master.two.2';
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
+set default_master_connection = '';
+
+--connection master1
+create database db1;
+create database not_replicated1;
+--save_master_pos
+
+--connection master2
+create database db2;
+create database not_replicated2;
+--save_master_pos
+
+--connection slave
+--sync_with_master 0,'master.one'
+--sync_with_master 0,'master.two.2'
+show databases;
+
+--connection master1
+drop database db1;
+drop database not_replicated1;
+--save_master_pos
+
+--connection master2
+drop database db2;
+drop database not_replicated2;
+--save_master_pos
+
+--connection slave
+--sync_with_master 0,'master.one'
+--sync_with_master 0,'master.two.2'
+
+stop all slaves;
+SET default_master_connection = "master.one";
+--source include/wait_for_slave_to_stop.inc
+SET default_master_connection = "master.two.2";
+--source include/wait_for_slave_to_stop.inc
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 57b28d1fd8a..df52b753666 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -661,9 +661,13 @@ static char *check_struct_option(char *cur_arg, char *key_name)
char *ptr, *end;
DBUG_ENTER("check_struct_option");
- ptr= strcend(cur_arg + 1, '.'); /* Skip the first character */
end= strcend(cur_arg, '=');
+ /* In replicate_do_db* we can have connection name with .*/
+ ptr= strcend(cur_arg + 1, '.'); /* Skip the first character */
+ while (strcend(ptr + 1, '.') < end)
+ ptr= strcend(ptr + 1, '.');
+
/*
If the first dot is after an equal sign, then it is part
of a variable value and the option is not a struct option.