From 4a40438ef0a37619493af25393dd454918b5ce0b Mon Sep 17 00:00:00 2001 From: "mats@mysql.com" <> Date: Wed, 4 Jan 2006 19:17:43 +0100 Subject: [PATCH 1/4] The ha_*_row() function shall not be virtual since they represent public interface for handler users. Virtual keyword removed for those functions. --- sql/handler.h | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/sql/handler.h b/sql/handler.h index eff4ecdc4d2..3772131d2e3 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1101,9 +1101,17 @@ public: uint get_index(void) const { return active_index; } virtual int open(const char *name, int mode, uint test_if_locked)=0; virtual int close(void)=0; - virtual int ha_write_row(byte * buf); - virtual int ha_update_row(const byte * old_data, byte * new_data); - virtual int ha_delete_row(const byte * buf); + + /* + These functions represent the public interface to *users* of the + handler class, hence they are *not* virtual. For the inheritance + interface, see the (private) functions write_row(), update_row(), + and delete_row() below. + */ + int ha_write_row(byte * buf); + int ha_update_row(const byte * old_data, byte * new_data); + int ha_delete_row(const byte * buf); + /* SYNOPSIS start_bulk_update() @@ -1472,28 +1480,27 @@ public: { return COMPATIBLE_DATA_NO; } private: - - /* - Row-level primitives for storage engines. - These should be overridden by the storage engine class. To call - these methods, use the corresponding 'ha_*' method above. - */ friend int ndb_add_binlog_index(THD *, void *); - virtual int write_row(byte *buf __attribute__((unused))) - { - return HA_ERR_WRONG_COMMAND; + /* + Row-level primitives for storage engines. These should be + overridden by the storage engine class. To call these methods, use + the corresponding 'ha_*' method above. + */ + virtual int write_row(byte *buf __attribute__((unused))) + { + return HA_ERR_WRONG_COMMAND; } virtual int update_row(const byte *old_data __attribute__((unused)), byte *new_data __attribute__((unused))) - { - return HA_ERR_WRONG_COMMAND; + { + return HA_ERR_WRONG_COMMAND; } virtual int delete_row(const byte *buf __attribute__((unused))) - { - return HA_ERR_WRONG_COMMAND; + { + return HA_ERR_WRONG_COMMAND; } }; From 5f7956094c0f675f1714b602593cc01a1793fb89 Mon Sep 17 00:00:00 2001 From: "mats@mysql.com" <> Date: Thu, 26 Jan 2006 09:25:37 +0100 Subject: [PATCH 2/4] WL#3023 (RBR: Use locks in a statment-like manner): Interface changes pushed early. Separation of public and implementation interface for external_lock() in preparation for implementation. --- sql/handler.cc | 38 +++++++++++++++++++++++--------------- sql/handler.h | 8 +++++++- sql/lock.cc | 6 +++--- sql/opt_range.cc | 6 +++--- sql/sql_table.cc | 4 ++-- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 7b86cafc367..c380ff3508e 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3014,40 +3014,48 @@ template int binlog_log_row(TABLE *, const byte *, const #endif /* HAVE_ROW_BASED_REPLICATION */ +int handler::ha_external_lock(THD *thd, int lock_type) +{ + int error; + if (unlikely(error= external_lock(thd, lock_type))) + return error; + return 0; +} + int handler::ha_write_row(byte *buf) { int error; - if (likely(!(error= write_row(buf)))) - { + if (unlikely(error= write_row(buf))) + return error; #ifdef HAVE_ROW_BASED_REPLICATION - error= binlog_log_row(table, 0, buf); + if (unlikely(error= binlog_log_row(table, 0, buf))) + return error; #endif - } - return error; + return 0; } int handler::ha_update_row(const byte *old_data, byte *new_data) { int error; - if (likely(!(error= update_row(old_data, new_data)))) - { + if (unlikely(error= update_row(old_data, new_data))) + return error; #ifdef HAVE_ROW_BASED_REPLICATION - error= binlog_log_row(table, old_data, new_data); + if (unlikely(error= binlog_log_row(table, old_data, new_data))) + return error; #endif - } - return error; + return 0; } int handler::ha_delete_row(const byte *buf) { int error; - if (likely(!(error= delete_row(buf)))) - { + if (unlikely(error= delete_row(buf))) + return error; #ifdef HAVE_ROW_BASED_REPLICATION - error= binlog_log_row(table, buf, 0); + if (unlikely(error= binlog_log_row(table, buf, 0))) + return error; #endif - } - return error; + return 0; } diff --git a/sql/handler.h b/sql/handler.h index 8545d8c082c..8551ea64149 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1237,6 +1237,7 @@ public: interface, see the (private) functions write_row(), update_row(), and delete_row() below. */ + int ha_external_lock(THD *thd, int lock_type); int ha_write_row(byte * buf); int ha_update_row(const byte * old_data, byte * new_data); int ha_delete_row(const byte * buf); @@ -1378,7 +1379,6 @@ public: { return 0; } virtual int extra_opt(enum ha_extra_function operation, ulong cache_size) { return extra(operation); } - virtual int external_lock(THD *thd, int lock_type) { return 0; } /* In an UPDATE or DELETE, if the row under the cursor was locked by another transaction, and the engine used an optimistic read of the last @@ -1626,6 +1626,12 @@ private: overridden by the storage engine class. To call these methods, use the corresponding 'ha_*' method above. */ + virtual int external_lock(THD *thd __attribute__((unused)), + int lock_type __attribute__((unused))) + { + return 0; + } + virtual int write_row(byte *buf __attribute__((unused))) { return HA_ERR_WRONG_COMMAND; diff --git a/sql/lock.cc b/sql/lock.cc index 8e24c56799d..edc76fbe660 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -229,12 +229,12 @@ static int lock_external(THD *thd, TABLE **tables, uint count) ((*tables)->reginfo.lock_type >= TL_READ && (*tables)->reginfo.lock_type <= TL_READ_NO_INSERT)) lock_type=F_RDLCK; - if ((error=(*tables)->file->external_lock(thd,lock_type))) + if ((error=(*tables)->file->ha_external_lock(thd,lock_type))) { print_lock_error(error, (*tables)->file->table_type()); for (; i-- ; tables--) { - (*tables)->file->external_lock(thd, F_UNLCK); + (*tables)->file->ha_external_lock(thd, F_UNLCK); (*tables)->current_lock=F_UNLCK; } DBUG_RETURN(error); @@ -562,7 +562,7 @@ static int unlock_external(THD *thd, TABLE **table,uint count) if ((*table)->current_lock != F_UNLCK) { (*table)->current_lock = F_UNLCK; - if ((error=(*table)->file->external_lock(thd, F_UNLCK))) + if ((error=(*table)->file->ha_external_lock(thd, F_UNLCK))) { error_code=error; print_lock_error(error_code, (*table)->file->table_type()); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 7dd694f3411..e99bb77c0c7 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -844,7 +844,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file, free_file)); file->ha_reset(); - file->external_lock(current_thd, F_UNLCK); + file->ha_external_lock(current_thd, F_UNLCK); file->close(); delete file; } @@ -1008,14 +1008,14 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler) /* Caller will free the memory */ goto failure; } - if (file->external_lock(thd, F_RDLCK)) + if (file->ha_external_lock(thd, F_RDLCK)) goto failure; if (file->extra(HA_EXTRA_KEYREAD) || file->ha_retrieve_all_pk() || init() || reset()) { - file->external_lock(thd, F_UNLCK); + file->ha_external_lock(thd, F_UNLCK); file->close(); goto failure; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f2da98dcee2..f08c37ad40d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5254,7 +5254,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (!(copy= new Copy_field[to->s->fields])) DBUG_RETURN(-1); /* purecov: inspected */ - if (to->file->external_lock(thd, F_WRLCK)) + if (to->file->ha_external_lock(thd, F_WRLCK)) DBUG_RETURN(-1); /* We can abort alter table for any table type */ @@ -5394,7 +5394,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, free_io_cache(from); *copied= found_count; *deleted=delete_count; - if (to->file->external_lock(thd,F_UNLCK)) + if (to->file->ha_external_lock(thd,F_UNLCK)) error=1; DBUG_RETURN(error > 0 ? -1 : 0); } From 2884408c751f770cc27375743b870f667d8f54af Mon Sep 17 00:00:00 2001 From: "mats@mysql.com" <> Date: Thu, 16 Feb 2006 08:30:53 +0100 Subject: [PATCH 3/4] WL#3023 (Use locks in a statement-like manner): Table maps are now written on aquiring locks to tables and released at the end of each logical statement. --- .../extra/binlog_tests/ctype_cp932.test | 4 + mysql-test/r/binlog_row_blackhole.result | 12 + .../r/binlog_row_mix_innodb_myisam.result | 38 +- mysql-test/r/binlog_stm_ctype_cp932.result | 1 - mysql-test/r/rpl_row_charset.result | 10 + mysql-test/r/rpl_row_create_table.result | 22 +- mysql-test/t/rpl_row_create_table.test | 8 +- sql/handler.cc | 37 +- sql/handler.h | 28 ++ sql/log.cc | 128 +++--- sql/log.h | 11 +- sql/log_event.cc | 430 ++++++++---------- sql/log_event.h | 11 +- sql/mysql_priv.h | 3 +- sql/parse_file.cc | 3 +- sql/rpl_rli.h | 16 +- sql/slave.cc | 4 + sql/sql_acl.cc | 10 - sql/sql_base.cc | 26 +- sql/sql_class.cc | 116 +++-- sql/sql_class.h | 25 +- sql/sql_insert.cc | 67 +-- sql/sql_load.cc | 13 - sql/sql_table.cc | 4 +- sql/sql_update.cc | 2 +- sql/table.h | 3 +- 26 files changed, 560 insertions(+), 472 deletions(-) diff --git a/mysql-test/extra/binlog_tests/ctype_cp932.test b/mysql-test/extra/binlog_tests/ctype_cp932.test index ac90ceabf23..6fb91e9ae50 100644 --- a/mysql-test/extra/binlog_tests/ctype_cp932.test +++ b/mysql-test/extra/binlog_tests/ctype_cp932.test @@ -434,4 +434,8 @@ insert into t1 values ('ab'); select * from t1; insert into t1 values ('abc'); select * from t1; +--disable_query_log +--disable_warnings drop table t1; +--enable_warnings +--enable_query_log diff --git a/mysql-test/r/binlog_row_blackhole.result b/mysql-test/r/binlog_row_blackhole.result index 5c79f27bdf5..39d7f5a0ada 100644 --- a/mysql-test/r/binlog_row_blackhole.result +++ b/mysql-test/r/binlog_row_blackhole.result @@ -118,6 +118,12 @@ master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Table_map 1 # test.t1 master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # use `test`; COMMIT +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Query 1 # use `test`; COMMIT +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; create table t2 (a varchar(200)) engine=blackhole master-bin.000001 # Table_map 1 # test.t2 master-bin.000001 # Write_rows 1 # @@ -125,6 +131,12 @@ master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; alter table t1 add b int master-bin.000001 # Query 1 # use `test`; alter table t1 drop b master-bin.000001 # Query 1 # use `test`; create table t3 like t1 +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Query 1 # use `test`; COMMIT +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Query 1 # use `test`; COMMIT drop table t1,t2,t3; reset master; create table t1 (a int) engine=blackhole; diff --git a/mysql-test/r/binlog_row_mix_innodb_myisam.result b/mysql-test/r/binlog_row_mix_innodb_myisam.result index b444d7a3edc..4ebbec4a424 100644 --- a/mysql-test/r/binlog_row_mix_innodb_myisam.result +++ b/mysql-test/r/binlog_row_mix_innodb_myisam.result @@ -262,22 +262,26 @@ master-bin.000001 209 Write_rows 1 # master-bin.000001 243 Table_map 1 # test.t1 master-bin.000001 282 Write_rows 1 # master-bin.000001 316 Xid 1 # COMMIT /* xid= */ -master-bin.000001 343 Query 1 # use `test`; delete from t1 -master-bin.000001 420 Xid 1 # COMMIT /* xid= */ -master-bin.000001 447 Query 1 # use `test`; delete from t2 -master-bin.000001 524 Xid 1 # COMMIT /* xid= */ -master-bin.000001 551 Query 1 # use `test`; alter table t2 type=MyISAM -master-bin.000001 640 Table_map 1 # test.t1 -master-bin.000001 679 Write_rows 1 # -master-bin.000001 713 Xid 1 # COMMIT /* xid= */ -master-bin.000001 740 Table_map 1 # test.t2 -master-bin.000001 779 Write_rows 1 # -master-bin.000001 813 Query 1 # use `test`; drop table t1,t2 -master-bin.000001 892 Query 1 # use `test`; create table t0 (n int) -master-bin.000001 978 Table_map 1 # test.t0 -master-bin.000001 1017 Write_rows 1 # -master-bin.000001 1051 Table_map 1 # test.t0 -master-bin.000001 1090 Write_rows 1 # -master-bin.000001 1124 Query 1 # use `test`; create table t2 (n int) engine=innodb +master-bin.000001 343 Table_map 1 # test.t1 +master-bin.000001 382 Query 1 # use `test`; delete from t1 +master-bin.000001 459 Xid 1 # COMMIT /* xid= */ +master-bin.000001 486 Table_map 1 # test.t2 +master-bin.000001 525 Query 1 # use `test`; delete from t2 +master-bin.000001 602 Xid 1 # COMMIT /* xid= */ +master-bin.000001 629 Query 1 # use `test`; alter table t2 type=MyISAM +master-bin.000001 718 Table_map 1 # test.t1 +master-bin.000001 757 Write_rows 1 # +master-bin.000001 791 Xid 1 # COMMIT /* xid= */ +master-bin.000001 818 Query 1 # use `test`; BEGIN +master-bin.000001 886 Table_map 1 # test.t1 +master-bin.000001 925 Write_rows 1 # +master-bin.000001 954 Xid 1 # COMMIT /* xid= */ +master-bin.000001 981 Query 1 # use `test`; drop table t1,t2 +master-bin.000001 1060 Query 1 # use `test`; create table t0 (n int) +master-bin.000001 1146 Table_map 1 # test.t0 +master-bin.000001 1185 Write_rows 1 # +master-bin.000001 1219 Table_map 1 # test.t0 +master-bin.000001 1258 Write_rows 1 # +master-bin.000001 1292 Query 1 # use `test`; create table t2 (n int) engine=innodb do release_lock("lock1"); drop table t0,t2; diff --git a/mysql-test/r/binlog_stm_ctype_cp932.result b/mysql-test/r/binlog_stm_ctype_cp932.result index 470ae3b5ab2..146fb2ca2d5 100755 --- a/mysql-test/r/binlog_stm_ctype_cp932.result +++ b/mysql-test/r/binlog_stm_ctype_cp932.result @@ -11366,4 +11366,3 @@ col1 a a a -drop table t1; diff --git a/mysql-test/r/rpl_row_charset.result b/mysql-test/r/rpl_row_charset.result index 3b065a06826..4108d0c6d90 100644 --- a/mysql-test/r/rpl_row_charset.result +++ b/mysql-test/r/rpl_row_charset.result @@ -112,10 +112,16 @@ drop database mysqltest3; show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest2 +master-bin.000001 # Table_map 1 # mysql.proc +master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # drop database if exists mysqltest3 +master-bin.000001 # Table_map 1 # mysql.proc +master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # create database mysqltest2 character set latin2 master-bin.000001 # Query 1 # create database mysqltest3 master-bin.000001 # Query 1 # drop database mysqltest3 +master-bin.000001 # Table_map 1 # mysql.proc +master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # create database mysqltest3 master-bin.000001 # Query 1 # use `mysqltest2`; create table t1 (a int auto_increment primary key, b varchar(100)) master-bin.000001 # Table_map 1 # mysqltest2.t1 @@ -141,7 +147,11 @@ master-bin.000001 # Query 1 # use `mysqltest2`; truncate table t1 master-bin.000001 # Table_map 1 # mysqltest2.t1 master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # drop database mysqltest2 +master-bin.000001 # Table_map 1 # mysql.proc +master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # drop database mysqltest3 +master-bin.000001 # Table_map 1 # mysql.proc +master-bin.000001 # Write_rows 1 # select "--- --global--" as ""; --- --global-- diff --git a/mysql-test/r/rpl_row_create_table.result b/mysql-test/r/rpl_row_create_table.result index 9182a1d6d89..0a443d243ac 100644 --- a/mysql-test/r/rpl_row_create_table.result +++ b/mysql-test/r/rpl_row_create_table.result @@ -127,7 +127,7 @@ NULL 5 10 NULL 6 12 CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; ERROR 23000: Duplicate entry '2' for key 1 -SHOW BINLOG EVENTS FROM 1256; +SHOW BINLOG EVENTS FROM 1326; Log_name Pos Event_type Server_id End_log_pos Info CREATE TABLE t7 (a INT, b INT UNIQUE); INSERT INTO t7 SELECT a,b FROM tt3; @@ -137,11 +137,11 @@ a b 1 2 2 4 3 6 -SHOW BINLOG EVENTS FROM 1256; +SHOW BINLOG EVENTS FROM 1326; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1256 Query 1 1356 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) -master-bin.000001 1356 Table_map 1 1396 test.t7 -master-bin.000001 1396 Write_rows 1 1452 +master-bin.000001 1326 Query 1 1426 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) +master-bin.000001 1426 Table_map 1 1466 test.t7 +master-bin.000001 1466 Write_rows 1 1522 SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -154,10 +154,10 @@ INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back -SHOW BINLOG EVENTS FROM 1452; +SHOW BINLOG EVENTS FROM 1522; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1452 Table_map 1 1492 test.t7 -master-bin.000001 1492 Write_rows 1 1548 +master-bin.000001 1522 Table_map 1 1562 test.t7 +master-bin.000001 1562 Write_rows 1 1618 SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -191,10 +191,10 @@ Create Table CREATE TABLE `t9` ( `a` int(11) default NULL, `b` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -SHOW BINLOG EVENTS FROM 1548; +SHOW BINLOG EVENTS FROM 1618; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1548 Query 1 1634 use `test`; CREATE TABLE t8 LIKE t4 -master-bin.000001 1634 Query 1 1773 use `test`; CREATE TABLE `t9` ( +master-bin.000001 1618 Query 1 1704 use `test`; CREATE TABLE t8 LIKE t4 +master-bin.000001 1704 Query 1 1843 use `test`; CREATE TABLE `t9` ( `a` int(11) default NULL, `b` int(11) default NULL ) diff --git a/mysql-test/t/rpl_row_create_table.test b/mysql-test/t/rpl_row_create_table.test index faabf489bba..52373b8278c 100644 --- a/mysql-test/t/rpl_row_create_table.test +++ b/mysql-test/t/rpl_row_create_table.test @@ -60,7 +60,7 @@ connection master; --error 1062 CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; # Shouldn't be written to the binary log -SHOW BINLOG EVENTS FROM 1256; +SHOW BINLOG EVENTS FROM 1326; # Test that INSERT-SELECT works the same way as for SBR. CREATE TABLE t7 (a INT, b INT UNIQUE); @@ -68,7 +68,7 @@ CREATE TABLE t7 (a INT, b INT UNIQUE); INSERT INTO t7 SELECT a,b FROM tt3; SELECT * FROM t7 ORDER BY a,b; # Should be written to the binary log -SHOW BINLOG EVENTS FROM 1256; +SHOW BINLOG EVENTS FROM 1326; sync_slave_with_master; SELECT * FROM t7 ORDER BY a,b; @@ -78,7 +78,7 @@ INSERT INTO tt4 VALUES (4,8), (5,10), (6,12); BEGIN; INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; -SHOW BINLOG EVENTS FROM 1452; +SHOW BINLOG EVENTS FROM 1522; SELECT * FROM t7 ORDER BY a,b; sync_slave_with_master; SELECT * FROM t7 ORDER BY a,b; @@ -91,7 +91,7 @@ CREATE TEMPORARY TABLE tt6 LIKE tt4; --echo **** On Master **** --query_vertical SHOW CREATE TABLE t8 --query_vertical SHOW CREATE TABLE t9 -SHOW BINLOG EVENTS FROM 1548; +SHOW BINLOG EVENTS FROM 1618; sync_slave_with_master; --echo **** On Slave **** --query_vertical SHOW CREATE TABLE t8 diff --git a/sql/handler.cc b/sql/handler.cc index c380ff3508e..6ea627ba9e7 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3016,10 +3016,43 @@ template int binlog_log_row(TABLE *, const byte *, const int handler::ha_external_lock(THD *thd, int lock_type) { + DBUG_ENTER("handler::ha_external_lock"); int error; if (unlikely(error= external_lock(thd, lock_type))) - return error; - return 0; + DBUG_RETURN(error); +#ifdef HAVE_ROW_BASED_REPLICATION + if (table->file->is_injective()) + DBUG_RETURN(0); + + /* + There is a number of statements that are logged statement-based + but call external lock. For these, we do not need to generate a + table map. + + TODO: The need for this switch is an indication that the model for + locking combined with row-based replication needs to be looked + over. Ideally, no such special handling should be needed. + */ + switch (thd->lex->sql_command) + { + case SQLCOM_TRUNCATE: + case SQLCOM_ALTER_TABLE: + DBUG_RETURN(0); + } + + /* + If we are locking a table for writing, we generate a table map. + For all other kinds of locks, we don't do anything. + */ + if (lock_type == F_WRLCK && check_table_binlog_row_based(thd, table)) + { + int const has_trans= table->file->has_transactions(); + error= thd->binlog_write_table_map(table, has_trans); + if (unlikely(error)) + DBUG_RETURN(error); + } +#endif + DBUG_RETURN(0); } int handler::ha_write_row(byte *buf) diff --git a/sql/handler.h b/sql/handler.h index 8551ea64149..dea80e5de87 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -871,7 +871,35 @@ typedef struct st_ha_create_information bool store_on_disk; /* 1 if table stored on disk */ } HA_CREATE_INFO; +/* + Class for maintaining hooks used inside operations on tables such + as: create table functions, delete table functions, and alter table + functions. + Class is using the Template Method pattern to separate the public + usage interface from the private inheritance interface. This + imposes no overhead, since the public non-virtual function is small + enough to be inlined. + + The hooks are usually used for functions that does several things, + e.g., create_table_from_items(), which both create a table and lock + it. + */ +class TABLEOP_HOOKS +{ +public: + inline void prelock(TABLE **tables, uint count) + { + do_prelock(tables, count); + } + +private: + /* Function primitive that is called prior to locking tables */ + virtual void do_prelock(TABLE **tables, uint count) + { + /* Default is to do nothing */ + } +}; typedef struct st_savepoint SAVEPOINT; extern ulong savepoint_alloc_size; diff --git a/sql/log.cc b/sql/log.cc index 7232d3a24dd..5ec3746ec1f 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -125,6 +125,12 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, Log_event *end_ev) if (end_ev) { + /* + We can always end the statement when ending a transaction since + transactions are not allowed inside stored functions. If they + were, we would have to ensure that we're not ending a statement + inside a stored function. + */ thd->binlog_flush_pending_rows_event(true); error= mysql_bin_log.write(thd, trans_log, end_ev); } @@ -144,7 +150,7 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, Log_event *end_ev) generated instead of the one that was written to the thrown-away transaction cache. */ - ++mysql_bin_log.m_table_map_version; + mysql_bin_log.update_table_map_version(); statistic_increment(binlog_cache_use, &LOCK_status); if (trans_log->disk_writes != 0) @@ -1678,6 +1684,38 @@ int THD::binlog_setup_trx_data() DBUG_RETURN(0); } +int THD::binlog_write_table_map(TABLE *table, bool is_trans) +{ + DBUG_ENTER("THD::binlog_write_table_map"); + DBUG_PRINT("enter", ("table=%p (%s: #%u)", + table, table->s->table_name, table->s->table_map_id)); + + /* Pre-conditions */ + DBUG_ASSERT(binlog_row_based && mysql_bin_log.is_open()); + DBUG_ASSERT(table->s->table_map_id != ULONG_MAX); + + Table_map_log_event::flag_set const + flags= Table_map_log_event::TM_NO_FLAGS; + + Table_map_log_event + the_event(this, table, table->s->table_map_id, is_trans, flags); + + /* + This function is called from ha_external_lock() after the storage + engine has registered for the transaction. + */ + if (is_trans) + trans_register_ha(this, options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), + &binlog_hton); + + if (int error= mysql_bin_log.write(&the_event)) + DBUG_RETURN(error); + + ++binlog_table_maps; + table->s->table_map_version= mysql_bin_log.table_map_version(); + DBUG_RETURN(0); +} + Rows_log_event* THD::binlog_get_pending_rows_event() const { @@ -1695,8 +1733,12 @@ THD::binlog_get_pending_rows_event() const void THD::binlog_set_pending_rows_event(Rows_log_event* ev) { + if (ha_data[binlog_hton.slot] == NULL) + binlog_setup_trx_data(); + binlog_trx_data *const trx_data= (binlog_trx_data*) ha_data[binlog_hton.slot]; + DBUG_ASSERT(trx_data); trx_data->pending= ev; } @@ -1739,15 +1781,6 @@ int MYSQL_LOG::flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event) */ pthread_mutex_lock(&LOCK_log); - /* - Write a table map if necessary - */ - if (pending->maybe_write_table_map(thd, file, this)) - { - pthread_mutex_unlock(&LOCK_log); - DBUG_RETURN(2); - } - /* Write pending event to log file or transaction cache */ @@ -1789,18 +1822,8 @@ int MYSQL_LOG::flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event) pthread_mutex_unlock(&LOCK_log); } - else if (event && event->get_cache_stmt()) /* && pending == 0 */ - { - /* - If we are setting a non-null event for a table that is - transactional, we start a transaction here as well. - */ - trans_register_ha(thd, - thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), - &binlog_hton); - } - trx_data->pending= event; + thd->binlog_set_pending_rows_event(event); DBUG_RETURN(error); } @@ -1832,21 +1855,13 @@ bool MYSQL_LOG::write(Log_event *event_info) mutex, we do this before aquiring the LOCK_log mutex in this function. - This is not optimal, but necessary in the current implementation - since there is code that writes rows to system tables without - using some way to flush the pending event (e.g., binlog_query()). - - TODO: There shall be no writes to any system table after calling - binlog_query(), so these writes has to be moved to before the call - of binlog_query() for correct functioning. - - This is necessesary not only for RBR, but the master might crash - after binlogging the query but before changing the system tables. - This means that the slave and the master are not in the same state - (after the master has restarted), so therefore we have to - eliminate this problem. + We only end the statement if we are in a top-level statement. If + we are inside a stored function, we do not end the statement since + this will close all tables on the slave. */ - thd->binlog_flush_pending_rows_event(true); + bool const end_stmt= + thd->prelocked_mode && thd->lex->requires_prelocking(); + thd->binlog_flush_pending_rows_event(end_stmt); pthread_mutex_lock(&LOCK_log); @@ -1869,8 +1884,9 @@ bool MYSQL_LOG::write(Log_event *event_info) (!binlog_filter->db_ok(local_db))) { VOID(pthread_mutex_unlock(&LOCK_log)); - DBUG_PRINT("info",("db_ok('%s')==%d", local_db, - binlog_filter->db_ok(local_db))); + DBUG_PRINT("info",("OPTION_BIN_LOG is %s, db_ok('%s') == %d", + (thd->options & OPTION_BIN_LOG) ? "set" : "clear", + local_db, binlog_filter->db_ok(local_db))); DBUG_RETURN(0); } #endif /* HAVE_REPLICATION */ @@ -2544,44 +2560,6 @@ void MYSQL_LOG::signal_update() DBUG_VOID_RETURN; } -#ifndef MYSQL_CLIENT -bool MYSQL_LOG::write_table_map(THD *thd, IO_CACHE *file, TABLE* table, - bool is_transactional) -{ - DBUG_ENTER("MYSQL_LOG::write_table_map()"); - DBUG_PRINT("enter", ("table=%p (%s: %u)", - table, table->s->table_name, table->s->table_map_id)); - - /* Pre-conditions */ - DBUG_ASSERT(binlog_row_based && is_open()); - DBUG_ASSERT(table->s->table_map_id != ULONG_MAX); - -#ifndef DBUG_OFF - /* - We only need to execute under the LOCK_log mutex if we are writing - to the log file; otherwise, we are writing to a thread-specific - transaction cache and there is no need to serialize this event - with events in other threads. - */ - if (file == &log_file) - safe_mutex_assert_owner(&LOCK_log); -#endif - - Table_map_log_event::flag_set const - flags= Table_map_log_event::TM_NO_FLAGS; - - Table_map_log_event - the_event(thd, table, table->s->table_map_id, is_transactional, flags); - - if (the_event.write(file)) - DBUG_RETURN(1); - - table->s->table_map_version= m_table_map_version; - DBUG_RETURN(0); -} -#endif /* !defined(MYSQL_CLIENT) */ - - #ifdef __NT__ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, uint length, int buffLen) diff --git a/sql/log.h b/sql/log.h index ea2946c2d86..95687b4eb8c 100644 --- a/sql/log.h +++ b/sql/log.h @@ -192,9 +192,11 @@ class MYSQL_LOG: public TC_LOG bool no_auto_events; friend class Log_event; -public: ulonglong m_table_map_version; + int write_to_file(IO_CACHE *cache); + +public: /* These describe the log's format. This is used only for relay logs. _for_exec is used by the SQL thread, _for_queue by the I/O thread. It's @@ -221,9 +223,12 @@ public: #if !defined(MYSQL_CLIENT) bool is_table_mapped(TABLE *table) const { - return table->s->table_map_version == m_table_map_version; + return table->s->table_map_version == table_map_version(); } + ulonglong table_map_version() const { return m_table_map_version; } + void update_table_map_version() { ++m_table_map_version; } + int flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event); #endif /* !defined(MYSQL_CLIENT) */ @@ -283,8 +288,6 @@ public: bool write(Log_event* event_info); // binary log write bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event); - bool write_table_map(THD *thd, IO_CACHE *cache, TABLE *table, bool is_trans); - void start_union_events(THD *thd); void stop_union_events(THD *thd); bool is_query_in_union(THD *thd, query_id_t query_id_param); diff --git a/sql/log_event.cc b/sql/log_event.cc index 04a6276d476..2ad4db41635 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1681,6 +1681,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli, const char *query DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos)); clear_all_errors(thd, rli); + rli->clear_tables_to_lock(); /* Note: We do not need to execute reset_one_shot_variables() if this @@ -5054,17 +5055,19 @@ char* sql_ex_info::init(char* buf,char* buf_end,bool use_new_format) Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid, MY_BITMAP const *cols, bool is_transactional) : Log_event(thd_arg, 0, is_transactional), + m_row_count(0), m_table(tbl_arg), m_table_id(tid), - m_width(tbl_arg->s->fields), - m_rows_buf((byte*)my_malloc(opt_binlog_rows_event_max_size * - sizeof(*m_rows_buf), MYF(MY_WME))), - m_rows_cur(m_rows_buf), - m_rows_end(m_rows_buf + opt_binlog_rows_event_max_size), + m_width(tbl_arg ? tbl_arg->s->fields : 1), + m_rows_buf(0), m_rows_cur(0), m_rows_end(0), m_flags(0) { - DBUG_ASSERT(m_table && m_table->s); - DBUG_ASSERT(m_table_id != ULONG_MAX); + /* + We allow a special form of dummy event when the table, and cols + are null and the table id is ULONG_MAX. + */ + DBUG_ASSERT(tbl_arg && tbl_arg->s && tid != ULONG_MAX || + !tbl_arg && !cols && tid == ULONG_MAX); if (thd_arg->options & OPTION_NO_FOREIGN_KEY_CHECKS) set_flags(NO_FOREIGN_KEY_CHECKS_F); @@ -5075,7 +5078,11 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid, m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, (m_width + 7) & ~7UL, false))) - memcpy(m_cols.bitmap, cols->bitmap, no_bytes_in_map(cols)); + { + /* Cols can be zero if this is a dummy binrows event */ + if (likely(cols != NULL)) + memcpy(m_cols.bitmap, cols->bitmap, no_bytes_in_map(cols)); + } else m_cols.bitmap= 0; // to not free it } @@ -5086,6 +5093,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, const Format_description_log_event *description_event) : Log_event(buf, description_event), + m_row_count(0), m_rows_buf(0), m_rows_cur(0), m_rows_end(0) { DBUG_ENTER("Rows_log_event::Rows_log_event(const char*,...)"); @@ -5111,8 +5119,6 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, post_start+= RW_FLAGS_OFFSET; } - DBUG_ASSERT(m_table_id != ULONG_MAX); - m_flags= uint2korr(post_start); byte const *const var_start= (const byte *)buf + common_header_len + @@ -5168,7 +5174,7 @@ int Rows_log_event::do_add_row_data(byte *const row_data, DBUG_DUMP("row_data", (const char*)row_data, min(length, 32)); DBUG_ASSERT(m_rows_buf <= m_rows_cur); - DBUG_ASSERT(m_rows_buf < m_rows_end); + DBUG_ASSERT(!m_rows_buf || m_rows_end && m_rows_buf < m_rows_end); DBUG_ASSERT(m_rows_cur <= m_rows_end); /* The cast will always work since m_rows_cur <= m_rows_end */ @@ -5176,12 +5182,12 @@ int Rows_log_event::do_add_row_data(byte *const row_data, { my_size_t const block_size= 1024; my_ptrdiff_t const old_alloc= m_rows_end - m_rows_buf; - my_ptrdiff_t const new_alloc= - old_alloc + block_size * (length / block_size + block_size - 1); my_ptrdiff_t const cur_size= m_rows_cur - m_rows_buf; + my_ptrdiff_t const new_alloc= + block_size * ((cur_size + length) / block_size + block_size - 1); - byte* const new_buf= - (byte*)my_realloc((gptr)m_rows_buf, new_alloc, MYF(MY_WME)); + byte* const new_buf= (byte*)my_realloc((gptr)m_rows_buf, new_alloc, + MYF(MY_ALLOW_ZERO_PTR|MY_WME)); if (unlikely(!new_buf)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -5202,6 +5208,7 @@ int Rows_log_event::do_add_row_data(byte *const row_data, DBUG_ASSERT(m_rows_cur + length < m_rows_end); memcpy(m_rows_cur, row_data, length); m_rows_cur+= length; + m_row_count++; DBUG_RETURN(0); } #endif @@ -5245,10 +5252,28 @@ static char const *unpack_row(TABLE *table, int Rows_log_event::exec_event(st_relay_log_info *rli) { DBUG_ENTER("Rows_log_event::exec_event(st_relay_log_info*)"); - DBUG_ASSERT(m_table_id != ULONG_MAX); int error= 0; char const *row_start= (char const *)m_rows_buf; - TABLE* table= rli->m_table_map.get_table(m_table_id); + + /* + If m_table_id == ULONG_MAX, then we have a dummy event that does + not contain any data. In that case, we just remove all tables in + the tables_to_lock list, step the relay log position, and return + with success. + */ + if (m_table_id == ULONG_MAX) + { + /* + This one is supposed to be set: just an extra check so that + nothing strange has happened. + */ + DBUG_ASSERT(get_flags(STMT_END_F)); + + rli->clear_tables_to_lock(); + thd->clear_error(); + rli->inc_event_relay_log_pos(); + DBUG_RETURN(0); + } /* 'thd' has been set by exec_relay_log_event(), just before calling @@ -5257,85 +5282,51 @@ int Rows_log_event::exec_event(st_relay_log_info *rli) DBUG_ASSERT(rli->sql_thd == thd); /* - lock_tables() reads the contents of thd->lex, so they must be - initialized, so we should call lex_start(); to be even safer, we call - mysql_init_query() which does a more complete set of inits. + If there is no locks taken, this is the first binrow event seen + after the table map events. We should then lock all the tables + used in the transaction and proceed with execution of the actual + event. */ - mysql_init_query(thd, NULL, 0); - - if (table) + if (!thd->lock) { + bool need_reopen= 1; /* To execute the first lap of the loop below */ + /* - table == NULL means that this table should not be - replicated (this was set up by Table_map_log_event::exec_event() which - tested replicate-* rules). + lock_tables() reads the contents of thd->lex, so they must be + initialized, so we should call lex_start(); to be even safer, we + call mysql_init_query() which does a more complete set of inits. */ - TABLE_LIST table_list; - bool need_reopen; - uint count= 1; - bzero(&table_list, sizeof(table_list)); - table_list.lock_type= TL_WRITE; - table_list.next_global= table_list.next_local= 0; - table_list.table= table; + mysql_init_query(thd, NULL, 0); - for ( ; ; ) + while ((error= lock_tables(thd, rli->tables_to_lock, + rli->tables_to_lock_count, &need_reopen))) { - table_list.db= const_cast(table->s->db.str); - table_list.alias= table_list.table_name= - const_cast(table->s->table_name.str); - - if ((error= lock_tables(thd, &table_list, count, &need_reopen)) == 0) - break; if (!need_reopen) { slave_print_msg(ERROR_LEVEL, rli, error, - "Error in %s event: error during table %s.%s lock", - get_type_str(), table->s->db.str, - table->s->table_name.str); + "Error in %s event: when locking tables", + get_type_str()); DBUG_RETURN(error); } - /* - we need to store a local copy of the table names since the table object - will become invalid after close_tables_for_reopen - */ - char *db= my_strdup(table->s->db.str, MYF(MY_WME)); - char *table_name= my_strdup(table->s->table_name.str, MYF(MY_WME)); - - if (db == 0 || table_name == 0) - { - /* - Since the lock_tables() failed, the table is not locked, so - we don't need to unlock them. - */ - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } /* - We also needs to flush the pending RBR event, since it keeps a - pointer to an open table. + So we need to reopen the tables. - ALTERNATIVE SOLUTION: Extract a pointer to the pending RBR - event and reset the table pointer after the tables has been - reopened. + We need to flush the pending RBR event, since it keeps a + pointer to an open table. + + ALTERNATIVE SOLUTION (not implemented): Extract a pointer to + the pending RBR event and reset the table pointer after the + tables has been reopened. + + NOTE: For this new scheme there should be no pending event: + need to add code to assert that is the case. */ thd->binlog_flush_pending_rows_event(false); + close_tables_for_reopen(thd, rli->tables_to_lock); - close_tables_for_reopen(thd, &table_list); - - /* open the table again, same as in Table_map_event::exec_event */ - table_list.db= const_cast(db); - table_list.alias= table_list.table_name= const_cast(table_name); - table_list.updating= 1; - TABLE_LIST *tables= &table_list; - if ((error= open_tables(thd, &tables, &count, 0)) == 0) - { - /* reset some variables for the table list*/ - table_list.updating= 0; - /* retrieve the new table reference and update the table map */ - table= table_list.table; - error= rli->m_table_map.set_table(m_table_id, table); - } - else /* error in open_tables */ + if ((error= open_tables(thd, &rli->tables_to_lock, + &rli->tables_to_lock_count, 0))) { if (thd->query_error || thd->is_fatal_error) { @@ -5345,19 +5336,41 @@ int Rows_log_event::exec_event(st_relay_log_info *rli) */ uint actual_error= thd->net.last_errno; slave_print_msg(ERROR_LEVEL, rli, actual_error, - "Error '%s' on reopening table `%s`.`%s`", + "Error '%s' on reopening tables", (actual_error ? thd->net.last_error : - "unexpected success or fatal error"), - db, table_name); + "unexpected success or fatal error")); thd->query_error= 1; } - } - my_free((char*) db, MYF(MY_ALLOW_ZERO_PTR)); - my_free((char*) table_name, MYF(MY_ALLOW_ZERO_PTR)); - - if (error) DBUG_RETURN(error); + } } + /* + When the open and locking succeeded, we add all the tables to + the table map and remove them from tables to lock. + */ + + TABLE_LIST *ptr= rli->tables_to_lock; + while (ptr) + { + rli->m_table_map.set_table(ptr->table_id, ptr->table); + rli->touching_table(ptr->db, ptr->table_name, ptr->table_id); + char *to_free= reinterpret_cast(ptr); + ptr= ptr->next_global; + my_free(to_free, MYF(MY_WME)); + } + rli->tables_to_lock= 0; + rli->tables_to_lock_count= 0; + } + + TABLE* table= rli->m_table_map.get_table(m_table_id); + + if (table) + { + /* + table == NULL means that this table should not be replicated + (this was set up by Table_map_log_event::exec_event() which + tested replicate-* rules). + */ /* It's not needed to set_time() but @@ -5510,52 +5523,25 @@ int Rows_log_event::exec_event(st_relay_log_info *rli) DBUG_RETURN(error); } - if (table) + if (table && (table->s->primary_key == MAX_KEY) && !cache_stmt) { /* - As "table" is not NULL, we did a successful lock_tables(), without any - prior LOCK TABLES and are not in prelocked mode, so this assertion should - be true. + ------------ Temporary fix until WL#2975 is implemented --------- + + This event is not the last one (no STMT_END_F). If we stop now + (in case of terminate_slave_thread()), how will we restart? We + have to restart from Table_map_log_event, but as this table is + not transactional, the rows already inserted will still be + present, and idempotency is not guaranteed (no PK) so we risk + that repeating leads to double insert. So we desperately try to + continue, hope we'll eventually leave this buggy situation (by + executing the final Rows_log_event). If we are in a hopeless + wait (reached end of last relay log and nothing gets appended + there), we timeout after one minute, and notify DBA about the + problem. When WL#2975 is implemented, just remove the member + st_relay_log_info::unsafe_to_stop_at and all its occurences. */ - DBUG_ASSERT(thd->lock); - /* - If we are here, there are more events to come which may use our mappings - and our table. So don't clear mappings or close tables, just unlock - tables. - Why don't we lock the table once for all in - Table_map_log_event::exec_event() ? Because we could have in binlog: - BEGIN; - Table_map t1 -> 1 - Write_rows to id 1 - Table_map t2 -> 2 - Write_rows to id 2 - Xid_log_event - So we cannot lock t1 when executing the first Table_map, because at that - moment we don't know we'll also have to lock t2, and all tables must be - locked at once in MySQL. - */ - mysql_unlock_tables(thd, thd->lock); - thd->lock= 0; - if ((table->s->primary_key == MAX_KEY) && - !cache_stmt) - { - /* - ------------ Temporary fix until WL#2975 is implemented --------- - This event is not the last one (no STMT_END_F). If we stop now (in - case of terminate_slave_thread()), how will we restart? We have to - restart from Table_map_log_event, but as this table is not - transactional, the rows already inserted will still be present, and - idempotency is not guaranteed (no PK) so we risk that repeating leads - to double insert. So we desperately try to continue, hope we'll - eventually leave this buggy situation (by executing the final - Rows_log_event). If we are in a hopeless wait (reached end of last - relay log and nothing gets appended there), we timeout after one - minute, and notify DBA about the problem. - When WL#2975 is implemented, just remove the member - st_relay_log_info::unsafe_to_stop_at and all its occurences. - */ - rli->unsafe_to_stop_at= time(0); - } + rli->unsafe_to_stop_at= time(0); } DBUG_ASSERT(error == 0); @@ -5569,7 +5555,6 @@ int Rows_log_event::exec_event(st_relay_log_info *rli) #ifndef MYSQL_CLIENT bool Rows_log_event::write_data_header(IO_CACHE *file) { - DBUG_ASSERT(m_table_id != ULONG_MAX); byte buf[ROWS_HEADER_LEN]; // No need to init the buffer DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", { @@ -5601,16 +5586,17 @@ bool Rows_log_event::write_data_body(IO_CACHE*file) } #endif -#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) && defined(DBUG_RBR) +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Rows_log_event::pack_info(Protocol *protocol) { - char buf[256]; - char const *const flagstr= get_flags(STMT_END_F) ? "STMT_END_F" : ""; - char const *const dbnam= m_table->s->db.str; - char const *const tblnam= m_table->s->table_name.str; - my_size_t bytes= snprintf(buf, sizeof(buf), - "%s.%s - %s", dbnam, tblnam, flagstr); - protocol->store(buf, bytes, &my_charset_bin); +#ifdef DBUG_RBR + char buf[256]; + char const *const flagstr= + get_flags(STMT_END_F) ? " flags: STMT_END_F" : ""; + my_size_t bytes= snprintf(buf, sizeof(buf), + "table_id: %lu%s", m_table_id, flagstr); + protocol->store(buf, bytes, &my_charset_bin); +#endif } #endif @@ -5752,59 +5738,6 @@ Table_map_log_event::~Table_map_log_event() my_free(m_memory, MYF(MY_ALLOW_ZERO_PTR)); } -/* - Find a table based on database name and table name. - - DESCRIPTION - - Currently, only the first table of the 'table_list' is located. If the - table is found in the list of open tables for the thread, the 'table' - field of 'table_list' is filled in. - - PARAMETERS - - thd Thread structure - table_list List of tables to locate in the thd->open_tables list. - count Pointer to a variable that will be set to the number of - tables found. If the pointer is NULL, nothing will be stored. - - RETURN VALUE - - The number of tables found. - - TO DO - - Replace the list of table searches with a hash based on the combined - database and table name. The handler_tables_hash is inappropriate since - it hashes on the table alias. At the same time, the function can be - extended to handle a full list of table names, in the same spirit as - open_tables() and lock_tables(). -*/ -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) -static uint find_tables(THD *thd, TABLE_LIST *table_list, uint *count) -{ - uint result= 0; - - /* we verify that the caller knows our limitation */ - DBUG_ASSERT(table_list->next_global == 0); - for (TABLE *table= thd->open_tables; table ; table= table->next) - { - if (strcmp(table->s->db.str, table_list->db) == 0 - && strcmp(table->s->table_name.str, table_list->table_name) == 0) - { - /* Copy the table pointer into the table list. */ - table_list->table= table; - result= 1; - break; - } - } - - if (count) - *count= result; - return result; -} -#endif - /* Return value is an error code, one of: @@ -5828,20 +5761,37 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli) thd->query_id= next_query_id(); pthread_mutex_unlock(&LOCK_thread_count); - TABLE_LIST table_list; + TABLE_LIST *table_list; + char *db_mem, *tname_mem; + void *const memory= + my_multi_malloc(MYF(MY_WME), + &table_list, sizeof(TABLE_LIST), + &db_mem, NAME_LEN + 1, + &tname_mem, NAME_LEN + 1, + NULL); + + /* + If memory is allocated, it the pointer to it should be stored in + table_list. If this is not true, the memory will not be correctly + free:ed later. + */ + DBUG_ASSERT(memory == NULL || memory == table_list); + uint32 dummy_len; - bzero(&table_list, sizeof(table_list)); - table_list.db= const_cast - (rpl_filter->get_rewrite_db(m_dbnam, &dummy_len)); - table_list.alias= table_list.table_name= const_cast(m_tblnam); - table_list.lock_type= TL_WRITE; - table_list.next_global= table_list.next_local= 0; - table_list.updating= 1; + bzero(table_list, sizeof(*table_list)); + table_list->db = db_mem; + table_list->alias= table_list->table_name = tname_mem; + table_list->lock_type= TL_WRITE; + table_list->next_global= table_list->next_local= 0; + table_list->table_id= m_table_id; + table_list->updating= 1; + strmov(table_list->db, rpl_filter->get_rewrite_db(m_dbnam, &dummy_len)); + strmov(table_list->table_name, m_tblnam); int error= 0; - if (rpl_filter->db_ok(table_list.db) && - (!rpl_filter->is_on() || rpl_filter->tables_ok("", &table_list))) + if (rpl_filter->db_ok(table_list->db) && + (!rpl_filter->is_on() || rpl_filter->tables_ok("", table_list))) { /* Check if the slave is set to use SBR. If so, the slave should @@ -5867,36 +5817,32 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli) be a no-op. */ uint count; - if (find_tables(thd, &table_list, &count) == 0) + /* + open_tables() reads the contents of thd->lex, so they must be + initialized, so we should call lex_start(); to be even safer, we + call mysql_init_query() which does a more complete set of inits. + */ + mysql_init_query(thd, NULL, 0); + if ((error= open_tables(thd, &table_list, &count, 0))) { - /* - open_tables() reads the contents of thd->lex, so they must be - initialized, so we should call lex_start(); to be even safer, we call - mysql_init_query() which does a more complete set of inits. - */ - mysql_init_query(thd, NULL, 0); - TABLE_LIST *tables= &table_list; - if ((error= open_tables(thd, &tables, &count, 0))) + if (thd->query_error || thd->is_fatal_error) { - if (thd->query_error || thd->is_fatal_error) - { - /* - Error reporting borrowed from Query_log_event with many excessive - simplifications (we don't honour --slave-skip-errors) - */ - uint actual_error= thd->net.last_errno; - slave_print_msg(ERROR_LEVEL, rli, actual_error, - "Error '%s' on opening table `%s`.`%s`", - (actual_error ? thd->net.last_error : - "unexpected success or fatal error"), - table_list.db, table_list.table_name); - thd->query_error= 1; - } - DBUG_RETURN(error); + /* + Error reporting borrowed from Query_log_event with many excessive + simplifications (we don't honour --slave-skip-errors) + */ + uint actual_error= thd->net.last_errno; + slave_print_msg(ERROR_LEVEL, rli, actual_error, + "Error '%s' on opening table `%s`.`%s`", + (actual_error ? thd->net.last_error : + "unexpected success or fatal error"), + table_list->db, table_list->table_name); + thd->query_error= 1; } + DBUG_RETURN(error); } - m_table= table_list.table; + m_table= table_list->table; /* This will fail later otherwise, the 'in_use' field should be @@ -5974,19 +5920,16 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli) } /* - We record in the slave's information that the number m_table_id is - mapped to the m_table object + We record in the slave's information that the table should be + locked by linking the table into the list of tables to lock, and + tell the RLI that we are touching a table. */ if (!error) - error= rli->m_table_map.set_table(m_table_id, m_table); - - /* - Tell the RLI that we are touching a table. - - TODO: Maybe we can combine this with the previous operation? - */ - if (!error) - rli->touching_table(m_dbnam, m_tblnam, m_table_id); + { + table_list->next_global= table_list->next_local= rli->tables_to_lock; + rli->tables_to_lock= table_list; + rli->tables_to_lock_count++; + } } /* @@ -6053,12 +5996,23 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file) field. */ +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Table_map_log_event::pack_info(Protocol *protocol) { +#ifdef DBUG_RBR + char buf[256]; + my_size_t bytes= snprintf(buf, sizeof(buf), + "table_id: %lu (%s.%s)", + m_table_id, m_dbnam, m_tblnam); + protocol->store(buf, bytes, &my_charset_bin); +#else char buf[256]; my_size_t bytes= snprintf(buf, sizeof(buf), "%s.%s", m_dbnam, m_tblnam); protocol->store(buf, bytes, &my_charset_bin); +#endif } +#endif + #endif diff --git a/sql/log_event.h b/sql/log_event.h index 8b665755aab..d514c2cd8aa 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -657,11 +657,16 @@ public: { return (void*) my_malloc((uint)size, MYF(MY_WME|MY_FAE)); } + static void operator delete(void *ptr, size_t size) { my_free((gptr) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); } + /* Placement version of the above operators */ + static void *operator new(size_t, void* ptr) { return ptr; } + static void operator delete(void*, void*) { } + #ifndef MYSQL_CLIENT bool write_header(IO_CACHE* file, ulong data_length); virtual bool write(IO_CACHE* file) @@ -1795,10 +1800,8 @@ public: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) virtual int exec_event(struct st_relay_log_info *rli); -#ifdef DBUG_RBR virtual void pack_info(Protocol *protocol); #endif -#endif #ifdef MYSQL_CLIENT /* not for direct call, each derived has its own ::print() */ @@ -1850,6 +1853,7 @@ public: Error code, or zero if write succeeded. */ #if !defined(MYSQL_CLIENT) && defined(HAVE_ROW_BASED_REPLICATION) +#if 0 int maybe_write_table_map(THD *thd, IO_CACHE *file, MYSQL_LOG *log) const { /* @@ -1864,6 +1868,9 @@ public: return result; } #endif +#endif + + uint m_row_count; /* The number of rows added to the event */ protected: /* diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 026234caf34..4269bb5beea 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -742,7 +742,8 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, List *extra_fields, List *keys, List *items, - MYSQL_LOCK **lock); + MYSQL_LOCK **lock, + TABLEOP_HOOKS *hooks); bool mysql_alter_table(THD *thd, char *new_db, char *new_name, HA_CREATE_INFO *create_info, TABLE_LIST *table_list, diff --git a/sql/parse_file.cc b/sql/parse_file.cc index 3cddc879825..2a602e9ba28 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -224,7 +224,8 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, File_option *param; DBUG_ENTER("sql_create_definition_file"); DBUG_PRINT("enter", ("Dir: %s, file: %s, base 0x%lx", - dir->str, file_name->str, (ulong) base)); + dir ? dir->str : "(null)", + file_name->str, (ulong) base)); if (dir) { diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 5500fdf1f64..cacae1aa4c2 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -276,7 +276,9 @@ typedef struct st_relay_log_info group_relay_log_pos); } - table_mapping m_table_map; + TABLE_LIST *tables_to_lock; /* RBR: Tables to lock */ + uint tables_to_lock_count; /* RBR: Count of tables to lock */ + table_mapping m_table_map; /* RBR: Mapping table-id to table */ /* Last charset (6 bytes) seen by slave SQL thread is cached here; it helps @@ -306,6 +308,18 @@ typedef struct st_relay_log_info void transaction_end(THD*); void cleanup_context(THD *, bool); + void clear_tables_to_lock() { + TABLE_LIST *ptr= tables_to_lock; + while (ptr) + { + char *to_free= reinterpret_cast(ptr); + ptr= ptr->next_global; + my_free(to_free, MYF(MY_WME)); + } + tables_to_lock= 0; + tables_to_lock_count= 0; + } + time_t unsafe_to_stop_at; } RELAY_LOG_INFO; diff --git a/sql/slave.cc b/sql/slave.cc index 41a13f2f5c5..6076a0a153b 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1444,6 +1444,8 @@ static int init_relay_log_info(RELAY_LOG_INFO* rli, rli->abort_pos_wait=0; rli->log_space_limit= relay_log_space_limit; rli->log_space_total= 0; + rli->tables_to_lock= 0; + rli->tables_to_lock_count= 0; /* The relay log will now be opened, as a SEQ_READ_APPEND IO_CACHE. @@ -2301,6 +2303,7 @@ st_relay_log_info::st_relay_log_info() abort_pos_wait(0), slave_run_id(0), sql_thd(0), last_slave_errno(0), inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE), until_log_pos(0), retried_trans(0), m_reload_flags(RELOAD_NONE_F), + tables_to_lock(0), tables_to_lock_count(0), unsafe_to_stop_at(0) { group_relay_log_name[0]= event_relay_log_name[0]= @@ -4950,6 +4953,7 @@ void st_relay_log_info::cleanup_context(THD *thd, bool error) } m_table_map.clear_tables(); close_thread_tables(thd); + clear_tables_to_lock(); unsafe_to_stop_at= 0; } #endif diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1419cd7fc6e..30422ea47c3 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3144,16 +3144,6 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, } grant_option=TRUE; thd->mem_root= old_root; - /* - This flush is here only becuase there is code that writes rows to - system tables after executing a binlog_query(). - - TODO: Ensure that no writes are executed after a binlog_query() by - moving the writes to before calling binlog_query(). Then remove - this line (and add an assert inside send_ok() that checks that - everything is in a consistent state). - */ - thd->binlog_flush_pending_rows_event(true); rw_unlock(&LOCK_grant); if (!result && !no_error) send_ok(thd); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 85c5a481d47..23ed7a53a64 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1031,21 +1031,18 @@ void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived) /* Fallthrough */ } - /* - For RBR: before calling close_thread_tables(), storage engines - should autocommit. Hence if there is a a pending event, it belongs - to a non-transactional engine, which writes directly to the table, - and should therefore be flushed before unlocking and closing the - tables. The test above for locked tables will not be triggered - since RBR locks and unlocks tables on a per-event basis. - - TODO (WL#3023): Change the semantics so that RBR does not lock and - unlock tables on a per-event basis. - */ - thd->binlog_flush_pending_rows_event(true); - if (thd->lock) { + /* + For RBR we flush the pending event just before we unlock all the + tables. This means that we are at the end of a topmost + statement, so we ensure that the STMT_END_F flag is set on the + pending event. For statements that are *inside* stored + functions, the pending event will not be flushed: that will be + handled either before writing a query log event (inside + binlog_query()) or when preparing a pending event. + */ + thd->binlog_flush_pending_rows_event(true); mysql_unlock_tables(thd, thd->lock); thd->lock=0; } @@ -1057,7 +1054,8 @@ void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived) saves some work in 2pc too) see also sql_parse.cc - dispatch_command() */ - bzero(&thd->transaction.stmt, sizeof(thd->transaction.stmt)); + if (!(thd->state_flags & Open_tables_state::BACKUPS_AVAIL)) + bzero(&thd->transaction.stmt, sizeof(thd->transaction.stmt)); if (!thd->active_transaction()) thd->transaction.xid_state.xid.null(); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2f392f46627..f71c8d4ca78 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -162,7 +162,7 @@ bool foreign_key_prefix(Key *a, Key *b) ****************************************************************************/ Open_tables_state::Open_tables_state(ulong version_arg) - :version(version_arg) + :version(version_arg), state_flags(0U) { reset_open_tables_state(); } @@ -178,7 +178,8 @@ THD::THD() :Statement(CONVENTIONAL_EXECUTION, 0, ALLOC_ROOT_MIN_BLOCK_SIZE, 0), Open_tables_state(refresh_version), rli_fake(0), lock_id(&main_lock_id), - user_time(0), in_sub_stmt(0), global_read_lock(0), is_fatal_error(0), + user_time(0), in_sub_stmt(0), binlog_table_maps(0), + global_read_lock(0), is_fatal_error(0), rand_used(0), time_zone_used(0), last_insert_id_used(0), insert_id_used(0), clear_next_insert_id(0), in_lock_tables(0), bootstrap(0), derived_tables_processing(FALSE), @@ -1910,6 +1911,7 @@ void THD::reset_n_backup_open_tables_state(Open_tables_state *backup) DBUG_ENTER("reset_n_backup_open_tables_state"); backup->set_open_tables_state(this); reset_open_tables_state(); + state_flags|= Open_tables_state::BACKUPS_AVAIL; DBUG_VOID_RETURN; } @@ -1976,25 +1978,6 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup, backup->client_capabilities= client_capabilities; backup->savepoints= transaction.savepoints; -#ifdef HAVE_ROW_BASED_REPLICATION - /* - For row-based replication and before executing a function/trigger, - the pending rows event has to be flushed. The function/trigger - might execute statement that require the pending event to be - flushed. A simple example: - - CREATE FUNCTION foo() RETURNS INT - BEGIN - SAVEPOINT x; - RETURN 0; - END - - INSERT INTO t1 VALUES (1), (foo()), (2); - */ - if (binlog_row_based) - binlog_flush_pending_rows_event(false); -#endif /* HAVE_ROW_BASED_REPLICATION */ - if ((!lex->requires_prelocking() || is_update_query(lex->sql_command)) && !binlog_row_based) options&= ~OPTION_BIN_LOG; @@ -2176,6 +2159,7 @@ THD::binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id, bool is_transactional, RowsEventT *hint __attribute__((unused))) { + DBUG_ENTER("binlog_prepare_pending_rows_event"); /* Pre-conditions */ DBUG_ASSERT(table->s->table_map_id != ULONG_MAX); @@ -2187,12 +2171,12 @@ THD::binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id, have to do it here. */ if (binlog_setup_trx_data()) - return NULL; + DBUG_RETURN(NULL); Rows_log_event* pending= binlog_get_pending_rows_event(); if (unlikely(pending && !pending->is_valid())) - return NULL; + DBUG_RETURN(NULL); /* Check if the current event is non-NULL and a write-rows @@ -2217,7 +2201,7 @@ THD::binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id, ev= new RowsEventT(this, table, table->s->table_map_id, cols, is_transactional); if (unlikely(!ev)) - return NULL; + DBUG_RETURN(NULL); ev->server_id= serv_id; // I don't like this, it's too easy to forget. /* flush the pending event and replace it with the newly created @@ -2226,16 +2210,16 @@ THD::binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id, if (unlikely(mysql_bin_log.flush_and_set_pending_rows_event(this, ev))) { delete ev; - return NULL; + DBUG_RETURN(NULL); } - return ev; /* This is the new pending event */ + DBUG_RETURN(ev); /* This is the new pending event */ } - return pending; /* This is the current pending event */ + DBUG_RETURN(pending); /* This is the current pending event */ } /* - Instansiate the versions we need, we have -fno-implicit-template as + Instantiate the versions we need, we have -fno-implicit-template as compiling option. */ template Rows_log_event* @@ -2499,15 +2483,34 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end) { pending->set_flags(Rows_log_event::STMT_END_F); pending->flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; + binlog_table_maps= 0; } - /* - We only bother to set the pending event if it is non-NULL. This - is essential for correctness, since there is not necessarily a - trx_data created for the thread if the pending event is NULL. - */ error= mysql_bin_log.flush_and_set_pending_rows_event(this, 0); } + else if (stmt_end && binlog_table_maps > 0) + { /* there is no pending event at this point */ + /* + If pending is null and we are going to end the statement, we + have to write an extra, empty, binrow event so that the slave + knows to discard the tables it has received. Otherwise, the + table maps written this far will be included in the table maps + for the following statement. + + See if we can replace this with a dummy, maybe constant, event. + */ +#if 0 + static unsigned char memory[sizeof(Write_rows_log_event)]; + void *const ptr= &memory; +#endif + Rows_log_event *ev= + new Write_rows_log_event(this, 0, ULONG_MAX, 0, FALSE); + ev->set_flags(Rows_log_event::STMT_END_F); + binlog_set_pending_rows_event(ev); + + error= mysql_bin_log.flush_and_set_pending_rows_event(this, 0); + binlog_table_maps= 0; + } DBUG_RETURN(error); } @@ -2533,6 +2536,17 @@ void THD::binlog_delete_pending_rows_event() functions have been issued, but before tables are unlocked and closed. + OBSERVE + There shall be no writes to any system table after calling + binlog_query(), so these writes has to be moved to before the call + of binlog_query() for correct functioning. + + This is necessesary not only for RBR, but the master might crash + after binlogging the query but before changing the system tables. + This means that the slave and the master are not in the same state + (after the master has restarted), so therefore we have to + eliminate this problem. + RETURN VALUE Error code, or 0 if no error. */ @@ -2542,7 +2556,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, { DBUG_ENTER("THD::binlog_query"); DBUG_ASSERT(query && mysql_bin_log.is_open()); - int error= binlog_flush_pending_rows_event(true); + switch (qtype) { case THD::MYSQL_QUERY_TYPE: @@ -2556,19 +2570,41 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, */ case THD::ROW_QUERY_TYPE: if (binlog_row_based) - DBUG_RETURN(binlog_flush_pending_rows_event(true)); + { + /* + If thd->lock is set, then we are not inside a stored function. + In that case, mysql_unlock_tables() will be called after this + binlog_query(), so we have to flush the pending rows event + with the STMT_END_F set to unlock all tables at the slave side + as well. + + We will not flush the pending event, if thd->lock is NULL. + This means that we are inside a stored function or trigger, so + the flushing will be done inside the top-most + close_thread_tables(). + */ + if (this->lock) + DBUG_RETURN(binlog_flush_pending_rows_event(TRUE)); + DBUG_RETURN(0); + } /* Otherwise, we fall through */ case THD::STMT_QUERY_TYPE: /* - Most callers of binlog_query() ignore the error code, assuming - that the statement will always be written to the binlog. In - case of error above, we therefore just continue and write the - statement to the binary log. + The MYSQL_LOG::write() function will set the STMT_END_F flag and + flush the pending rows event if necessary. */ { Query_log_event qinfo(this, query, query_len, is_trans, suppress_use); qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; - DBUG_RETURN(mysql_bin_log.write(&qinfo)); + /* + Binlog table maps will be irrelevant after a Query_log_event + (they are just removed on the slave side) so after the query + log event is written to the binary log, we pretend that no + table maps were written. + */ + int error= mysql_bin_log.write(&qinfo); + binlog_table_maps= 0; + DBUG_RETURN(error); } break; diff --git a/sql/sql_class.h b/sql/sql_class.h index cb8c2818a19..742d12f4376 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -735,11 +735,20 @@ public: ulong version; uint current_tablenr; + enum enum_flags { + BACKUPS_AVAIL = (1U << 0) /* There are backups available */ + }; + + /* + Flags with information about the open tables state. + */ + uint state_flags; + /* This constructor serves for creation of Open_tables_state instances which are used as backup storage. */ - Open_tables_state() {}; + Open_tables_state() : state_flags(0U) { } Open_tables_state(ulong version_arg); @@ -753,6 +762,7 @@ public: open_tables= temporary_tables= handler_tables= derived_tables= 0; lock= locked_tables= 0; prelocked_mode= NON_PRELOCKED; + state_flags= 0U; } }; @@ -900,8 +910,9 @@ public: #ifndef MYSQL_CLIENT /* - Public interface to write rows to the binlog + Public interface to write RBR events to the binlog */ + int binlog_write_table_map(TABLE *table, bool is_transactional); int binlog_write_row(TABLE* table, bool is_transactional, MY_BITMAP const* cols, my_size_t colcnt, const byte *buf); @@ -945,6 +956,11 @@ public: int binlog_flush_pending_rows_event(bool stmt_end); void binlog_delete_pending_rows_event(); +private: + uint binlog_table_maps; // Number of table maps currently in the binlog + +public: + #endif #endif /* HAVE_ROW_BASED_REPLICATION */ #ifndef MYSQL_CLIENT @@ -1543,7 +1559,6 @@ class select_create: public select_insert { HA_CREATE_INFO *create_info; MYSQL_LOCK *lock; Field **field; - bool create_table_written; public: select_create (TABLE_LIST *table, HA_CREATE_INFO *create_info_par, @@ -1552,11 +1567,11 @@ public: List &select_fields,enum_duplicates duplic, bool ignore) :select_insert (NULL, NULL, &select_fields, 0, 0, duplic, ignore), create_table(table), extra_fields(&fields_par),keys(&keys_par), create_info(create_info_par), - lock(0), create_table_written(FALSE) + lock(0) {} int prepare(List &list, SELECT_LEX_UNIT *u); - void binlog_show_create_table(); + void binlog_show_create_table(TABLE **tables, uint count); void store_values(List &values); void send_error(uint errcode,const char *err); bool send_eof(); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index a265d32e7c2..616d0f42741 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1711,7 +1711,7 @@ pthread_handler_t handle_delayed_insert(void *arg) { thd->fatal_error(); strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES)); - goto end; + goto err; } #if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) sigset_t set; @@ -1724,13 +1724,13 @@ pthread_handler_t handle_delayed_insert(void *arg) if (!(di->table=open_ltable(thd,&di->table_list,TL_WRITE_DELAYED))) { thd->fatal_error(); // Abort waiting inserts - goto end; + goto err; } if (!(di->table->file->table_flags() & HA_CAN_INSERT_DELAYED)) { thd->fatal_error(); my_error(ER_ILLEGAL_HA, MYF(0), di->table_list.table_name); - goto end; + goto err; } di->table->copy_blobs=1; @@ -1859,6 +1859,16 @@ pthread_handler_t handle_delayed_insert(void *arg) pthread_cond_broadcast(&di->cond_client); // If waiting clients } +err: + /* + mysql_lock_tables() can potentially start a transaction and write + a table map. In the event of an error, that transaction has to be + rolled back. We only need to roll back a potential statement + transaction, since real transactions are rolled back in + close_thread_tables(). + */ + ha_rollback_stmt(thd); + end: /* di should be unlinked from the thread handler list and have no active @@ -2493,9 +2503,25 @@ select_create::prepare(List &values, SELECT_LEX_UNIT *u) { DBUG_ENTER("select_create::prepare"); + class MY_HOOKS : public TABLEOP_HOOKS { + public: + MY_HOOKS(select_create *x) : ptr(x) { } + virtual void do_prelock(TABLE **tables, uint count) + { + if (binlog_row_based) + ptr->binlog_show_create_table(tables, count); + } + + private: + select_create *ptr; + }; + + MY_HOOKS hooks(this); + unit= u; table= create_table_from_items(thd, create_info, create_table, - extra_fields, keys, &values, &lock); + extra_fields, keys, &values, &lock, + &hooks); if (!table) DBUG_RETURN(-1); // abort() deletes table @@ -2533,7 +2559,7 @@ select_create::prepare(List &values, SELECT_LEX_UNIT *u) void -select_create::binlog_show_create_table() +select_create::binlog_show_create_table(TABLE **tables, uint count) { /* Note 1: In RBR mode, we generate a CREATE TABLE statement for the @@ -2556,18 +2582,19 @@ select_create::binlog_show_create_table() on rollback, we clear the OPTION_STATUS_NO_TRANS_UPDATE bit of thd->options. */ - DBUG_ASSERT(binlog_row_based && !create_table_written); + DBUG_ASSERT(binlog_row_based); + DBUG_ASSERT(tables && *tables && count > 0); thd->options&= ~OPTION_STATUS_NO_TRANS_UPDATE; char buf[2048]; String query(buf, sizeof(buf), system_charset_info); query.length(0); // Have to zero it since constructor doesn't - TABLE_LIST tables; - memset(&tables, 0, sizeof(tables)); - tables.table = table; + TABLE_LIST table_list; + memset(&table_list, 0, sizeof(table_list)); + table_list.table = *tables; - int result= store_create_info(thd, &tables, &query, create_info); + int result= store_create_info(thd, &table_list, &query, create_info); DBUG_ASSERT(result == 0); /* store_create_info() always return 0 */ thd->binlog_query(THD::STMT_QUERY_TYPE, query.ptr(), query.length(), @@ -2578,16 +2605,6 @@ select_create::binlog_show_create_table() void select_create::store_values(List &values) { - /* - Before writing the first row, we write the CREATE TABLE statement - to the binlog. - */ - if (binlog_row_based && !create_table_written) - { - binlog_show_create_table(); - create_table_written= TRUE; - } - fill_record_n_invoke_before_triggers(thd, field, values, 1, table->triggers, TRG_EVENT_INSERT); } @@ -2607,16 +2624,6 @@ void select_create::send_error(uint errcode,const char *err) bool select_create::send_eof() { - /* - If no rows where written to the binary log, we write the CREATE - TABLE statement to the binlog. - */ - if (binlog_row_based && !create_table_written) - { - binlog_show_create_table(); - create_table_written= TRUE; - } - bool tmp=select_insert::send_eof(); if (tmp) abort(); diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 3850e704718..948ed8fb97e 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -414,19 +414,6 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, #ifndef EMBEDDED_LIBRARY if (mysql_bin_log.is_open()) { -#ifdef HAVE_ROW_BASED_REPLICATION - /* - We need to do the job that is normally done inside - binlog_query() here, which is to ensure that the pending event - is written before tables are unlocked and before any other - events are written. We also need to update the table map - version for the binary log to mark that table maps are invalid - after this point. - */ - if (binlog_row_based) - thd->binlog_flush_pending_rows_event(true); - else -#endif { /* Make sure last block (the one which caused the error) gets diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f08c37ad40d..a4872e28ab8 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2069,7 +2069,8 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, List *extra_fields, List *keys, List *items, - MYSQL_LOCK **lock) + MYSQL_LOCK **lock, + TABLEOP_HOOKS *hooks) { TABLE tmp_table; // Used during 'create_field()' TABLE_SHARE share; @@ -2148,6 +2149,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, save us from that ? */ table->reginfo.lock_type=TL_WRITE; + hooks->prelock(&table, 1); // Call prelock hooks if (! ((*lock)= mysql_lock_tables(thd, &table, 1, MYSQL_LOCK_IGNORE_FLUSH, ¬_used))) { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 65d1beeaf3b..62ea4e89eff 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1415,7 +1415,7 @@ bool multi_update::send_data(List ¬_used_values) memcpy((char*) tmp_table->field[0]->ptr, (char*) table->file->ref, table->file->ref_length); /* Write row, ignoring duplicated updates to a row */ - if (error= tmp_table->file->ha_write_row(tmp_table->record[0])) + if ((error= tmp_table->file->ha_write_row(tmp_table->record[0]))) { if (error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE && diff --git a/sql/table.h b/sql/table.h index 99b818ef47b..cc1a50f1853 100644 --- a/sql/table.h +++ b/sql/table.h @@ -533,7 +533,8 @@ typedef struct st_table_list struct st_table_list *next_name_resolution_table; /* Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */ List *use_index, *ignore_index; - TABLE *table; /* opened table */ + TABLE *table; /* opened table */ + uint table_id; /* table id (from binlog) for opened table */ /* select_result for derived table to pass it from table creation to table filling procedure From 101edab125c3112be6cf76dd01b512b3bebcbcf5 Mon Sep 17 00:00:00 2001 From: "mats@mysql.com" <> Date: Fri, 24 Feb 2006 16:19:55 +0100 Subject: [PATCH 4/4] WL#3023 (RBR: Use locks in a statement-like manner): Adaptions to make it work with NDB. --- mysql-test/extra/binlog_tests/binlog.test | 3 + mysql-test/extra/binlog_tests/blackhole.test | 2 + .../extra/binlog_tests/ctype_cp932.test | 1 + .../binlog_tests/ctype_cp932_binlog.test | 1 + .../extra/binlog_tests/ctype_ucs_binlog.test | 1 + .../extra/binlog_tests/drop_temp_table.test | 1 + .../binlog_tests/insert_select-binlog.test | 2 + .../mix_innodb_myisam_binlog.test | 13 + mysql-test/extra/rpl_tests/rpl_flsh_tbls.test | 2 + mysql-test/extra/rpl_tests/rpl_log.test | 16 +- .../extra/rpl_tests/rpl_multi_query.test | 1 + .../extra/rpl_tests/rpl_row_charset.test | 3 +- .../extra/rpl_tests/rpl_row_delayed_ins.test | 1 + .../extra/rpl_tests/rpl_stm_charset.test | 1 + mysql-test/include/rpl_row_basic.inc | 54 +-- mysql-test/r/binlog_row_binlog.result | 408 +++++++++--------- mysql-test/r/binlog_row_blackhole.result | 36 +- mysql-test/r/binlog_row_ctype_cp932.result | 5 +- mysql-test/r/binlog_row_ctype_ucs.result | 4 +- mysql-test/r/binlog_row_insert_select.result | 8 +- .../r/binlog_row_mix_innodb_myisam.result | 144 +++---- mysql-test/r/ctype_cp932_binlog_row.result | 4 +- mysql-test/r/rpl_row_basic_11bugs.result | 4 +- mysql-test/r/rpl_row_basic_2myisam.result | 38 +- mysql-test/r/rpl_row_basic_3innodb.result | 38 +- mysql-test/r/rpl_row_charset.result | 70 +-- mysql-test/r/rpl_row_create_table.result | 12 +- mysql-test/r/rpl_row_delayed_ins.result | 4 +- mysql-test/r/rpl_row_log.result | 46 +- mysql-test/r/rpl_row_log_innodb.result | 46 +- mysql-test/r/rpl_row_max_relay_size.result | 2 +- mysql-test/r/rpl_row_sp008.result | 12 +- mysql-test/t/binlog_stm_binlog.test | 2 +- mysql-test/t/ndb_binlog_ddl_multi.test | 6 + mysql-test/t/ndb_binlog_ignore_db.test | 1 + mysql-test/t/rpl_heap.test | 2 + mysql-test/t/rpl_loaddata_s.test | 1 + mysql-test/t/rpl_ndb_blob.test | 1 + mysql-test/t/rpl_ndb_disk.test | 1 + mysql-test/t/rpl_row_basic_11bugs.test | 1 + mysql-test/t/rpl_row_create_table.test | 5 + mysql-test/t/rpl_row_drop.test | 1 + mysql-test/t/rpl_row_sp008.test | 1 + mysql-test/t/rpl_sp.test | 1 + mysql-test/t/sp.test | 1 + mysql-test/t/sp_notembedded.test | 1 + mysql-test/t/user_var-binlog.test | 1 + sql/ha_ndbcluster_binlog.cc | 17 +- sql/handler.h | 2 - sql/log.cc | 2 + sql/log_event.cc | 17 +- sql/rpl_injector.cc | 29 +- sql/rpl_injector.h | 74 ++++ 53 files changed, 647 insertions(+), 503 deletions(-) diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test index 8eb1dcb7dc3..46d012f123b 100644 --- a/mysql-test/extra/binlog_tests/binlog.test +++ b/mysql-test/extra/binlog_tests/binlog.test @@ -21,6 +21,7 @@ insert t2 values (5); commit; # first COMMIT must be Query_log_event, second - Xid_log_event --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; drop table t1,t2; @@ -42,6 +43,8 @@ while ($1) commit; drop table t1; --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events in 'master-bin.000001' from 102; --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events in 'master-bin.000002' from 102; diff --git a/mysql-test/extra/binlog_tests/blackhole.test b/mysql-test/extra/binlog_tests/blackhole.test index 7e03dc9ed57..3d1614b4035 100644 --- a/mysql-test/extra/binlog_tests/blackhole.test +++ b/mysql-test/extra/binlog_tests/blackhole.test @@ -122,6 +122,7 @@ select * from t3; let $VERSION=`select version()`; --replace_result $VERSION VERSION --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; drop table t1,t2,t3; @@ -143,4 +144,5 @@ rollback; set autocommit=1; --replace_result $VERSION VERSION --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; diff --git a/mysql-test/extra/binlog_tests/ctype_cp932.test b/mysql-test/extra/binlog_tests/ctype_cp932.test index 6fb91e9ae50..890aa701918 100644 --- a/mysql-test/extra/binlog_tests/ctype_cp932.test +++ b/mysql-test/extra/binlog_tests/ctype_cp932.test @@ -415,6 +415,7 @@ SET @var1= x'8300'; # code (and I have used it to test the fix) until there is some way to # exercise this code from mysql-test-run. EXECUTE stmt1 USING @var1; +--replace_regex /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 102; SELECT HEX(f1) FROM t1; DROP table t1; diff --git a/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test b/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test index a17f8f827a6..5e93d6e126e 100644 --- a/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test +++ b/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test @@ -27,6 +27,7 @@ SET @var1= x'8300'; # exercise this code from mysql-test-run. EXECUTE stmt1 USING @var1; --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 102; SELECT HEX(f1) FROM t1; DROP table t1; diff --git a/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test b/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test index 940310e4499..afe594b8d36 100644 --- a/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test +++ b/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test @@ -9,6 +9,7 @@ create table t2 (c char(30)) charset=ucs2; set @v=convert('abc' using ucs2); reset master; insert into t2 values (@v); +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we # absolutely need variables names to be quoted and strings to be diff --git a/mysql-test/extra/binlog_tests/drop_temp_table.test b/mysql-test/extra/binlog_tests/drop_temp_table.test index bc06de4096c..9c8647395bf 100644 --- a/mysql-test/extra/binlog_tests/drop_temp_table.test +++ b/mysql-test/extra/binlog_tests/drop_temp_table.test @@ -25,6 +25,7 @@ select get_lock("a",10); let $VERSION=`select version()`; --replace_result $VERSION VERSION --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; drop database `drop-temp+table-test`; diff --git a/mysql-test/extra/binlog_tests/insert_select-binlog.test b/mysql-test/extra/binlog_tests/insert_select-binlog.test index d4041f86ab5..a01dae5934b 100644 --- a/mysql-test/extra/binlog_tests/insert_select-binlog.test +++ b/mysql-test/extra/binlog_tests/insert_select-binlog.test @@ -15,6 +15,7 @@ insert into t1 select * from t2; # verify the binlog : let $VERSION=`select version()`; --replace_result $VERSION VERSION +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; select * from t1; drop table t1, t2; @@ -29,6 +30,7 @@ create table t2(unique(a)) select a from t1; # The above should produce an error, *and* not appear in the binlog let $VERSION=`select version()`; --replace_result $VERSION VERSION +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; drop table t1; diff --git a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test index 0de20ed8be8..18f620829ec 100644 --- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test +++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test @@ -30,6 +30,7 @@ insert into t2 select * from t1; commit; --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; delete from t1; @@ -43,6 +44,7 @@ insert into t2 select * from t1; rollback; --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; delete from t1; @@ -58,6 +60,7 @@ rollback to savepoint my_savepoint; commit; --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; delete from t1; @@ -75,6 +78,7 @@ commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; # and when ROLLBACK is not explicit? @@ -96,6 +100,7 @@ connection con2; # logging has been done, we use a user lock. select get_lock("a",10); --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; # and when not in a transact1on? @@ -107,6 +112,7 @@ insert into t1 values(9); insert into t2 select * from t1; --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; # Check that when the query updat1ng the MyISAM table is the first in the @@ -119,11 +125,13 @@ insert into t1 values(10); # first make t1 non-empty begin; insert into t2 select * from t1; --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; insert into t1 values(11); commit; --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; @@ -142,6 +150,7 @@ insert into t2 select * from t1; commit; --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; delete from t1; @@ -154,6 +163,7 @@ insert into t2 select * from t1; rollback; --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; delete from t1; @@ -169,6 +179,7 @@ rollback to savepoint my_savepoint; commit; --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; delete from t1; @@ -186,6 +197,7 @@ commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; # Test for BUG#5714, where a MyISAM update in the transaction used to @@ -246,6 +258,7 @@ disconnect con2; connection con3; select get_lock("lock1",60); --replace_column 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; do release_lock("lock1"); drop table t0,t2; diff --git a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test index c5db667e29b..cfa943228fa 100644 --- a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test +++ b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test @@ -19,6 +19,7 @@ flush no_write_to_binlog tables; # Check that it's not in the binlog. --replace_result $SERVER_VERSION SERVER_VERSION --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ eval SHOW BINLOG EVENTS FROM $rename_event_pos ; # Check that the master is not confused. select * from t3; @@ -27,6 +28,7 @@ flush tables; # Check that it's in the binlog. --replace_result $SERVER_VERSION SERVER_VERSION --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ eval SHOW BINLOG EVENTS FROM $rename_event_pos ; save_master_pos; connection slave; diff --git a/mysql-test/extra/rpl_tests/rpl_log.test b/mysql-test/extra/rpl_tests/rpl_log.test index 7f1c50aaf0e..b942ad29679 100644 --- a/mysql-test/extra/rpl_tests/rpl_log.test +++ b/mysql-test/extra/rpl_tests/rpl_log.test @@ -39,16 +39,16 @@ select count(*) from t1; drop table t1; --replace_result $VERSION VERSION --replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// +--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ show binlog events; --replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// +--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ show binlog events from 102 limit 1; --replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// +--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ show binlog events from 102 limit 2; --replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// +--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ show binlog events from 102 limit 2,1; flush logs; @@ -91,11 +91,11 @@ insert into t1 values (1); drop table t1; --replace_result $VERSION VERSION --replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// +--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ show binlog events; --replace_result $VERSION VERSION --replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// +--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ show binlog events in 'master-bin.000002'; show binary logs; save_master_pos; @@ -105,11 +105,11 @@ sync_with_master; show binary logs; --replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION --replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// +--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ show binlog events in 'slave-bin.000001' from 4; --replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION --replace_column 2 # 5 # ---replace_regex /\/\* xid=.* \*\//\/* XID *\// +--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ show binlog events in 'slave-bin.000002' from 4; --replace_result $MASTER_MYPORT MASTER_PORT --replace_column 1 # 8 # 9 # 16 # 23 # 33 # diff --git a/mysql-test/extra/rpl_tests/rpl_multi_query.test b/mysql-test/extra/rpl_tests/rpl_multi_query.test index a0062bd04bf..30a83886a86 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_query.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_query.test @@ -24,6 +24,7 @@ sync_slave_with_master; select * from mysqltest.t1; connection master; --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; drop database mysqltest; sync_slave_with_master; diff --git a/mysql-test/extra/rpl_tests/rpl_row_charset.test b/mysql-test/extra/rpl_tests/rpl_row_charset.test index c2a7cda4333..2533806983f 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_charset.test +++ b/mysql-test/extra/rpl_tests/rpl_row_charset.test @@ -114,6 +114,7 @@ connection master; drop database mysqltest2; drop database mysqltest3; --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; sync_slave_with_master; @@ -162,7 +163,7 @@ select hex(c1), hex(c2) from t1; connection master; # Let's have a look at generated SETs. ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +#--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR #--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 drop table t1; sync_slave_with_master; diff --git a/mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test b/mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test index fc899f1fa5f..8425ecf55a6 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test +++ b/mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test @@ -14,6 +14,7 @@ sync_slave_with_master; connection master; --replace_result $VERSION VERSION +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; sync_slave_with_master; select * from t1; diff --git a/mysql-test/extra/rpl_tests/rpl_stm_charset.test b/mysql-test/extra/rpl_tests/rpl_stm_charset.test index e5209a9b9ac..d29a82cfd31 100644 --- a/mysql-test/extra/rpl_tests/rpl_stm_charset.test +++ b/mysql-test/extra/rpl_tests/rpl_stm_charset.test @@ -110,6 +110,7 @@ connection master; drop database mysqltest2; drop database mysqltest3; --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; sync_slave_with_master; diff --git a/mysql-test/include/rpl_row_basic.inc b/mysql-test/include/rpl_row_basic.inc index 9f1cc186388..ea2c4c1688c 100644 --- a/mysql-test/include/rpl_row_basic.inc +++ b/mysql-test/include/rpl_row_basic.inc @@ -174,22 +174,16 @@ SELECT C1,HEX(B1),HEX(B2) FROM t4 ORDER BY C1; connection master; eval CREATE TABLE t7 (C1 INT PRIMARY KEY, C2 INT) ENGINE = $type ; sync_slave_with_master; ---disable_query_log -SELECT "--- on slave: original values ---" AS ""; ---enable_query_log +--echo --- on slave: original values --- INSERT INTO t7 VALUES (1,3), (2,6), (3,9); SELECT * FROM t7 ORDER BY C1; connection master; ---disable_query_log -SELECT "--- on master: new values inserted ---" AS ""; ---enable_query_log +--echo --- on master: new values inserted --- INSERT INTO t7 VALUES (1,2), (2,4), (3,6); SELECT * FROM t7 ORDER BY C1; sync_slave_with_master; ---disable_query_log -SELECT "--- on slave: old values should be overwritten by replicated values ---" AS ""; ---enable_query_log +--echo --- on slave: old values should be overwritten by replicated values --- SELECT * FROM t7 ORDER BY C1; # @@ -197,42 +191,33 @@ SELECT * FROM t7 ORDER BY C1; # causing a conflict for a key that is not "last". # connection master; ---disable_query_log -SELECT "--- on master ---" AS ""; ---enable_query_log -DROP TABLE t7; -eval CREATE TABLE t7 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = $type ; +--echo --- on master --- +eval CREATE TABLE t8 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = $type ; # First we make sure that the constraints are correctly set. -INSERT INTO t7 VALUES (99,99,99); +INSERT INTO t8 VALUES (99,99,99); --error 1062 -INSERT INTO t7 VALUES (99,22,33); +INSERT INTO t8 VALUES (99,22,33); --error 1062 -INSERT INTO t7 VALUES (11,99,33); +INSERT INTO t8 VALUES (11,99,33); --error 1062 -INSERT INTO t7 VALUES (11,22,99); -SELECT * FROM t7 ORDER BY a; +INSERT INTO t8 VALUES (11,22,99); +SELECT * FROM t8 ORDER BY a; sync_slave_with_master; ---disable_query_log -SELECT "--- on slave ---" AS ""; ---enable_query_log -SELECT * FROM t7 ORDER BY a; -INSERT INTO t7 VALUES (1,2,3), (2,4,6), (3,6,9); -SELECT * FROM t7 ORDER BY a; +--echo --- on slave --- +SELECT * FROM t8 ORDER BY a; +INSERT INTO t8 VALUES (1,2,3), (2,4,6), (3,6,9); +SELECT * FROM t8 ORDER BY a; connection master; ---disable_query_log -SELECT "--- on master ---" AS ""; ---enable_query_log +--echo --- on master --- # We insert a row that will cause conflict on the primary key but not # on the other keys. -INSERT INTO t7 VALUES (2,4,8); +INSERT INTO t8 VALUES (2,4,8); sync_slave_with_master; ---disable_query_log -SELECT "--- on slave ---" AS ""; ---enable_query_log -SELECT * FROM t7 ORDER BY a; +--echo --- on slave --- +SELECT * FROM t8 ORDER BY a; # # Test conflicting operations when changing in a table referenced by a @@ -245,5 +230,4 @@ SELECT * FROM t7 ORDER BY a; # connection master; -DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; -sync_slave_with_master; +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8; diff --git a/mysql-test/r/binlog_row_binlog.result b/mysql-test/r/binlog_row_binlog.result index df69ca29b2f..6cb086109b4 100644 --- a/mysql-test/r/binlog_row_binlog.result +++ b/mysql-test/r/binlog_row_binlog.result @@ -13,12 +13,12 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=bdb master-bin.000001 # Query 1 # use `test`; create table t2 (a int) engine=innodb master-bin.000001 # Query 1 # use `test`; BEGIN -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; BEGIN -master-bin.000001 # Table_map 1 # test.t2 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t2) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # COMMIT /* xid= */ drop table t1,t2; reset master; @@ -30,206 +30,206 @@ show binlog events in 'master-bin.000001' from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (n int) engine=innodb master-bin.000001 # Query 1 # use `test`; BEGIN -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # COMMIT /* xid= */ master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 show binlog events in 'master-bin.000002' from 102; diff --git a/mysql-test/r/binlog_row_blackhole.result b/mysql-test/r/binlog_row_blackhole.result index 7b1e64b00d8..aa5c943de00 100644 --- a/mysql-test/r/binlog_row_blackhole.result +++ b/mysql-test/r/binlog_row_blackhole.result @@ -109,33 +109,33 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 master-bin.000001 # Query 1 # use `test`; drop table t1,t2 master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=blackhole -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; create table t2 (a varchar(200)) engine=blackhole -master-bin.000001 # Table_map 1 # test.t2 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t2) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; alter table t1 add b int master-bin.000001 # Query 1 # use `test`; alter table t1 drop b master-bin.000001 # Query 1 # use `test`; create table t3 like t1 -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT drop table t1,t2,t3; reset master; @@ -153,6 +153,6 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=blackhole master-bin.000001 # Query 1 # use `test`; BEGIN -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; COMMIT diff --git a/mysql-test/r/binlog_row_ctype_cp932.result b/mysql-test/r/binlog_row_ctype_cp932.result index 6d213158ef6..4e0ba6f6a20 100644 --- a/mysql-test/r/binlog_row_ctype_cp932.result +++ b/mysql-test/r/binlog_row_ctype_cp932.result @@ -11323,8 +11323,8 @@ EXECUTE stmt1 USING @var1; SHOW BINLOG EVENTS FROM 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 189 use `test`; CREATE TABLE t1(f1 blob) -master-bin.000001 189 Table_map 1 228 test.t1 -master-bin.000001 228 Write_rows 1 262 +master-bin.000001 189 Table_map 1 228 table_id: # (test.t1) +master-bin.000001 228 Write_rows 1 262 table_id: # flags: STMT_END_F SELECT HEX(f1) FROM t1; HEX(f1) 8300 @@ -11366,4 +11366,3 @@ col1 a a a -drop table t1; diff --git a/mysql-test/r/binlog_row_ctype_ucs.result b/mysql-test/r/binlog_row_ctype_ucs.result index 12f7062d38a..5feb17cde13 100644 --- a/mysql-test/r/binlog_row_ctype_ucs.result +++ b/mysql-test/r/binlog_row_ctype_ucs.result @@ -5,8 +5,8 @@ reset master; insert into t2 values (@v); show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 102 Table_map 1 141 test.t2 -master-bin.000001 141 Write_rows 1 231 +master-bin.000001 102 Table_map 1 141 table_id: # (test.t2) +master-bin.000001 141 Write_rows 1 231 table_id: # flags: STMT_END_F /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ROLLBACK; diff --git a/mysql-test/r/binlog_row_insert_select.result b/mysql-test/r/binlog_row_insert_select.result index 27c515e5781..870d255d004 100644 --- a/mysql-test/r/binlog_row_insert_select.result +++ b/mysql-test/r/binlog_row_insert_select.result @@ -4,12 +4,12 @@ create table t2(a int); insert into t2 values(1),(2); reset master; insert into t1 select * from t2; -ERROR 23000: Duplicate entry '2' for key 1 +ERROR 23000: Duplicate entry '2' for key 'a' show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 -master-bin.000001 102 Table_map 1 141 test.t1 -master-bin.000001 141 Write_rows 1 175 +master-bin.000001 102 Table_map 1 141 table_id: # (test.t1) +master-bin.000001 141 Write_rows 1 175 table_id: # flags: STMT_END_F select * from t1; a 1 @@ -19,7 +19,7 @@ create table t1(a int); insert into t1 values(1),(1); reset master; create table t2(unique(a)) select a from t1; -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'a' show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 diff --git a/mysql-test/r/binlog_row_mix_innodb_myisam.result b/mysql-test/r/binlog_row_mix_innodb_myisam.result index 4ebbec4a424..324527fa036 100644 --- a/mysql-test/r/binlog_row_mix_innodb_myisam.result +++ b/mysql-test/r/binlog_row_mix_innodb_myisam.result @@ -9,10 +9,10 @@ commit; show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 # use `test`; BEGIN -master-bin.000001 170 Table_map 1 # test.t1 -master-bin.000001 209 Write_rows 1 # -master-bin.000001 243 Table_map 1 # test.t2 -master-bin.000001 282 Write_rows 1 # +master-bin.000001 170 Table_map 1 # table_id: # (test.t1) +master-bin.000001 209 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 243 Table_map 1 # table_id: # (test.t2) +master-bin.000001 282 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 316 Xid 1 # COMMIT /* xid= */ delete from t1; delete from t2; @@ -26,10 +26,10 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 # use `test`; BEGIN -master-bin.000001 170 Table_map 1 # test.t1 -master-bin.000001 209 Write_rows 1 # -master-bin.000001 243 Table_map 1 # test.t2 -master-bin.000001 282 Write_rows 1 # +master-bin.000001 170 Table_map 1 # table_id: # (test.t1) +master-bin.000001 209 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 243 Table_map 1 # table_id: # (test.t2) +master-bin.000001 282 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 316 Query 1 # use `test`; ROLLBACK delete from t1; delete from t2; @@ -46,13 +46,13 @@ commit; show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 # use `test`; BEGIN -master-bin.000001 170 Table_map 1 # test.t1 -master-bin.000001 209 Write_rows 1 # +master-bin.000001 170 Table_map 1 # table_id: # (test.t1) +master-bin.000001 209 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 243 Query 1 # use `test`; savepoint my_savepoint -master-bin.000001 328 Table_map 1 # test.t1 -master-bin.000001 367 Write_rows 1 # -master-bin.000001 401 Table_map 1 # test.t2 -master-bin.000001 440 Write_rows 1 # +master-bin.000001 328 Table_map 1 # table_id: # (test.t1) +master-bin.000001 367 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 401 Table_map 1 # table_id: # (test.t2) +master-bin.000001 440 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 479 Query 1 # use `test`; rollback to savepoint my_savepoint master-bin.000001 576 Xid 1 # COMMIT /* xid= */ delete from t1; @@ -75,16 +75,16 @@ a show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 # use `test`; BEGIN -master-bin.000001 170 Table_map 1 # test.t1 -master-bin.000001 209 Write_rows 1 # +master-bin.000001 170 Table_map 1 # table_id: # (test.t1) +master-bin.000001 209 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 243 Query 1 # use `test`; savepoint my_savepoint -master-bin.000001 328 Table_map 1 # test.t1 -master-bin.000001 367 Write_rows 1 # -master-bin.000001 401 Table_map 1 # test.t2 -master-bin.000001 440 Write_rows 1 # +master-bin.000001 328 Table_map 1 # table_id: # (test.t1) +master-bin.000001 367 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 401 Table_map 1 # table_id: # (test.t2) +master-bin.000001 440 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 479 Query 1 # use `test`; rollback to savepoint my_savepoint -master-bin.000001 576 Table_map 1 # test.t1 -master-bin.000001 615 Write_rows 1 # +master-bin.000001 576 Table_map 1 # table_id: # (test.t1) +master-bin.000001 615 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 649 Xid 1 # COMMIT /* xid= */ delete from t1; delete from t2; @@ -101,10 +101,10 @@ get_lock("a",10) show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 # use `test`; BEGIN -master-bin.000001 170 Table_map 1 # test.t1 -master-bin.000001 209 Write_rows 1 # -master-bin.000001 243 Table_map 1 # test.t2 -master-bin.000001 282 Write_rows 1 # +master-bin.000001 170 Table_map 1 # table_id: # (test.t1) +master-bin.000001 209 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 243 Table_map 1 # table_id: # (test.t2) +master-bin.000001 282 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 316 Query 1 # use `test`; ROLLBACK delete from t1; delete from t2; @@ -113,11 +113,11 @@ insert into t1 values(9); insert into t2 select * from t1; show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 102 Table_map 1 # test.t1 -master-bin.000001 141 Write_rows 1 # +master-bin.000001 102 Table_map 1 # table_id: # (test.t1) +master-bin.000001 141 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 175 Xid 1 # COMMIT /* xid= */ -master-bin.000001 202 Table_map 1 # test.t2 -master-bin.000001 241 Write_rows 1 # +master-bin.000001 202 Table_map 1 # table_id: # (test.t2) +master-bin.000001 241 Write_rows 1 # table_id: # flags: STMT_END_F delete from t1; delete from t2; reset master; @@ -126,23 +126,23 @@ begin; insert into t2 select * from t1; show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 102 Table_map 1 # test.t1 -master-bin.000001 141 Write_rows 1 # +master-bin.000001 102 Table_map 1 # table_id: # (test.t1) +master-bin.000001 141 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 175 Xid 1 # COMMIT /* xid= */ -master-bin.000001 202 Table_map 1 # test.t2 -master-bin.000001 241 Write_rows 1 # +master-bin.000001 202 Table_map 1 # table_id: # (test.t2) +master-bin.000001 241 Write_rows 1 # table_id: # flags: STMT_END_F insert into t1 values(11); commit; show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 102 Table_map 1 # test.t1 -master-bin.000001 141 Write_rows 1 # +master-bin.000001 102 Table_map 1 # table_id: # (test.t1) +master-bin.000001 141 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 175 Xid 1 # COMMIT /* xid= */ -master-bin.000001 202 Table_map 1 # test.t2 -master-bin.000001 241 Write_rows 1 # +master-bin.000001 202 Table_map 1 # table_id: # (test.t2) +master-bin.000001 241 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 275 Query 1 # use `test`; BEGIN -master-bin.000001 343 Table_map 1 # test.t1 -master-bin.000001 382 Write_rows 1 # +master-bin.000001 343 Table_map 1 # table_id: # (test.t1) +master-bin.000001 382 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 416 Xid 1 # COMMIT /* xid= */ alter table t2 engine=INNODB; delete from t1; @@ -155,10 +155,10 @@ commit; show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 # use `test`; BEGIN -master-bin.000001 170 Table_map 1 # test.t1 -master-bin.000001 209 Write_rows 1 # -master-bin.000001 243 Table_map 1 # test.t2 -master-bin.000001 282 Write_rows 1 # +master-bin.000001 170 Table_map 1 # table_id: # (test.t1) +master-bin.000001 209 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 243 Table_map 1 # table_id: # (test.t2) +master-bin.000001 282 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 316 Xid 1 # COMMIT /* xid= */ delete from t1; delete from t2; @@ -182,8 +182,8 @@ commit; show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 # use `test`; BEGIN -master-bin.000001 170 Table_map 1 # test.t1 -master-bin.000001 209 Write_rows 1 # +master-bin.000001 170 Table_map 1 # table_id: # (test.t1) +master-bin.000001 209 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 243 Xid 1 # COMMIT /* xid= */ delete from t1; delete from t2; @@ -203,14 +203,14 @@ a show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 # use `test`; BEGIN -master-bin.000001 170 Table_map 1 # test.t1 -master-bin.000001 209 Write_rows 1 # -master-bin.000001 243 Table_map 1 # test.t1 -master-bin.000001 282 Write_rows 1 # +master-bin.000001 170 Table_map 1 # table_id: # (test.t1) +master-bin.000001 209 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 243 Table_map 1 # table_id: # (test.t1) +master-bin.000001 282 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 316 Xid 1 # COMMIT /* xid= */ delete from t1; delete from t2; -alter table t2 type=MyISAM; +alter table t2 engine=MyISAM; insert into t1 values (1); begin; select * from t1 for update; @@ -257,31 +257,31 @@ get_lock("lock1",60) show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 # use `test`; BEGIN -master-bin.000001 170 Table_map 1 # test.t1 -master-bin.000001 209 Write_rows 1 # -master-bin.000001 243 Table_map 1 # test.t1 -master-bin.000001 282 Write_rows 1 # +master-bin.000001 170 Table_map 1 # table_id: # (test.t1) +master-bin.000001 209 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 243 Table_map 1 # table_id: # (test.t1) +master-bin.000001 282 Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 316 Xid 1 # COMMIT /* xid= */ -master-bin.000001 343 Table_map 1 # test.t1 +master-bin.000001 343 Table_map 1 # table_id: # (test.t1) master-bin.000001 382 Query 1 # use `test`; delete from t1 master-bin.000001 459 Xid 1 # COMMIT /* xid= */ -master-bin.000001 486 Table_map 1 # test.t2 +master-bin.000001 486 Table_map 1 # table_id: # (test.t2) master-bin.000001 525 Query 1 # use `test`; delete from t2 master-bin.000001 602 Xid 1 # COMMIT /* xid= */ -master-bin.000001 629 Query 1 # use `test`; alter table t2 type=MyISAM -master-bin.000001 718 Table_map 1 # test.t1 -master-bin.000001 757 Write_rows 1 # -master-bin.000001 791 Xid 1 # COMMIT /* xid= */ -master-bin.000001 818 Query 1 # use `test`; BEGIN -master-bin.000001 886 Table_map 1 # test.t1 -master-bin.000001 925 Write_rows 1 # -master-bin.000001 954 Xid 1 # COMMIT /* xid= */ -master-bin.000001 981 Query 1 # use `test`; drop table t1,t2 -master-bin.000001 1060 Query 1 # use `test`; create table t0 (n int) -master-bin.000001 1146 Table_map 1 # test.t0 -master-bin.000001 1185 Write_rows 1 # -master-bin.000001 1219 Table_map 1 # test.t0 -master-bin.000001 1258 Write_rows 1 # -master-bin.000001 1292 Query 1 # use `test`; create table t2 (n int) engine=innodb +master-bin.000001 629 Query 1 # use `test`; alter table t2 engine=MyISAM +master-bin.000001 720 Table_map 1 # table_id: # (test.t1) +master-bin.000001 759 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 793 Xid 1 # COMMIT /* xid= */ +master-bin.000001 820 Query 1 # use `test`; BEGIN +master-bin.000001 888 Table_map 1 # table_id: # (test.t1) +master-bin.000001 927 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 956 Xid 1 # COMMIT /* xid= */ +master-bin.000001 983 Query 1 # use `test`; drop table t1,t2 +master-bin.000001 1062 Query 1 # use `test`; create table t0 (n int) +master-bin.000001 1148 Table_map 1 # table_id: # (test.t0) +master-bin.000001 1187 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 1221 Table_map 1 # table_id: # (test.t0) +master-bin.000001 1260 Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 1294 Query 1 # use `test`; create table t2 (n int) engine=innodb do release_lock("lock1"); drop table t0,t2; diff --git a/mysql-test/r/ctype_cp932_binlog_row.result b/mysql-test/r/ctype_cp932_binlog_row.result index 913e8125619..f1a64241fbb 100644 --- a/mysql-test/r/ctype_cp932_binlog_row.result +++ b/mysql-test/r/ctype_cp932_binlog_row.result @@ -9,8 +9,8 @@ EXECUTE stmt1 USING @var1; SHOW BINLOG EVENTS FROM 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(f1 blob) -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F SELECT HEX(f1) FROM t1; HEX(f1) 8300 diff --git a/mysql-test/r/rpl_row_basic_11bugs.result b/mysql-test/r/rpl_row_basic_11bugs.result index 772a22babfe..4e8c1ad1c9b 100644 --- a/mysql-test/r/rpl_row_basic_11bugs.result +++ b/mysql-test/r/rpl_row_basic_11bugs.result @@ -28,8 +28,8 @@ INSERT INTO t2 VALUES (3,3), (4,4); SHOW BINLOG EVENTS FROM 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 102 Query 1 195 use `test`; CREATE TABLE t1 (a INT, b INT) -master-bin.000001 195 Table_map 1 235 test.t1 -master-bin.000001 235 Write_rows 1 282 +master-bin.000001 195 Table_map 1 235 table_id: # (test.t1) +master-bin.000001 235 Write_rows 1 282 table_id: # flags: STMT_END_F **** On Slave **** SHOW DATABASES; Database diff --git a/mysql-test/r/rpl_row_basic_2myisam.result b/mysql-test/r/rpl_row_basic_2myisam.result index 12a8d8282e3..a6877b27b95 100644 --- a/mysql-test/r/rpl_row_basic_2myisam.result +++ b/mysql-test/r/rpl_row_basic_2myisam.result @@ -363,7 +363,6 @@ SELECT C1,HEX(B1),HEX(B2) FROM t4 ORDER BY C1; C1 HEX(B1) HEX(B2) 1 NULL 0 CREATE TABLE t7 (C1 INT PRIMARY KEY, C2 INT) ENGINE = 'MYISAM' ; - --- on slave: original values --- INSERT INTO t7 VALUES (1,3), (2,6), (3,9); SELECT * FROM t7 ORDER BY C1; @@ -371,7 +370,6 @@ C1 C2 1 3 2 6 3 9 - --- on master: new values inserted --- INSERT INTO t7 VALUES (1,2), (2,4), (3,6); SELECT * FROM t7 ORDER BY C1; @@ -379,48 +377,42 @@ C1 C2 1 2 2 4 3 6 - --- on slave: old values should be overwritten by replicated values --- SELECT * FROM t7 ORDER BY C1; C1 C2 1 2 2 4 3 6 - --- on master --- -DROP TABLE t7; -CREATE TABLE t7 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = 'MYISAM' ; -INSERT INTO t7 VALUES (99,99,99); -INSERT INTO t7 VALUES (99,22,33); -ERROR 23000: Duplicate entry '99' for key 1 -INSERT INTO t7 VALUES (11,99,33); -ERROR 23000: Duplicate entry '99' for key 2 -INSERT INTO t7 VALUES (11,22,99); -ERROR 23000: Duplicate entry '99' for key 3 -SELECT * FROM t7 ORDER BY a; +CREATE TABLE t8 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = 'MYISAM' ; +INSERT INTO t8 VALUES (99,99,99); +INSERT INTO t8 VALUES (99,22,33); +ERROR 23000: Duplicate entry '99' for key 'PRIMARY' +INSERT INTO t8 VALUES (11,99,33); +ERROR 23000: Duplicate entry '99' for key 'b' +INSERT INTO t8 VALUES (11,22,99); +ERROR 23000: Duplicate entry '99' for key 'c' +SELECT * FROM t8 ORDER BY a; a b c 99 99 99 - --- on slave --- -SELECT * FROM t7 ORDER BY a; +SELECT * FROM t8 ORDER BY a; a b c 99 99 99 -INSERT INTO t7 VALUES (1,2,3), (2,4,6), (3,6,9); -SELECT * FROM t7 ORDER BY a; +INSERT INTO t8 VALUES (1,2,3), (2,4,6), (3,6,9); +SELECT * FROM t8 ORDER BY a; a b c 1 2 3 2 4 6 3 6 9 99 99 99 - --- on master --- -INSERT INTO t7 VALUES (2,4,8); - +INSERT INTO t8 VALUES (2,4,8); --- on slave --- -SELECT * FROM t7 ORDER BY a; +SELECT * FROM t8 ORDER BY a; a b c 1 2 3 2 4 8 3 6 9 99 99 99 -DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8; diff --git a/mysql-test/r/rpl_row_basic_3innodb.result b/mysql-test/r/rpl_row_basic_3innodb.result index ed9b231e1a1..4c6ec627db5 100644 --- a/mysql-test/r/rpl_row_basic_3innodb.result +++ b/mysql-test/r/rpl_row_basic_3innodb.result @@ -363,7 +363,6 @@ SELECT C1,HEX(B1),HEX(B2) FROM t4 ORDER BY C1; C1 HEX(B1) HEX(B2) 1 NULL 0 CREATE TABLE t7 (C1 INT PRIMARY KEY, C2 INT) ENGINE = 'INNODB' ; - --- on slave: original values --- INSERT INTO t7 VALUES (1,3), (2,6), (3,9); SELECT * FROM t7 ORDER BY C1; @@ -371,7 +370,6 @@ C1 C2 1 3 2 6 3 9 - --- on master: new values inserted --- INSERT INTO t7 VALUES (1,2), (2,4), (3,6); SELECT * FROM t7 ORDER BY C1; @@ -379,48 +377,42 @@ C1 C2 1 2 2 4 3 6 - --- on slave: old values should be overwritten by replicated values --- SELECT * FROM t7 ORDER BY C1; C1 C2 1 2 2 4 3 6 - --- on master --- -DROP TABLE t7; -CREATE TABLE t7 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = 'INNODB' ; -INSERT INTO t7 VALUES (99,99,99); -INSERT INTO t7 VALUES (99,22,33); -ERROR 23000: Duplicate entry '99' for key 1 -INSERT INTO t7 VALUES (11,99,33); -ERROR 23000: Duplicate entry '99' for key 2 -INSERT INTO t7 VALUES (11,22,99); -ERROR 23000: Duplicate entry '99' for key 3 -SELECT * FROM t7 ORDER BY a; +CREATE TABLE t8 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = 'INNODB' ; +INSERT INTO t8 VALUES (99,99,99); +INSERT INTO t8 VALUES (99,22,33); +ERROR 23000: Duplicate entry '99' for key 'PRIMARY' +INSERT INTO t8 VALUES (11,99,33); +ERROR 23000: Duplicate entry '99' for key 'b' +INSERT INTO t8 VALUES (11,22,99); +ERROR 23000: Duplicate entry '99' for key 'c' +SELECT * FROM t8 ORDER BY a; a b c 99 99 99 - --- on slave --- -SELECT * FROM t7 ORDER BY a; +SELECT * FROM t8 ORDER BY a; a b c 99 99 99 -INSERT INTO t7 VALUES (1,2,3), (2,4,6), (3,6,9); -SELECT * FROM t7 ORDER BY a; +INSERT INTO t8 VALUES (1,2,3), (2,4,6), (3,6,9); +SELECT * FROM t8 ORDER BY a; a b c 1 2 3 2 4 6 3 6 9 99 99 99 - --- on master --- -INSERT INTO t7 VALUES (2,4,8); - +INSERT INTO t8 VALUES (2,4,8); --- on slave --- -SELECT * FROM t7 ORDER BY a; +SELECT * FROM t8 ORDER BY a; a b c 1 2 3 2 4 8 3 6 9 99 99 99 -DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8; diff --git a/mysql-test/r/rpl_row_charset.result b/mysql-test/r/rpl_row_charset.result index 4108d0c6d90..060dffbfe2e 100644 --- a/mysql-test/r/rpl_row_charset.result +++ b/mysql-test/r/rpl_row_charset.result @@ -112,46 +112,56 @@ drop database mysqltest3; show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest2 -master-bin.000001 # Table_map 1 # mysql.proc -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (mysql.proc) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysql.event) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # drop database if exists mysqltest3 -master-bin.000001 # Table_map 1 # mysql.proc -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (mysql.proc) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysql.event) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # create database mysqltest2 character set latin2 master-bin.000001 # Query 1 # create database mysqltest3 master-bin.000001 # Query 1 # drop database mysqltest3 -master-bin.000001 # Table_map 1 # mysql.proc -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (mysql.proc) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysql.event) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # create database mysqltest3 master-bin.000001 # Query 1 # use `mysqltest2`; create table t1 (a int auto_increment primary key, b varchar(100)) -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `mysqltest2`; truncate table t1 -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `mysqltest2`; truncate table t1 -master-bin.000001 # Table_map 1 # mysqltest2.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (mysqltest2.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # drop database mysqltest2 -master-bin.000001 # Table_map 1 # mysql.proc -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (mysql.proc) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysql.event) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # drop database mysqltest3 -master-bin.000001 # Table_map 1 # mysql.proc -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (mysql.proc) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Table_map 1 # table_id: # (mysql.event) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F select "--- --global--" as ""; --- --global-- diff --git a/mysql-test/r/rpl_row_create_table.result b/mysql-test/r/rpl_row_create_table.result index 0a443d243ac..e35dcc2abb5 100644 --- a/mysql-test/r/rpl_row_create_table.result +++ b/mysql-test/r/rpl_row_create_table.result @@ -126,12 +126,12 @@ NULL 4 2 NULL 5 10 NULL 6 12 CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; -ERROR 23000: Duplicate entry '2' for key 1 +ERROR 23000: Duplicate entry '2' for key 'b' SHOW BINLOG EVENTS FROM 1326; Log_name Pos Event_type Server_id End_log_pos Info CREATE TABLE t7 (a INT, b INT UNIQUE); INSERT INTO t7 SELECT a,b FROM tt3; -ERROR 23000: Duplicate entry '2' for key 1 +ERROR 23000: Duplicate entry '2' for key 'b' SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -140,8 +140,8 @@ a b SHOW BINLOG EVENTS FROM 1326; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 1326 Query 1 1426 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) -master-bin.000001 1426 Table_map 1 1466 test.t7 -master-bin.000001 1466 Write_rows 1 1522 +master-bin.000001 1426 Table_map 1 1466 table_id: # (test.t7) +master-bin.000001 1466 Write_rows 1 1522 table_id: # flags: STMT_END_F SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -156,8 +156,8 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back SHOW BINLOG EVENTS FROM 1522; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1522 Table_map 1 1562 test.t7 -master-bin.000001 1562 Write_rows 1 1618 +master-bin.000001 1522 Table_map 1 1562 table_id: # (test.t7) +master-bin.000001 1562 Write_rows 1 1618 table_id: # flags: STMT_END_F SELECT * FROM t7 ORDER BY a,b; a b 1 2 diff --git a/mysql-test/r/rpl_row_delayed_ins.result b/mysql-test/r/rpl_row_delayed_ins.result index 7ed817b5780..b93aaae9112 100644 --- a/mysql-test/r/rpl_row_delayed_ins.result +++ b/mysql-test/r/rpl_row_delayed_ins.result @@ -16,8 +16,8 @@ show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 master-bin.000001 102 Query 1 222 use `test`; create table t1(a int not null primary key) engine=myisam -master-bin.000001 222 Table_map 1 261 test.t1 -master-bin.000001 261 Write_rows 1 305 +master-bin.000001 222 Table_map 1 261 table_id: # (test.t1) +master-bin.000001 261 Write_rows 1 305 table_id: # flags: STMT_END_F master-bin.000001 305 Query 1 380 use `test`; flush tables select * from t1; a diff --git a/mysql-test/r/rpl_row_log.result b/mysql-test/r/rpl_row_log.result index a5317975302..1265ff930f1 100644 --- a/mysql-test/r/rpl_row_log.result +++ b/mysql-test/r/rpl_row_log.result @@ -21,12 +21,12 @@ show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; drop table t1 master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; drop table t1 show binlog events from 102 limit 1; Log_name Pos Event_type Server_id End_log_pos Info @@ -34,10 +34,10 @@ master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_in show binlog events from 102 limit 2; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM -master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Table_map 1 # table_id: # (test.t1) show binlog events from 102 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F flush logs; create table t5 (a int)ENGINE=MyISAM; drop table t5; @@ -51,42 +51,44 @@ show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; drop table t1 master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # use `test`; drop table t1 master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 show binlog events in 'master-bin.000002'; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000002 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 +master-bin.000002 # Table_map 1 # table_id: # (mysql.slow_log) +master-bin.000002 # Table_map 1 # table_id: # (mysql.general_log) master-bin.000002 # Query 1 # use `test`; create table t5 (a int)ENGINE=MyISAM master-bin.000002 # Query 1 # use `test`; drop table t5 master-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=MyISAM -master-bin.000002 # Table_map 1 # test.t1 -master-bin.000002 # Write_rows 1 # +master-bin.000002 # Table_map 1 # table_id: # (test.t1) +master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000002 # Query 1 # use `test`; drop table t1 show binary logs; Log_name File_size master-bin.000001 1332 -master-bin.000002 525 +master-bin.000002 635 start slave; show binary logs; Log_name File_size slave-bin.000001 1506 -slave-bin.000002 350 +slave-bin.000002 460 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM -slave-bin.000001 # Table_map 1 # test.t1 -slave-bin.000001 # Write_rows 1 # +slave-bin.000001 # Table_map 1 # table_id: # (test.t1) +slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F slave-bin.000001 # Query 1 # use `test`; drop table t1 slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM -slave-bin.000001 # Table_map 1 # test.t1 -slave-bin.000001 # Write_rows 1 # +slave-bin.000001 # Table_map 1 # table_id: # (test.t1) +slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F slave-bin.000001 # Query 1 # use `test`; drop table t1 slave-bin.000001 # Query 1 # use `test`; create table t5 (a int)ENGINE=MyISAM slave-bin.000001 # Query 1 # use `test`; drop table t5 @@ -94,12 +96,14 @@ slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 show binlog events in 'slave-bin.000002' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000002 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 +slave-bin.000002 # Table_map 2 # table_id: # (mysql.slow_log) +slave-bin.000002 # Table_map 2 # table_id: # (mysql.general_log) slave-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=MyISAM -slave-bin.000002 # Table_map 1 # test.t1 -slave-bin.000002 # Write_rows 1 # +slave-bin.000002 # Table_map 1 # table_id: # (test.t1) +slave-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F slave-bin.000002 # Query 1 # use `test`; drop table t1 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 525 # # master-bin.000002 Yes Yes # 0 0 525 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 635 # # master-bin.000002 Yes Yes # 0 0 635 # None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log diff --git a/mysql-test/r/rpl_row_log_innodb.result b/mysql-test/r/rpl_row_log_innodb.result index 52b5219cf43..6c378bede1b 100644 --- a/mysql-test/r/rpl_row_log_innodb.result +++ b/mysql-test/r/rpl_row_log_innodb.result @@ -21,13 +21,13 @@ show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # COMMIT /* XID */ master-bin.000001 # Query 1 # use `test`; drop table t1 master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # COMMIT /* XID */ master-bin.000001 # Query 1 # use `test`; drop table t1 show binlog events from 102 limit 1; @@ -36,10 +36,10 @@ master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_in show binlog events from 102 limit 2; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB -master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Table_map 1 # table_id: # (test.t1) show binlog events from 102 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F flush logs; create table t5 (a int)ENGINE=InnoDB; drop table t5; @@ -53,46 +53,48 @@ show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # COMMIT /* XID */ master-bin.000001 # Query 1 # use `test`; drop table t1 master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB -master-bin.000001 # Table_map 1 # test.t1 -master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # table_id: # (test.t1) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # COMMIT /* XID */ master-bin.000001 # Query 1 # use `test`; drop table t1 master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 show binlog events in 'master-bin.000002'; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000002 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 +master-bin.000002 # Table_map 1 # table_id: # (mysql.slow_log) +master-bin.000002 # Table_map 1 # table_id: # (mysql.general_log) master-bin.000002 # Query 1 # use `test`; create table t5 (a int)ENGINE=InnoDB master-bin.000002 # Query 1 # use `test`; drop table t5 master-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=InnoDB -master-bin.000002 # Table_map 1 # test.t1 -master-bin.000002 # Write_rows 1 # +master-bin.000002 # Table_map 1 # table_id: # (test.t1) +master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000002 # Xid 1 # COMMIT /* XID */ master-bin.000002 # Query 1 # use `test`; drop table t1 show binary logs; Log_name File_size master-bin.000001 1386 -master-bin.000002 552 +master-bin.000002 662 start slave; show binary logs; Log_name File_size slave-bin.000001 1560 -slave-bin.000002 377 +slave-bin.000002 487 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB -slave-bin.000001 # Table_map 1 # test.t1 -slave-bin.000001 # Write_rows 1 # +slave-bin.000001 # Table_map 1 # table_id: # (test.t1) +slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F slave-bin.000001 # Xid 1 # COMMIT /* XID */ slave-bin.000001 # Query 1 # use `test`; drop table t1 slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB -slave-bin.000001 # Table_map 1 # test.t1 -slave-bin.000001 # Write_rows 1 # +slave-bin.000001 # Table_map 1 # table_id: # (test.t1) +slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F slave-bin.000001 # Xid 1 # COMMIT /* XID */ slave-bin.000001 # Query 1 # use `test`; drop table t1 slave-bin.000001 # Query 1 # use `test`; create table t5 (a int)ENGINE=InnoDB @@ -101,13 +103,15 @@ slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 show binlog events in 'slave-bin.000002' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000002 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 +slave-bin.000002 # Table_map 2 # table_id: # (mysql.slow_log) +slave-bin.000002 # Table_map 2 # table_id: # (mysql.general_log) slave-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=InnoDB -slave-bin.000002 # Table_map 1 # test.t1 -slave-bin.000002 # Write_rows 1 # +slave-bin.000002 # Table_map 1 # table_id: # (test.t1) +slave-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F slave-bin.000002 # Xid 1 # COMMIT /* XID */ slave-bin.000002 # Query 1 # use `test`; drop table t1 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 552 # # master-bin.000002 Yes Yes # 0 0 552 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 662 # # master-bin.000002 Yes Yes # 0 0 662 # None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log diff --git a/mysql-test/r/rpl_row_max_relay_size.result b/mysql-test/r/rpl_row_max_relay_size.result index 6146d623ec5..b7afe0b0515 100644 --- a/mysql-test/r/rpl_row_max_relay_size.result +++ b/mysql-test/r/rpl_row_max_relay_size.result @@ -58,4 +58,4 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File flush logs; show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000002 102 +master-bin.000002 212 diff --git a/mysql-test/r/rpl_row_sp008.result b/mysql-test/r/rpl_row_sp008.result index 57606e26f19..633709e83ca 100644 --- a/mysql-test/r/rpl_row_sp008.result +++ b/mysql-test/r/rpl_row_sp008.result @@ -35,11 +35,11 @@ master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 master-bin.000001 102 Query 1 193 use `test`; DROP TABLE IF EXISTS test.t2 master-bin.000001 193 Query 1 299 use `test`; CREATE TABLE test.t1 (a INT,PRIMARY KEY(a)) master-bin.000001 299 Query 1 405 use `test`; CREATE TABLE test.t2 (a INT,PRIMARY KEY(a)) -master-bin.000001 405 Table_map 1 444 test.t1 -master-bin.000001 444 Write_rows 1 483 -master-bin.000001 483 Table_map 1 540 mysql.proc -master-bin.000001 540 Write_rows 1 723 -master-bin.000001 723 Table_map 1 762 test.t2 -master-bin.000001 762 Write_rows 1 796 +master-bin.000001 405 Table_map 1 444 table_id: # (test.t1) +master-bin.000001 444 Write_rows 1 483 table_id: # flags: STMT_END_F +master-bin.000001 483 Table_map 1 540 table_id: # (mysql.proc) +master-bin.000001 540 Write_rows 1 723 table_id: # flags: STMT_END_F +master-bin.000001 723 Table_map 1 762 table_id: # (test.t2) +master-bin.000001 762 Write_rows 1 796 table_id: # flags: STMT_END_F DROP PROCEDURE IF EXISTS test.p1; DROP TABLE IF EXISTS test.t1; diff --git a/mysql-test/t/binlog_stm_binlog.test b/mysql-test/t/binlog_stm_binlog.test index 826ce54ae2c..f22e7e45aea 100644 --- a/mysql-test/t/binlog_stm_binlog.test +++ b/mysql-test/t/binlog_stm_binlog.test @@ -5,7 +5,7 @@ create table t1 (a int, b int) engine=innodb; begin; insert into t1 values (1,2); commit; ---replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ +--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ show binlog events; drop table t1; diff --git a/mysql-test/t/ndb_binlog_ddl_multi.test b/mysql-test/t/ndb_binlog_ddl_multi.test index 3aa3b9469fd..e75bd8ab201 100644 --- a/mysql-test/t/ndb_binlog_ddl_multi.test +++ b/mysql-test/t/ndb_binlog_ddl_multi.test @@ -35,11 +35,13 @@ create table t1 (a int primary key) engine=ndb; create table t2 (a int primary key) engine=ndb; --replace_result $binlog_start --replace_column 2 # 4 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ --eval show binlog events from $binlog_start --connection server1 --replace_result $binlog_start --replace_column 2 # 4 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ --eval show binlog events from $binlog_start @@ -55,6 +57,7 @@ alter table t2 add column (b int); --connections server1 --replace_result $binlog_start --replace_column 2 # 4 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ --eval show binlog events from $binlog_start @@ -75,6 +78,7 @@ drop table mysqltest.t1; --connection server1 --replace_result $binlog_start --replace_column 2 # 4 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ --eval show binlog events from $binlog_start @@ -93,6 +97,7 @@ create table t1 (a int primary key) engine=ndb; --connection server2 --replace_result $binlog_start --replace_column 2 # 4 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ --eval show binlog events from $binlog_start --connection server2 @@ -146,4 +151,5 @@ drop table t1; --connection server2 --replace_result $binlog_start --replace_column 2 # 4 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ --eval show binlog events from $binlog_start diff --git a/mysql-test/t/ndb_binlog_ignore_db.test b/mysql-test/t/ndb_binlog_ignore_db.test index a46266f209a..82a261ffe13 100644 --- a/mysql-test/t/ndb_binlog_ignore_db.test +++ b/mysql-test/t/ndb_binlog_ignore_db.test @@ -14,6 +14,7 @@ create table t1 (a int primary key, b int) engine=ndb; insert into t1 values (1, 1); --replace_result $binlog_start --replace_column 2 # 4 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ --eval show binlog events from $binlog_start drop database mysqltest; diff --git a/mysql-test/t/rpl_heap.test b/mysql-test/t/rpl_heap.test index 2436b851a03..b35983ad4d7 100644 --- a/mysql-test/t/rpl_heap.test +++ b/mysql-test/t/rpl_heap.test @@ -22,6 +22,7 @@ create table t1 engine=HEAP select 10 as a; insert into t1 values(11); save_master_pos; --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 79; connection slave; reset slave; @@ -40,6 +41,7 @@ select * from t1; select * from t1 limit 10; save_master_pos; --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events in 'master-bin.002' from 79; connection slave; diff --git a/mysql-test/t/rpl_loaddata_s.test b/mysql-test/t/rpl_loaddata_s.test index 8e2bf012bc9..72a5d1a8ec1 100644 --- a/mysql-test/t/rpl_loaddata_s.test +++ b/mysql-test/t/rpl_loaddata_s.test @@ -21,6 +21,7 @@ connection slave; sync_with_master; select count(*) from test.t1; # check that LOAD was replicated --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; # should be nothing # Cleanup diff --git a/mysql-test/t/rpl_ndb_blob.test b/mysql-test/t/rpl_ndb_blob.test index c31b629b9f8..97f3591cfaa 100644 --- a/mysql-test/t/rpl_ndb_blob.test +++ b/mysql-test/t/rpl_ndb_blob.test @@ -90,4 +90,5 @@ drop table t1; --connection master let $VERSION=`select version()`; --replace_result $VERSION VERSION +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; diff --git a/mysql-test/t/rpl_ndb_disk.test b/mysql-test/t/rpl_ndb_disk.test index f1aa1ee2bf1..0e8e4124100 100644 --- a/mysql-test/t/rpl_ndb_disk.test +++ b/mysql-test/t/rpl_ndb_disk.test @@ -69,6 +69,7 @@ select * from t1 order by pk1; --connection master let $VERSION=`select version()`; --replace_result $VERSION VERSION +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; # diff --git a/mysql-test/t/rpl_row_basic_11bugs.test b/mysql-test/t/rpl_row_basic_11bugs.test index 67fa11b76a0..d098723644f 100644 --- a/mysql-test/t/rpl_row_basic_11bugs.test +++ b/mysql-test/t/rpl_row_basic_11bugs.test @@ -17,6 +17,7 @@ USE test_ignore; CREATE TABLE t2 (a INT, b INT); SHOW TABLES; INSERT INTO t2 VALUES (3,3), (4,4); +--replace_regex /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 102; sync_slave_with_master; --echo **** On Slave **** diff --git a/mysql-test/t/rpl_row_create_table.test b/mysql-test/t/rpl_row_create_table.test index 52373b8278c..6897dc5c718 100644 --- a/mysql-test/t/rpl_row_create_table.test +++ b/mysql-test/t/rpl_row_create_table.test @@ -26,6 +26,7 @@ CREATE TABLE t2 (a INT, b INT) ENGINE=Merge; CREATE TABLE t3 (a INT, b INT) CHARSET=utf8; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8; --replace_column 1 # 4 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ --query_vertical SHOW BINLOG EVENTS FROM 212 --echo **** On Master **** --query_vertical SHOW CREATE TABLE t1 @@ -60,6 +61,7 @@ connection master; --error 1062 CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; # Shouldn't be written to the binary log +--replace_regex /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 1326; # Test that INSERT-SELECT works the same way as for SBR. @@ -68,6 +70,7 @@ CREATE TABLE t7 (a INT, b INT UNIQUE); INSERT INTO t7 SELECT a,b FROM tt3; SELECT * FROM t7 ORDER BY a,b; # Should be written to the binary log +--replace_regex /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 1326; sync_slave_with_master; SELECT * FROM t7 ORDER BY a,b; @@ -78,6 +81,7 @@ INSERT INTO tt4 VALUES (4,8), (5,10), (6,12); BEGIN; INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; +--replace_regex /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 1522; SELECT * FROM t7 ORDER BY a,b; sync_slave_with_master; @@ -91,6 +95,7 @@ CREATE TEMPORARY TABLE tt6 LIKE tt4; --echo **** On Master **** --query_vertical SHOW CREATE TABLE t8 --query_vertical SHOW CREATE TABLE t9 +--replace_regex /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 1618; sync_slave_with_master; --echo **** On Slave **** diff --git a/mysql-test/t/rpl_row_drop.test b/mysql-test/t/rpl_row_drop.test index 816bd108b88..20c217a7c3a 100644 --- a/mysql-test/t/rpl_row_drop.test +++ b/mysql-test/t/rpl_row_drop.test @@ -32,6 +32,7 @@ connection master; DROP TABLE t1,t2; let $VERSION=`select version()`; --replace_result $VERSION VERSION +--replace_regex /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS; SHOW TABLES; sync_slave_with_master; diff --git a/mysql-test/t/rpl_row_sp008.test b/mysql-test/t/rpl_row_sp008.test index 611062543e0..ea837dccd5a 100644 --- a/mysql-test/t/rpl_row_sp008.test +++ b/mysql-test/t/rpl_row_sp008.test @@ -49,6 +49,7 @@ SELECT * FROM test.t2; connection master; let $VERSION=`select version()`; --replace_result $VERSION VERSION +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; # Cleanup diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 73f14bd49b3..de26fd24174 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -343,6 +343,7 @@ drop trigger trg; insert into t1 values (1); select * from t1; --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events in 'master-bin.000001' from 102; sync_slave_with_master; select * from t1; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 45de4010535..9a5b435d504 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -2583,6 +2583,7 @@ begin show warnings; end| --disable_parsing +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; show storage engines; show master status; diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index f7ba9803fda..5ba78473f8b 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -15,6 +15,7 @@ begin show grants for 'root'@'localhost'; end| --disable_parsing +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events; show storage engines; show master status; diff --git a/mysql-test/t/user_var-binlog.test b/mysql-test/t/user_var-binlog.test index a7726c990f1..7f1561b925b 100644 --- a/mysql-test/t/user_var-binlog.test +++ b/mysql-test/t/user_var-binlog.test @@ -14,6 +14,7 @@ set @var1= "';aaa"; SET @var2=char(ascii('a')); insert into t1 values (@var1),(@var2); --replace_column 2 # 5 # +--replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we # absolutely need variables names to be quoted and strings to be diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 06f946b013c..52ab3afcba1 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -310,7 +310,7 @@ void ndbcluster_binlog_init_share(NDB_SHARE *share, TABLE *_table) table= 0; break; } - assign_new_table_id(table); + assign_new_table_id(table_share); if (!table->record[1] || table->record[1] == table->record[0]) { table->record[1]= alloc_root(&table->mem_root, @@ -1620,15 +1620,20 @@ static int open_binlog_index(THD *thd, TABLE_LIST *tables, /* Insert one row in the cluster_replication.binlog_index - - declared friend in handler.h to be able to call write_row directly - so that this insert is not replicated */ int ndb_add_binlog_index(THD *thd, void *_row) { Binlog_index_row &row= *(Binlog_index_row *) _row; int error= 0; bool need_reopen; + + /* + Turn of binlogging to prevent the table changes to be written to + the binary log. + */ + ulong saved_options= thd->options; + thd->options&= ~(OPTION_BIN_LOG); + for ( ; ; ) /* loop for need_reopen */ { if (!binlog_index && open_binlog_index(thd, &binlog_tables, &binlog_index)) @@ -1663,7 +1668,7 @@ int ndb_add_binlog_index(THD *thd, void *_row) binlog_index->field[6]->store(row.n_schemaops); int r; - if ((r= binlog_index->file->write_row(binlog_index->record[0]))) + if ((r= binlog_index->file->ha_write_row(binlog_index->record[0]))) { sql_print_error("NDB Binlog: Writing row to binlog_index: %d", r); error= -1; @@ -1672,10 +1677,12 @@ int ndb_add_binlog_index(THD *thd, void *_row) mysql_unlock_tables(thd, thd->lock); thd->lock= 0; + thd->options= saved_options; return 0; add_binlog_index_err: close_thread_tables(thd); binlog_index= 0; + thd->options= saved_options; return error; } diff --git a/sql/handler.h b/sql/handler.h index dd445637b9f..37bf5335077 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1907,8 +1907,6 @@ public: { return COMPATIBLE_DATA_NO; } private: - friend int ndb_add_binlog_index(THD *, void *); - /* Row-level primitives for storage engines. These should be overridden by the storage engine class. To call these methods, use diff --git a/sql/log.cc b/sql/log.cc index c2fadb9d845..2b75bda2d70 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2680,6 +2680,8 @@ int MYSQL_LOG::flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event) DBUG_ASSERT(trx_data); + DBUG_PRINT("info", ("trx_data->pending=%p", trx_data->pending)); + if (Rows_log_event* pending= trx_data->pending) { IO_CACHE *file= &log_file; diff --git a/sql/log_event.cc b/sql/log_event.cc index 9fbb29bbc8c..944190c6d20 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5268,8 +5268,8 @@ int Rows_log_event::exec_event(st_relay_log_info *rli) /* If m_table_id == ULONG_MAX, then we have a dummy event that does not contain any data. In that case, we just remove all tables in - the tables_to_lock list, step the relay log position, and return - with success. + the tables_to_lock list, close the thread tables, step the relay + log position, and return with success. */ if (m_table_id == ULONG_MAX) { @@ -5280,6 +5280,7 @@ int Rows_log_event::exec_event(st_relay_log_info *rli) DBUG_ASSERT(get_flags(STMT_END_F)); rli->clear_tables_to_lock(); + close_thread_tables(thd); thd->clear_error(); rli->inc_event_relay_log_pos(); DBUG_RETURN(0); @@ -5414,12 +5415,16 @@ int Rows_log_event::exec_event(st_relay_log_info *rli) DBUG_ASSERT(row_end != NULL); // cannot happen DBUG_ASSERT(row_end <= (const char*)m_rows_end); +#if 0 /* in_use can have been set to NULL in close_tables_for_reopen */ THD* old_thd= table->in_use; if (!table->in_use) table->in_use= thd; +#endif error= do_exec_row(table); +#if 0 table->in_use = old_thd; +#endif switch (error) { /* Some recoverable errors */ @@ -5599,14 +5604,12 @@ bool Rows_log_event::write_data_body(IO_CACHE*file) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Rows_log_event::pack_info(Protocol *protocol) { -#ifdef DBUG_RBR char buf[256]; char const *const flagstr= get_flags(STMT_END_F) ? " flags: STMT_END_F" : ""; my_size_t bytes= snprintf(buf, sizeof(buf), "table_id: %lu%s", m_table_id, flagstr); protocol->store(buf, bytes, &my_charset_bin); -#endif } #endif @@ -6009,17 +6012,11 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) void Table_map_log_event::pack_info(Protocol *protocol) { -#ifdef DBUG_RBR char buf[256]; my_size_t bytes= snprintf(buf, sizeof(buf), "table_id: %lu (%s.%s)", m_table_id, m_dbnam, m_tblnam); protocol->store(buf, bytes, &my_charset_bin); -#else - char buf[256]; - my_size_t bytes= snprintf(buf, sizeof(buf), "%s.%s", m_dbnam, m_tblnam); - protocol->store(buf, bytes, &my_charset_bin); -#endif } #endif diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc index a69dea9a158..a69cfc2b75f 100644 --- a/sql/rpl_injector.cc +++ b/sql/rpl_injector.cc @@ -26,7 +26,7 @@ /* inline since it's called below */ inline injector::transaction::transaction(MYSQL_LOG *log, THD *thd) - : m_thd(thd) + : m_state(START_STATE), m_thd(thd) { /* Default initialization of m_start_pos (which initializes it to garbage). @@ -64,12 +64,31 @@ int injector::transaction::commit() DBUG_RETURN(0); } +int injector::transaction::use_table(server_id_type sid, table tbl) +{ + DBUG_ENTER("injector::transaction::use_table"); + + int error; + + if ((error= check_state(TABLE_STATE))) + DBUG_RETURN(error); + + m_thd->set_server_id(sid); + error= m_thd->binlog_write_table_map(tbl.get_table(), + tbl.is_transactional()); + DBUG_RETURN(error); +} + int injector::transaction::write_row (server_id_type sid, table tbl, MY_BITMAP const* cols, size_t colcnt, record_type record) { DBUG_ENTER("injector::transaction::write_row(...)"); + + if (int error= check_state(ROW_STATE)) + DBUG_RETURN(error); + m_thd->set_server_id(sid); m_thd->binlog_write_row(tbl.get_table(), tbl.is_transactional(), cols, colcnt, record); @@ -82,6 +101,10 @@ int injector::transaction::delete_row(server_id_type sid, table tbl, record_type record) { DBUG_ENTER("injector::transaction::delete_row(...)"); + + if (int error= check_state(ROW_STATE)) + DBUG_RETURN(error); + m_thd->set_server_id(sid); m_thd->binlog_delete_row(tbl.get_table(), tbl.is_transactional(), cols, colcnt, record); @@ -94,6 +117,10 @@ int injector::transaction::update_row(server_id_type sid, table tbl, record_type before, record_type after) { DBUG_ENTER("injector::transaction::update_row(...)"); + + if (int error= check_state(ROW_STATE)) + DBUG_RETURN(error); + m_thd->set_server_id(sid); m_thd->binlog_update_row(tbl.get_table(), tbl.is_transactional(), cols, colcnt, before, after); diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h index 32d3fdd1a78..50a0a56dd9b 100644 --- a/sql/rpl_injector.h +++ b/sql/rpl_injector.h @@ -159,6 +159,24 @@ public: return *this; } + /* + + DESCRIPTION + + Register table for use within the transaction. All tables + that are going to be used need to be registered before being + used below. The member function will fail with an error if + use_table() is called after any *_row() function has been + called for the transaction. + + RETURN VALUE + + 0 All OK + >0 Failure + + */ + int use_table(server_id_type sid, table tbl); + /* Add a 'write row' entry to the transaction. */ @@ -219,6 +237,62 @@ public: } } + enum enum_state + { + START_STATE, /* Start state */ + TABLE_STATE, /* At least one table has been registered */ + ROW_STATE, /* At least one row has been registered */ + STATE_COUNT /* State count and sink state */ + } m_state; + + /* + Check and update the state. + + PARAMETER(S) + + target_state + The state we are moving to: TABLE_STATE if we are + writing a table and ROW_STATE if we are writing a row. + + DESCRIPTION + + The internal state will be updated to the target state if + and only if it is a legal move. The only legal moves are: + + START_STATE -> START_STATE + START_STATE -> TABLE_STATE + TABLE_STATE -> TABLE_STATE + TABLE_STATE -> ROW_STATE + + That is: + - It is not possible to write any row before having written at + least one table + - It is not possible to write a table after at least one row + has been written + + RETURN VALUE + + 0 All OK + -1 Incorrect call sequence + */ + int check_state(enum_state const target_state) + { + static char const *state_name[] = { + "START_STATE", "TABLE_STATE", "ROW_STATE", "STATE_COUNT" + }; + + DBUG_ASSERT(0 <= target_state && target_state <= STATE_COUNT); + DBUG_PRINT("info", ("In state %s", state_name[m_state])); + + if (m_state <= target_state && target_state <= m_state + 1 && + m_state < STATE_COUNT) + m_state= target_state; + else + m_state= STATE_COUNT; + return m_state == STATE_COUNT ? 1 : 0; + } + + binlog_pos m_start_pos; THD *m_thd; };