From 82ac789172d627739541284cd1f314d4fa514a3e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Jul 2007 08:11:38 +0200 Subject: [PATCH] Bug#22540: Incorrect value in column End_log_pos of SHOW BINLOG EVENTS using InnoDB dollin' it up for Guilhem ;) -- test streamlined, better comments, faster code, add'l assert. mysql-test/r/binlog.result: Bug#22540: Incorrect value in column End_log_pos of SHOW BINLOG EVENTS using InnoDB streamlined test mysql-test/t/binlog.test: Bug#22540: Incorrect value in column End_log_pos of SHOW BINLOG EVENTS using InnoDB streamlined test sql/log.cc: Bug#22540: Incorrect value in column End_log_pos of SHOW BINLOG EVENTS using InnoDB comment clarified --- mysql-test/r/binlog.result | 97 -------------------------------------- mysql-test/t/binlog.test | 61 ------------------------ sql/log.cc | 16 ++++--- 3 files changed, 9 insertions(+), 165 deletions(-) diff --git a/mysql-test/r/binlog.result b/mysql-test/r/binlog.result index aa5c6e88d65..0a199c87545 100644 --- a/mysql-test/r/binlog.result +++ b/mysql-test/r/binlog.result @@ -153,105 +153,8 @@ master-bin.000001 353 Query 1 441 use `test`; insert into t1 values (2) master-bin.000001 441 Query 1 529 use `test`; insert into t1 values (3) master-bin.000001 529 Xid 1 556 COMMIT /* XID */ master-bin.000001 556 Query 1 632 use `test`; drop table t1 -set autocommit= 1; -reset master; -create table t1(n int) engine=innodb; -insert into t1 values (1); -insert into t1 values (2); -insert into t1 values (3); -commit; -drop table t1; -show binlog events from 0; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 98 Server version, Binlog ver: 4 -master-bin.000001 98 Query 1 197 use `test`; create table t1(n int) engine=innodb -master-bin.000001 197 Query 1 285 use `test`; insert into t1 values (1) -master-bin.000001 285 Xid 1 312 COMMIT /* XID */ -master-bin.000001 312 Query 1 400 use `test`; insert into t1 values (2) -master-bin.000001 400 Xid 1 427 COMMIT /* XID */ -master-bin.000001 427 Query 1 515 use `test`; insert into t1 values (3) -master-bin.000001 515 Xid 1 542 COMMIT /* XID */ -master-bin.000001 542 Query 1 618 use `test`; drop table t1 -reset master; -create table t1(n int) engine=myisam; -begin; -insert into t1 values (4); -insert into t1 values (5); -insert into t1 values (6); -commit; -drop table t1; -show binlog events from 0; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 98 Server version, Binlog ver: 4 -master-bin.000001 98 Query 1 197 use `test`; create table t1(n int) engine=myisam -master-bin.000001 197 Query 1 285 use `test`; insert into t1 values (4) -master-bin.000001 285 Query 1 373 use `test`; insert into t1 values (5) -master-bin.000001 373 Query 1 461 use `test`; insert into t1 values (6) -master-bin.000001 461 Query 1 537 use `test`; drop table t1 -set autocommit= 1; -reset master; -create table t1(n int) engine=innodb; -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 197 -insert into t1 values (1); -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 312 -insert into t1 values (2); -insert into t1 values (3); -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 542 -commit; -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 542 -drop table t1; -show binlog events from 0; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 98 Server version, Binlog ver: 4 -master-bin.000001 98 Query 1 197 use `test`; create table t1(n int) engine=innodb -master-bin.000001 197 Query 1 285 use `test`; insert into t1 values (1) -master-bin.000001 285 Xid 1 312 COMMIT /* XID */ -master-bin.000001 312 Query 1 400 use `test`; insert into t1 values (2) -master-bin.000001 400 Xid 1 427 COMMIT /* XID */ -master-bin.000001 427 Query 1 515 use `test`; insert into t1 values (3) -master-bin.000001 515 Xid 1 542 COMMIT /* XID */ -master-bin.000001 542 Query 1 618 use `test`; drop table t1 -set autocommit= 0; -reset master; -create table t1(n int) engine=myisam; -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 197 -insert into t1 values (4); -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 285 -insert into t1 values (5); -insert into t1 values (6); -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 461 -commit; -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 461 -drop table t1; -show binlog events from 0; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 98 Server version, Binlog ver: 4 -master-bin.000001 98 Query 1 197 use `test`; create table t1(n int) engine=myisam -master-bin.000001 197 Query 1 285 use `test`; insert into t1 values (4) -master-bin.000001 285 Query 1 373 use `test`; insert into t1 values (5) -master-bin.000001 373 Query 1 461 use `test`; insert into t1 values (6) -master-bin.000001 461 Query 1 537 use `test`; drop table t1 -set session autocommit = @ac; set @bcs = @@binlog_cache_size; -set @ac = @@autocommit; set global binlog_cache_size=4096; -set autocommit= 0; reset master; create table t1 (a int) engine=innodb; show binlog events from 0; diff --git a/mysql-test/t/binlog.test b/mysql-test/t/binlog.test index b9996a2b380..5d1399925c3 100644 --- a/mysql-test/t/binlog.test +++ b/mysql-test/t/binlog.test @@ -78,72 +78,11 @@ drop table t1; --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/ show binlog events from 0; -set autocommit= 1; -reset master; -create table t1(n int) engine=innodb; -insert into t1 values (1); -insert into t1 values (2); -insert into t1 values (3); -commit; -drop table t1; ---replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/ -show binlog events from 0; - -reset master; -create table t1(n int) engine=myisam; -begin; -insert into t1 values (4); -insert into t1 values (5); -insert into t1 values (6); -commit; -drop table t1; ---replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/ -show binlog events from 0; - -# now show this also works for SHOW MASTER STATUS -# as this is what "mysqldump --master-data=1" uses. - -set autocommit= 1; -reset master; -create table t1(n int) engine=innodb; -show master status; -insert into t1 values (1); -show master status; -insert into t1 values (2); -insert into t1 values (3); -show master status; -commit; -show master status; -drop table t1; ---replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/ -show binlog events from 0; - -set autocommit= 0; -reset master; -create table t1(n int) engine=myisam; -show master status; -insert into t1 values (4); -show master status; -insert into t1 values (5); -insert into t1 values (6); - -show master status; -commit; -show master status; -drop table t1; ---replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/ -show binlog events from 0; - -set session autocommit = @ac; - # now show that nothing breaks if we need to read from the cache more # than once, resulting in split event-headers set @bcs = @@binlog_cache_size; -set @ac = @@autocommit; - set global binlog_cache_size=4096; -set autocommit= 0; reset master; create table t1 (a int) engine=innodb; diff --git a/sql/log.cc b/sql/log.cc index bcaf352f620..164dbd0d2d5 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1965,14 +1965,14 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event) } /* - Adjust hdr_offs. Note that this doesn't mean it will necessarily - be valid in the next iteration; if the current event is very long, - it may take a couple of read-iterations (and subsequent fixings - of hdr_offs) for it to become valid again. - if we had a split header, hdr_offs was already fixed above. + Adjust hdr_offs. Note that it may still point beyond the segment + read in the next iteration; if the current event is very long, + it may take a couple of read-iterations (and subsequent adjustments + of hdr_offs) for it to point into the then-current segment. + If we have a split header (!carry), hdr_offs will be set at the + beginning of the next iteration, overwriting the value we set here: */ - if (carry == 0) - hdr_offs -= length; + hdr_offs -= length; } /* Write data to the binary log file */ @@ -1982,6 +1982,8 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event) DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;); } while ((length=my_b_fill(cache))); + DBUG_ASSERT(carry == 0); + if (commit_event->write(&log_file)) goto err; #ifndef DBUG_OFF