3469 Rohit Kalhans 2011-10-03
BUG#11747866:REPLICATE-REWRITE-DB DOESN'T WORK WITH SINGLE CHARACTER DATABASE NAMES
Problem: replicate-rewrite-db option doesnot work with single character database names.
The last character was being trimmed from the "from" database name.
Background: Since the loop handling the option, has to handle invalid arguments for the
option,while stripping the whitespaces, it was stripping one character from the "from"
database name. In case where there was only one character, this threw an error as
"empty from database name".
Fix. Revamped the loop handling this option. Made sure that the whitespaces are
suitably trimmed and the correct "to" and "from" databases names are passed to the
function handling the replicate_rewrite_db functionality.
@ mysql-test/suite/rpl/r/rpl_replicate_rewrite_db.result
Added: New test-result file.
@ mysql-test/suite/rpl/t/rpl_replicate_rewrite_db.test
Added: New test file.
@ sql/mysqld.cc
Revamped the loop handling this option. Made sure that the whitespaces are
suitably trimmed and the correct "to" and "from" databases names are passed
to the function handling the replicate_rewrite_db functionality.
added:
mysql-test/suite/rpl/r/rpl_replicate_rewrite_db.result
mysql-test/suite/rpl/t/rpl_replicate_rewrite_db.test
modified:
sql/mysqld.cc
3468 Rohit Kalhans 2011-10-03 [merge]
Upmerge from mysql-5.5 to mysql-trunk
modified:
mysql-test/include/commit.inc
mysql-test/r/commit_1innodb.result
=== added file 'mysql-test/suite/rpl/r/rpl_replicate_rewrite_db.result'
--- a/mysql-test/suite/rpl/r/rpl_replicate_rewrite_db.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_replicate_rewrite_db.result 2011-10-03 11:16:06 +0000
@@ -0,0 +1,14 @@
+include/master-slave.inc
+[connection master]
+testing for normal fuctionality
+include/rpl_start_server.inc [server_number=1 parameters: --replicate-rewrite-db='mysql->test']
+[PASS]
+testing with single letter databases name.
+include/rpl_start_server.inc [server_number=1 parameters: --replicate-rewrite-db='a->b']
+[PASS]
+check for '->' operator not found. Should FAIL with error
+[FAIL]
+check for empty "from" db name. Should FAIL with error
+[FAIL]
+check for empty "to" db name. Should FAIL with error
+[FAIL]
=== added file 'mysql-test/suite/rpl/t/rpl_replicate_rewrite_db.test'
--- a/mysql-test/suite/rpl/t/rpl_replicate_rewrite_db.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_replicate_rewrite_db.test 2011-10-03 11:16:06 +0000
@@ -0,0 +1,49 @@
+##---------------------------------------------------------------------------
+# Purpose: Testing error messages for --replicate-rewrite-db option
+##--------------------------------------------------------------------------
+
+#check single character databases. Bug#11747866
+--let $rpl_skip_reset_master_and_slave= 1
+--let $rpl_skip_change_master= 1
+--let $rpl_skip_start_slave= 1
+--source include/master-slave.inc
+--connection master
+
+#check for normal functionality
+--echo testing for normal fuctionality
+--let $rpl_server_number= 1
+--let $rpl_server_parameters= --replicate-rewrite-db='mysql->test'
+--source include/rpl_start_server.inc
+--echo [PASS]
+
+#check for single characters databases. BUG#11747866
+--echo testing with single letter databases name.
+--let $rpl_server_number= 1
+--let $rpl_server_parameters= --replicate-rewrite-db='a->b'
+--source include/rpl_start_server.inc
+--echo [PASS]
+
+#check for '->' operator not found. Should fail with error
+--echo check for '->' operator not found. Should FAIL with error
+--disable_result_log
+--error 1
+exec $MYSQLD --replicate-rewrite-db='mysql' 2>&1;
+--enable_result_log
+--echo [FAIL]
+
+#check for empty "from" db name. Should fail with error
+--echo check for empty "from" db name. Should FAIL with error
+--disable_result_log
+--error 1
+exec $MYSQLD --replicate-rewrite-db= '->test ' 2>&1;
+--enable_result_log
+--echo [FAIL]
+
+#check for empty "to" db name. Should fail with error.
+--echo check for empty "to" db name. Should FAIL with error
+--disable_result_log
+--error 1
+exec $MYSQLD --replicate-rewrite-db='acc-> ' 2>&1;
+--enable_result_log
+--echo [FAIL]
+
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2011-08-20 00:36:03 +0000
+++ b/sql/mysqld.cc 2011-10-03 11:16:06 +0000
@@ -7552,16 +7552,15 @@ mysqld_get_one_option(int optid,
sql_print_error("Bad syntax in replicate-rewrite-db - missing '->'!\n");
return 1;
}
- val= p--;
- while (my_isspace(mysqld_charset, *p) && p > argument)
- *p-- = 0;
- if (p == argument)
+ val= p + 2;
+ while(p > argument && my_isspace(mysqld_charset, p[-1]))
+ p--;
+ *p= 0;
+ if (!*key)
{
sql_print_error("Bad syntax in replicate-rewrite-db - empty FROM db!\n");
return 1;
}
- *val= 0;
- val+= 2;
while (*val && my_isspace(mysqld_charset, *val))
val++;
if (!*val)
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (rohit.kalhans:3468 to 3469) Bug#11747866 | Rohit Kalhans | 3 Oct |