Commit cff27c6b authored by Sergey Petrunya's avatar Sergey Petrunya

MWL#36: Add a mysqlbinlog option to change the used database

- Apply Alexander Ivanov's fix to testsuite
parent e1e10417
...@@ -22,19 +22,21 @@ LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE t1 ...@@ -22,19 +22,21 @@ LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE t1
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'; FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';
DELETE FROM test3.t3 WHERE a=1; DELETE FROM test3.t3 WHERE a=1;
flush logs; flush logs;
#
# mysqlbinlog output
# --base64-output = decode-rows
# --rewrite-db = test1->new_test1
# --rewrite-db = test3->new_test3
#
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/; DELIMITER /*!*/;
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup #010909 4:46:40 server id # end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
ROLLBACK/*!*/; ROLLBACK/*!*/;
BINLOG '
AMqaOw8BAAAAZgAAAGoAAAAAAAQANS4xLjM4LU1hcmlhREItYmV0YTEtZGVidWctbG9nAAAAAAAA
AAAAAAAAAAAAAAAAAAAAypo7EzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
# at # # at #
use new_test1/*!*/; use new_test1/*!*/;
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/; SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
...@@ -47,19 +49,14 @@ SET @@session.collation_database=DEFAULT/*!*/; ...@@ -47,19 +49,14 @@ SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (a INT, b INT) CREATE TABLE t1 (a INT, b INT)
/*!*/; /*!*/;
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
# at # # at #
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `new_test1`.`t1` mapped to number # #010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F #010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F
BINLOG '
AMqaOxMBAAAALwAAADgBAAAAABcAAAAAAAAACW5ld190ZXN0MQACdDEAAgMDAAM=
AMqaOxcBAAAALwAAAGcBAAAQABcAAAAAAAEAAv/8AQAAAAEAAAD8AgAAAAIAAAA=
'/*!*/;
### INSERT INTO new_test1.t1 ### INSERT INTO new_test1.t1
### SET ### SET
### @1=1 /* INT meta=0 nullable=1 is_null=0 */ ### @1=1 /* INT meta=0 nullable=1 is_null=0 */
...@@ -69,30 +66,25 @@ AMqaOxcBAAAALwAAAGcBAAAQABcAAAAAAAEAAv/8AQAAAAEAAAD8AgAAAAIAAAA= ...@@ -69,30 +66,25 @@ AMqaOxcBAAAALwAAAGcBAAAQABcAAAAAAAEAAv/8AQAAAAEAAAD8AgAAAAIAAAA=
### @1=2 /* INT meta=0 nullable=1 is_null=0 */ ### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2=2 /* INT meta=0 nullable=1 is_null=0 */ ### @2=2 /* INT meta=0 nullable=1 is_null=0 */
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
use test2/*!*/; use test2/*!*/;
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t2 (a INT) CREATE TABLE t2 (a INT)
/*!*/; /*!*/;
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
# at # # at #
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test2`.`t2` mapped to number # #010909 4:46:40 server id # end_log_pos # Table_map: `test2`.`t2` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F #010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F
BINLOG '
AMqaOxMBAAAAKgAAAHMCAAAAABgAAAAAAAAABXRlc3QyAAJ0MgABAwAB
AMqaOxcBAAAAJwAAAJoCAAAQABgAAAAAAAEAAf/+AQAAAP4CAAAA
'/*!*/;
### INSERT INTO test2.t2 ### INSERT INTO test2.t2
### SET ### SET
### @1=1 /* INT meta=0 nullable=1 is_null=0 */ ### @1=1 /* INT meta=0 nullable=1 is_null=0 */
...@@ -100,53 +92,43 @@ AMqaOxcBAAAAJwAAAJoCAAAQABgAAAAAAAEAAf/+AQAAAP4CAAAA ...@@ -100,53 +92,43 @@ AMqaOxcBAAAAJwAAAJoCAAAQABgAAAAAAAEAAf/+AQAAAP4CAAAA
### SET ### SET
### @1=2 /* INT meta=0 nullable=1 is_null=0 */ ### @1=2 /* INT meta=0 nullable=1 is_null=0 */
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
# at # # at #
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `new_test1`.`t1` mapped to number # #010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Delete_rows: table id # flags: STMT_END_F #010909 4:46:40 server id # end_log_pos # Delete_rows: table id # flags: STMT_END_F
BINLOG '
AMqaOxMBAAAALwAAAFADAAAAABcAAAAAAAAACW5ld190ZXN0MQACdDEAAgMDAAM=
AMqaOxkBAAAAJgAAAHYDAAAQABcAAAAAAAEAAv/8AQAAAAEAAAA=
'/*!*/;
### DELETE FROM new_test1.t1 ### DELETE FROM new_test1.t1
### WHERE ### WHERE
### @1=1 /* INT meta=0 nullable=1 is_null=0 */ ### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2=1 /* INT meta=0 nullable=1 is_null=0 */ ### @2=1 /* INT meta=0 nullable=1 is_null=0 */
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at # # at #
use new_test3/*!*/; use new_test3/*!*/;
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t3 (a INT) CREATE TABLE t3 (a INT)
/*!*/; /*!*/;
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
# at # # at #
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `new_test3`.`t3` mapped to number # #010909 4:46:40 server id # end_log_pos # Table_map: `new_test3`.`t3` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F #010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F
BINLOG '
AMqaOxMBAAAALgAAAIIEAAAAABkAAAAAAAAACW5ld190ZXN0MwACdDMAAQMAAQ==
AMqaOxcBAAAAJwAAAKkEAAAQABkAAAAAAAEAAf/+AQAAAP4CAAAA
'/*!*/;
### INSERT INTO new_test3.t3 ### INSERT INTO new_test3.t3
### SET ### SET
### @1=1 /* INT meta=0 nullable=1 is_null=0 */ ### @1=1 /* INT meta=0 nullable=1 is_null=0 */
...@@ -154,49 +136,38 @@ AMqaOxcBAAAAJwAAAKkEAAAQABkAAAAAAAEAAf/+AQAAAP4CAAAA ...@@ -154,49 +136,38 @@ AMqaOxcBAAAAJwAAAKkEAAAQABkAAAAAAAEAAf/+AQAAAP4CAAAA
### SET ### SET
### @1=2 /* INT meta=0 nullable=1 is_null=0 */ ### @1=2 /* INT meta=0 nullable=1 is_null=0 */
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
# at # # at #
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `new_test1`.`t1` mapped to number # #010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F #010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F
BINLOG '
AMqaOxMBAAAALwAAAF8FAAAAABcAAAAAAAAACW5ld190ZXN0MQACdDEAAgMDAAM=
AMqaOxcBAAAAJgAAAIUFAAAQABcAAAAAAAEAAv/8AwAAAAMAAAA=
'/*!*/;
### INSERT INTO new_test1.t1 ### INSERT INTO new_test1.t1
### SET ### SET
### @1=3 /* INT meta=0 nullable=1 is_null=0 */ ### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2=3 /* INT meta=0 nullable=1 is_null=0 */ ### @2=3 /* INT meta=0 nullable=1 is_null=0 */
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at # # at #
use new_test1/*!*/; use new_test1/*!*/;
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
# at # # at #
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `new_test1`.`t1` mapped to number # #010909 4:46:40 server id # end_log_pos # Table_map: `new_test1`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F #010909 4:46:40 server id # end_log_pos # Write_rows: table id # flags: STMT_END_F
BINLOG '
AMqaOxMBAAAALwAAADsGAAAAABcAAAAAAAAACW5ld190ZXN0MQACdDEAAgMDAAM=
AMqaOxcBAAAASgAAAIUGAAAQABcAAAAAAAEAAv/8AgAAAAIAAAD8AwAAAAMAAAD8BAAAAAQAAAD8
BQAAAAUAAAD8BgAAAAYAAAA=
'/*!*/;
### INSERT INTO new_test1.t1 ### INSERT INTO new_test1.t1
### SET ### SET
### @1=2 /* INT meta=0 nullable=1 is_null=0 */ ### @1=2 /* INT meta=0 nullable=1 is_null=0 */
...@@ -218,34 +189,29 @@ BQAAAAUAAAD8BgAAAAYAAAA= ...@@ -218,34 +189,29 @@ BQAAAAUAAAD8BgAAAAYAAAA=
### @1=6 /* INT meta=0 nullable=1 is_null=0 */ ### @1=6 /* INT meta=0 nullable=1 is_null=0 */
### @2=6 /* INT meta=0 nullable=1 is_null=0 */ ### @2=6 /* INT meta=0 nullable=1 is_null=0 */
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
# at # # at #
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `new_test3`.`t3` mapped to number # #010909 4:46:40 server id # end_log_pos # Table_map: `new_test3`.`t3` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Delete_rows: table id # flags: STMT_END_F #010909 4:46:40 server id # end_log_pos # Delete_rows: table id # flags: STMT_END_F
BINLOG '
AMqaOxMBAAAALgAAADoHAAAAABkAAAAAAAAACW5ld190ZXN0MwACdDMAAQMAAQ==
AMqaOxkBAAAAIgAAAFwHAAAQABkAAAAAAAEAAf/+AQAAAA==
'/*!*/;
### DELETE FROM new_test3.t3 ### DELETE FROM new_test3.t3
### WHERE ### WHERE
### @1=1 /* INT meta=0 nullable=1 is_null=0 */ ### @1=1 /* INT meta=0 nullable=1 is_null=0 */
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0 #010909 4:46:40 server id # end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/; SET TIMESTAMP=1000000000/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at # # at #
#010909 4:46:40 server id 1 end_log_pos # Rotate to master-bin.000002 pos: 4 #010909 4:46:40 server id # end_log_pos # Rotate to master-bin.000002 pos: 4
DELIMITER ; DELIMITER ;
# End of log file # End of log file
ROLLBACK /* added by mysqlbinlog */; ROLLBACK /* added by mysqlbinlog */;
......
...@@ -51,9 +51,16 @@ DELETE FROM test3.t3 WHERE a=1; ...@@ -51,9 +51,16 @@ DELETE FROM test3.t3 WHERE a=1;
flush logs; flush logs;
--echo #
--echo # mysqlbinlog output
--echo # --base64-output = decode-rows
--echo # --rewrite-db = test1->new_test1
--echo # --rewrite-db = test3->new_test3
--echo #
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--replace_regex /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ --replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
--exec $MYSQL_BINLOG --rewrite-db="test1->new_test1" --rewrite-db="test3->new_test3" -v -v $MYSQLD_DATADIR/master-bin.000001 --exec $MYSQL_BINLOG --base64-output=decode-rows --rewrite-db="test1->new_test1" --rewrite-db="test3->new_test3" -v -v $MYSQLD_DATADIR/master-bin.000001
DROP DATABASE test1; DROP DATABASE test1;
DROP DATABASE test2; DROP DATABASE test2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment