commit f8fe84392dce5185d795cdc2cafe28911e5b530c Author: Sachin <sachin.setiya@mariadb.com> Date: Thu Dec 20 04:44:04 2018 +0530 MDEV-15839 replicate-filter for a connection name with a dot 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 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. -- Regards Sachin Setiya Software Engineer at MariaDB