diff options
author | sachin <sachin.setiya@mariadb.com> | 2019-03-20 15:04:24 +0530 |
---|---|---|
committer | sachin <sachin.setiya@mariadb.com> | 2019-03-22 12:13:24 +0530 |
commit | 778c525ff8f47aa56027d185a3f271d34cdb66ef (patch) | |
tree | b483ff1826f7c0808205c620474f989a6d1e76f8 | |
parent | f00e25b4c4dee75d0bc3d8f3027ff1e9c8c5368b (diff) | |
download | mariadb-git-778c525ff8f47aa56027d185a3f271d34cdb66ef.tar.gz |
MDEV-17119 replicate_rewrite_db does not work for single chardatabase name
Fixed issue in logic.
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_rewrt_db.result | 19 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt | 2 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_rewrt_db.test | 19 | ||||
-rw-r--r-- | sql/mysqld.cc | 3 |
4 files changed, 41 insertions, 2 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_rewrt_db.result b/mysql-test/suite/rpl/r/rpl_rewrt_db.result index 6cbd107fdcf..0c80887d169 100644 --- a/mysql-test/suite/rpl/r/rpl_rewrt_db.result +++ b/mysql-test/suite/rpl/r/rpl_rewrt_db.result @@ -1,19 +1,36 @@ include/master-slave.inc [connection master] +set sql_log_bin=0; +create database y; +set sql_log_bin=1; drop database if exists mysqltest1; +drop database if exists x; create database mysqltest1; +set sql_log_bin=0; +create database x; +set sql_log_bin=1; use mysqltest1; create table t1 (a int); insert into t1 values(9); +use x; +create table t1 (a int); +insert into t1 values(9); select * from mysqltest1.t1; a 9 +select * from x.t1; +a +9 show databases like 'mysqltest1'; Database (mysqltest1) mysqltest1 select * from test.t1; a 9 +select * from y.t1; +a +9 +use mysqltest1; drop table t1; drop database mysqltest1; drop database if exists rewrite; @@ -209,10 +226,12 @@ SET sql_log_bin= 0; DROP DATABASE database_master_temp_01; DROP DATABASE database_master_temp_02; DROP DATABASE database_master_temp_03; +DROP DATABASE x; SET sql_log_bin= 1; SET sql_log_bin= 0; DROP DATABASE database_slave_temp_01; DROP DATABASE database_slave_temp_02; DROP DATABASE database_slave_temp_03; +DROP DATABASE y; SET sql_log_bin= 1; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt b/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt index 290b92e0a3e..84059110136 100644 --- a/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt +++ b/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt @@ -1 +1 @@ -"--replicate-rewrite-db=test->rewrite" "--replicate-rewrite-db=mysqltest1->test" "--replicate-rewrite-db=database_master_temp_01->database_slave_temp_01" "--replicate-rewrite-db=database_master_temp_02->database_slave_temp_02" "--replicate-rewrite-db=database_master_temp_03->database_slave_temp_03" +"--replicate-rewrite-db=test->rewrite" "--replicate-rewrite-db=mysqltest1 -> test" "--replicate-rewrite-db=x -> y" "--replicate-rewrite-db=database_master_temp_01->database_slave_temp_01" "--replicate-rewrite-db=database_master_temp_02->database_slave_temp_02" "--replicate-rewrite-db=database_master_temp_03->database_slave_temp_03" diff --git a/mysql-test/suite/rpl/t/rpl_rewrt_db.test b/mysql-test/suite/rpl/t/rpl_rewrt_db.test index 996ad0a10c7..bd0749bc2de 100644 --- a/mysql-test/suite/rpl/t/rpl_rewrt_db.test +++ b/mysql-test/suite/rpl/t/rpl_rewrt_db.test @@ -2,20 +2,37 @@ -- source include/have_binlog_format_mixed_or_statement.inc -- source include/master-slave.inc +--connection slave +set sql_log_bin=0; +create database y; +set sql_log_bin=1; + +--connection master --disable_warnings drop database if exists mysqltest1; +drop database if exists x; --enable_warnings create database mysqltest1; +set sql_log_bin=0; +create database x; +set sql_log_bin=1; use mysqltest1; create table t1 (a int); insert into t1 values(9); +use x; +create table t1 (a int); +insert into t1 values(9); select * from mysqltest1.t1; +select * from x.t1; sync_slave_with_master; +#TODO no it is no empty show databases like 'mysqltest1'; # should be empty select * from test.t1; +select * from y.t1; # cleanup connection master; +use mysqltest1; drop table t1; drop database mysqltest1; sync_slave_with_master; @@ -224,6 +241,7 @@ SET sql_log_bin= 0; DROP DATABASE database_master_temp_01; DROP DATABASE database_master_temp_02; DROP DATABASE database_master_temp_03; +DROP DATABASE x; SET sql_log_bin= 1; connection slave; @@ -231,6 +249,7 @@ SET sql_log_bin= 0; DROP DATABASE database_slave_temp_01; DROP DATABASE database_slave_temp_02; DROP DATABASE database_slave_temp_03; +DROP DATABASE y; SET sql_log_bin= 1; connection master; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index aa749e5aaef..528c5d8ecfe 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7596,7 +7596,8 @@ mysqld_get_one_option(int optid, val= p--; while (my_isspace(mysqld_charset, *p) && p > argument) *p-- = 0; - if (p == argument) + /* Db name can be one char also */ + if (p == argument && my_isspace(mysqld_charset, *p)) { sql_print_error("Bad syntax in replicate-rewrite-db - empty FROM db!\n"); return 1; |