Commit c5c49716 authored by unknown's avatar unknown

post-review fixes. Now ROLLBACK is done in Format_description_log_event


mysql-test/t/mix_innodb_myisam_binlog.test:
  fix for --ps-protocol
parent 98db5e57
...@@ -1171,11 +1171,10 @@ static int dump_local_log_entries(const char* logname) ...@@ -1171,11 +1171,10 @@ static int dump_local_log_entries(const char* logname)
{ {
/* /*
if binlog wasn't closed properly ("in use" flag is set) don't complain if binlog wasn't closed properly ("in use" flag is set) don't complain
about a corruption, but issue a "ROLLBACK" to annihilate half-logged about a corruption, but treat it as EOF and move to the next binlog.
transaction. Otherwise, treat it as EOF and move to the next binlog.
*/ */
if (description_event->flags & LOG_EVENT_BINLOG_IN_USE_F) if (description_event->flags & LOG_EVENT_BINLOG_IN_USE_F)
fprintf(result_file, "ROLLBACK;\n"); file->error= 0;
else if (file->error) else if (file->error)
{ {
fprintf(stderr, fprintf(stderr,
......
...@@ -527,8 +527,8 @@ show binlog events from 96; ...@@ -527,8 +527,8 @@ show binlog events from 96;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 96 User var 1 136 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci master-bin.000001 96 User var 1 136 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci
master-bin.000001 136 Query 1 226 use `test`; insert into t2 values (@v) master-bin.000001 136 Query 1 226 use `test`; insert into t2 values (@v)
flush logs;
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`; SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`;
use test; use test;
SET TIMESTAMP=10000; SET TIMESTAMP=10000;
......
...@@ -15,6 +15,7 @@ flush logs; ...@@ -15,6 +15,7 @@ flush logs;
--- Local -- --- Local --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1000000000; SET TIMESTAMP=1000000000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -47,6 +48,7 @@ insert into t1 values ("Alas"); ...@@ -47,6 +48,7 @@ insert into t1 values ("Alas");
--- --database -- --- --database --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1; SET INSERT_ID=1;
--- --position -- --- --position --
...@@ -60,6 +62,7 @@ insert into t1 values ("Alas"); ...@@ -60,6 +62,7 @@ insert into t1 values ("Alas");
--- Remote -- --- Remote --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1000000000; SET TIMESTAMP=1000000000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -92,6 +95,7 @@ insert into t1 values ("Alas"); ...@@ -92,6 +95,7 @@ insert into t1 values ("Alas");
--- --database -- --- --database --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1; SET INSERT_ID=1;
--- --position -- --- --position --
...@@ -105,13 +109,12 @@ insert into t1 values ("Alas"); ...@@ -105,13 +109,12 @@ insert into t1 values ("Alas");
--- reading stdin -- --- reading stdin --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1065204671; SET TIMESTAMP=1065204671;
BEGIN; BEGIN;
ROLLBACK;
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
use test; use test;
SET TIMESTAMP=1065204671; SET TIMESTAMP=1065204671;
BEGIN; BEGIN;
ROLLBACK;
drop table t1, t2; drop table t1, t2;
...@@ -16,6 +16,7 @@ insert into t1 values(null, "f"); ...@@ -16,6 +16,7 @@ insert into t1 values(null, "f");
--- Local -- --- Local --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -40,6 +41,7 @@ insert into t1 values(null, "e"); ...@@ -40,6 +41,7 @@ insert into t1 values(null, "e");
--- offset -- --- offset --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1; SET INSERT_ID=1;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
...@@ -75,6 +77,7 @@ insert into t1 values(null, "e"); ...@@ -75,6 +77,7 @@ insert into t1 values(null, "e");
--- stop-position -- --- stop-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -93,6 +96,7 @@ insert into t1 values(null, "c"); ...@@ -93,6 +96,7 @@ insert into t1 values(null, "c");
--- start-datetime -- --- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=3; SET INSERT_ID=3;
use test; use test;
SET TIMESTAMP=1579609944; SET TIMESTAMP=1579609944;
...@@ -109,6 +113,7 @@ insert into t1 values(null, "e"); ...@@ -109,6 +113,7 @@ insert into t1 values(null, "e");
--- stop-datetime -- --- stop-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -124,6 +129,7 @@ insert into t1 values(null, "b"); ...@@ -124,6 +129,7 @@ insert into t1 values(null, "b");
--- Local with 2 binlogs on command line -- --- Local with 2 binlogs on command line --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -152,10 +158,10 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq ...@@ -152,10 +158,10 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0; SET @@session.sql_mode=0;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
insert into t1 values(null, "f"); insert into t1 values(null, "f");
ROLLBACK;
--- offset -- --- offset --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1; SET INSERT_ID=1;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
...@@ -182,7 +188,6 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq ...@@ -182,7 +188,6 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0; SET @@session.sql_mode=0;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
insert into t1 values(null, "f"); insert into t1 values(null, "f");
ROLLBACK;
--- start-position -- --- start-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
...@@ -203,10 +208,10 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq ...@@ -203,10 +208,10 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0; SET @@session.sql_mode=0;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
insert into t1 values(null, "f"); insert into t1 values(null, "f");
ROLLBACK;
--- stop-position -- --- stop-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -232,6 +237,7 @@ SET INSERT_ID=6; ...@@ -232,6 +237,7 @@ SET INSERT_ID=6;
--- start-datetime -- --- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=3; SET INSERT_ID=3;
use test; use test;
SET TIMESTAMP=1579609944; SET TIMESTAMP=1579609944;
...@@ -252,10 +258,10 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq ...@@ -252,10 +258,10 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq
SET @@session.sql_mode=0; SET @@session.sql_mode=0;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
insert into t1 values(null, "f"); insert into t1 values(null, "f");
ROLLBACK;
--- stop-datetime -- --- stop-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -271,6 +277,7 @@ insert into t1 values(null, "b"); ...@@ -271,6 +277,7 @@ insert into t1 values(null, "b");
--- Remote -- --- Remote --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -295,6 +302,7 @@ insert into t1 values(null, "e"); ...@@ -295,6 +302,7 @@ insert into t1 values(null, "e");
--- offset -- --- offset --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1; SET INSERT_ID=1;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
...@@ -330,6 +338,7 @@ insert into t1 values(null, "e"); ...@@ -330,6 +338,7 @@ insert into t1 values(null, "e");
--- stop-position -- --- stop-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -348,6 +357,7 @@ insert into t1 values(null, "c"); ...@@ -348,6 +357,7 @@ insert into t1 values(null, "c");
--- start-datetime -- --- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=3; SET INSERT_ID=3;
use test; use test;
SET TIMESTAMP=1579609944; SET TIMESTAMP=1579609944;
...@@ -364,6 +374,7 @@ insert into t1 values(null, "e"); ...@@ -364,6 +374,7 @@ insert into t1 values(null, "e");
--- stop-datetime -- --- stop-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -379,6 +390,7 @@ insert into t1 values(null, "b"); ...@@ -379,6 +390,7 @@ insert into t1 values(null, "b");
--- Remote with 2 binlogs on command line -- --- Remote with 2 binlogs on command line --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -410,6 +422,7 @@ insert into t1 values(null, "f"); ...@@ -410,6 +422,7 @@ insert into t1 values(null, "f");
--- offset -- --- offset --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=1; SET INSERT_ID=1;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
...@@ -459,6 +472,7 @@ insert into t1 values(null, "f"); ...@@ -459,6 +472,7 @@ insert into t1 values(null, "f");
--- stop-position -- --- stop-position --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -484,6 +498,7 @@ SET INSERT_ID=6; ...@@ -484,6 +498,7 @@ SET INSERT_ID=6;
--- start-datetime -- --- start-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET INSERT_ID=3; SET INSERT_ID=3;
use test; use test;
SET TIMESTAMP=1579609944; SET TIMESTAMP=1579609944;
...@@ -507,6 +522,7 @@ insert into t1 values(null, "f"); ...@@ -507,6 +522,7 @@ insert into t1 values(null, "f");
--- stop-datetime -- --- stop-datetime --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
...@@ -522,6 +538,7 @@ insert into t1 values(null, "b"); ...@@ -522,6 +538,7 @@ insert into t1 values(null, "b");
--- to-last-log -- --- to-last-log --
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test; use test;
SET TIMESTAMP=1579609942; SET TIMESTAMP=1579609942;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
......
...@@ -175,6 +175,7 @@ select hex(c1), hex(c2) from t1; ...@@ -175,6 +175,7 @@ select hex(c1), hex(c2) from t1;
hex(c1) hex(c2) hex(c1) hex(c2)
CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET TIMESTAMP=1000000000; SET TIMESTAMP=1000000000;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
SET @@session.sql_mode=0; SET @@session.sql_mode=0;
...@@ -244,5 +245,4 @@ CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255)); ...@@ -244,5 +245,4 @@ CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255));
SET TIMESTAMP=1000000000; SET TIMESTAMP=1000000000;
SET @@session.character_set_client=7,@@session.collation_connection=51,@@session.collation_server=30; SET @@session.character_set_client=7,@@session.collation_connection=51,@@session.collation_server=30;
INSERT INTO t1 (c1, c2) VALUES (', ',', '); INSERT INTO t1 (c1, c2) VALUES (', ',', ');
ROLLBACK;
drop table t1; drop table t1;
...@@ -181,8 +181,8 @@ master-bin.000001 137 Query 1 230 use `test`; INSERT INTO t1 VALUES(@`a b`) ...@@ -181,8 +181,8 @@ master-bin.000001 137 Query 1 230 use `test`; INSERT INTO t1 VALUES(@`a b`)
master-bin.000001 230 User var 1 272 @`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci master-bin.000001 230 User var 1 272 @`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci
master-bin.000001 272 User var 1 310 @`var2`=_latin1 0x61 COLLATE latin1_swedish_ci master-bin.000001 272 User var 1 310 @`var2`=_latin1 0x61 COLLATE latin1_swedish_ci
master-bin.000001 310 Query 1 411 use `test`; insert into t1 values (@var1),(@var2) master-bin.000001 310 Query 1 411 use `test`; insert into t1 values (@var1),(@var2)
flush logs;
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`; SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`;
use test; use test;
SET TIMESTAMP=10000; SET TIMESTAMP=10000;
......
...@@ -339,7 +339,6 @@ set @v=convert('abc' using ucs2); ...@@ -339,7 +339,6 @@ set @v=convert('abc' using ucs2);
reset master; reset master;
insert into t2 values (@v); insert into t2 values (@v);
show binlog events from 96; show binlog events from 96;
flush logs;
# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
# absolutely need variables names to be quoted and strings to be # absolutely need variables names to be quoted and strings to be
# escaped). # escaped).
......
...@@ -26,6 +26,7 @@ insert into t2 select * from t1; ...@@ -26,6 +26,7 @@ insert into t2 select * from t1;
commit; commit;
--replace_column 5 # --replace_column 5 #
--replace_result "xid=12" "xid=7"
show binlog events from 96; show binlog events from 96;
delete from t1; delete from t1;
...@@ -54,6 +55,7 @@ rollback to savepoint my_savepoint; ...@@ -54,6 +55,7 @@ rollback to savepoint my_savepoint;
commit; commit;
--replace_column 5 # --replace_column 5 #
--replace_result "xid=45" "xid=24"
show binlog events from 96; show binlog events from 96;
delete from t1; delete from t1;
...@@ -71,6 +73,7 @@ commit; ...@@ -71,6 +73,7 @@ commit;
select a from t1 order by a; # check that savepoints work :) select a from t1 order by a; # check that savepoints work :)
--replace_column 5 # --replace_column 5 #
--replace_result "xid=67" "xid=36"
show binlog events from 96; show binlog events from 96;
# and when ROLLBACK is not explicit? # and when ROLLBACK is not explicit?
...@@ -103,6 +106,7 @@ insert into t1 values(9); ...@@ -103,6 +106,7 @@ insert into t1 values(9);
insert into t2 select * from t1; insert into t2 select * from t1;
--replace_column 5 # --replace_column 5 #
--replace_result "xid=116" "xid=59"
show binlog events from 96; show binlog events from 96;
# Check that when the query updat1ng the MyISAM table is the first in the # Check that when the query updat1ng the MyISAM table is the first in the
...@@ -115,11 +119,13 @@ insert into t1 values(10); # first make t1 non-empty ...@@ -115,11 +119,13 @@ insert into t1 values(10); # first make t1 non-empty
begin; begin;
insert into t2 select * from t1; insert into t2 select * from t1;
--replace_column 5 # --replace_column 5 #
--replace_result "xid=130" "xid=65"
show binlog events from 96; show binlog events from 96;
insert into t1 values(11); insert into t1 values(11);
commit; commit;
--replace_column 5 # --replace_column 5 #
--replace_result "xid=130" "xid=65" "xid=133" "xid=67"
show binlog events from 96; show binlog events from 96;
...@@ -138,6 +144,7 @@ insert into t2 select * from t1; ...@@ -138,6 +144,7 @@ insert into t2 select * from t1;
commit; commit;
--replace_column 5 # --replace_column 5 #
--replace_result "xid=152" "xid=77"
show binlog events from 96; show binlog events from 96;
delete from t1; delete from t1;
...@@ -165,6 +172,7 @@ rollback to savepoint my_savepoint; ...@@ -165,6 +172,7 @@ rollback to savepoint my_savepoint;
commit; commit;
--replace_column 5 # --replace_column 5 #
--replace_result "xid=184" "xid=93"
show binlog events from 96; show binlog events from 96;
delete from t1; delete from t1;
...@@ -182,6 +190,7 @@ commit; ...@@ -182,6 +190,7 @@ commit;
select a from t1 order by a; # check that savepoints work :) select a from t1 order by a; # check that savepoints work :)
--replace_column 5 # --replace_column 5 #
--replace_result "xid=205" "xid=104"
show binlog events from 96; show binlog events from 96;
# Test for BUG#5714, where a MyISAM update in the transaction used to # Test for BUG#5714, where a MyISAM update in the transaction used to
......
...@@ -111,7 +111,6 @@ set @var1= "';aaa"; ...@@ -111,7 +111,6 @@ set @var1= "';aaa";
SET @var2=char(ascii('a')); SET @var2=char(ascii('a'));
insert into t1 values (@var1),(@var2); insert into t1 values (@var1),(@var2);
show binlog events from 96; show binlog events from 96;
flush logs;
# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
# absolutely need variables names to be quoted and strings to be # absolutely need variables names to be quoted and strings to be
# escaped). # escaped).
......
...@@ -403,18 +403,18 @@ int Log_event::exec_event(struct st_relay_log_info* rli) ...@@ -403,18 +403,18 @@ int Log_event::exec_event(struct st_relay_log_info* rli)
only in the case discussed above, 'if (rli)' is useless here. only in the case discussed above, 'if (rli)' is useless here.
But as we are not 100% sure, keep it for now. But as we are not 100% sure, keep it for now.
*/ */
if (rli) if (rli)
{ {
/* /*
If in a transaction, and if the slave supports transactions, just If in a transaction, and if the slave supports transactions, just
inc_event_relay_log_pos(). We only have to check for OPTION_BEGIN inc_event_relay_log_pos(). We only have to check for OPTION_BEGIN
(not OPTION_NOT_AUTOCOMMIT) as transactions are logged with (not OPTION_NOT_AUTOCOMMIT) as transactions are logged with
BEGIN/COMMIT, not with SET AUTOCOMMIT= . BEGIN/COMMIT, not with SET AUTOCOMMIT= .
CAUTION: opt_using_transactions means CAUTION: opt_using_transactions means
innodb || bdb ; suppose the master supports InnoDB and BDB, innodb || bdb ; suppose the master supports InnoDB and BDB,
but the slave supports only BDB, problems but the slave supports only BDB, problems
will arise: will arise:
- suppose an InnoDB table is created on the master, - suppose an InnoDB table is created on the master,
- then it will be MyISAM on the slave - then it will be MyISAM on the slave
- but as opt_using_transactions is true, the slave will believe he - but as opt_using_transactions is true, the slave will believe he
...@@ -930,8 +930,8 @@ void Query_log_event::pack_info(Protocol *protocol) ...@@ -930,8 +930,8 @@ void Query_log_event::pack_info(Protocol *protocol)
char *buf, *pos; char *buf, *pos;
if (!(buf= my_malloc(9 + db_len + q_len, MYF(MY_WME)))) if (!(buf= my_malloc(9 + db_len + q_len, MYF(MY_WME))))
return; return;
pos= buf; pos= buf;
if (!(flags & LOG_EVENT_SUPPRESS_USE_F) if (!(flags & LOG_EVENT_SUPPRESS_USE_F)
&& db && db_len) && db && db_len)
{ {
pos= strmov(buf, "use `"); pos= strmov(buf, "use `");
...@@ -1595,7 +1595,7 @@ Default database: '%s'. Query: '%s'", ...@@ -1595,7 +1595,7 @@ Default database: '%s'. Query: '%s'",
We may also want an option to tell the slave to ignore "affected" We may also want an option to tell the slave to ignore "affected"
mismatch. This mismatch could be implemented with a new ER_ code, and mismatch. This mismatch could be implemented with a new ER_ code, and
to ignore it you would use --slave-skip-errors... to ignore it you would use --slave-skip-errors...
To do the comparison we need to know the value of "affected" which the To do the comparison we need to know the value of "affected" which the
above mysql_parse() computed. And we need to know the value of above mysql_parse() computed. And we need to know the value of
"affected" in the master's binlog. Both will be implemented later. The "affected" in the master's binlog. Both will be implemented later. The
...@@ -1682,14 +1682,20 @@ void Start_log_event_v3::print(FILE* file, bool short_form, LAST_EVENT_INFO* las ...@@ -1682,14 +1682,20 @@ void Start_log_event_v3::print(FILE* file, bool short_form, LAST_EVENT_INFO* las
fprintf(file," at startup"); fprintf(file," at startup");
fputc('\n', file); fputc('\n', file);
} }
if (!artificial_event && created)
{
#ifdef WHEN_WE_HAVE_THE_RESET_CONNECTION_SQL_COMMAND #ifdef WHEN_WE_HAVE_THE_RESET_CONNECTION_SQL_COMMAND
/* /*
This is for mysqlbinlog: like in replication, we want to delete the stale This is for mysqlbinlog: like in replication, we want to delete the stale
tmp files left by an unclean shutdown of mysqld (temporary tables). Probably tmp files left by an unclean shutdown of mysqld (temporary tables)
this can be done with RESET CONNECTION (syntax to be defined). and rollback unfinished transaction.
*/ Probably this can be done with RESET CONNECTION (syntax to be defined).
fprintf(file,"RESET CONNECTION;\n"); */
fprintf(file,"RESET CONNECTION;\n");
#else
fprintf(file,"ROLLBACK;\n");
#endif #endif
}
fflush(file); fflush(file);
} }
#endif /* MYSQL_CLIENT */ #endif /* MYSQL_CLIENT */
...@@ -1765,38 +1771,14 @@ int Start_log_event_v3::exec_event(struct st_relay_log_info* rli) ...@@ -1765,38 +1771,14 @@ int Start_log_event_v3::exec_event(struct st_relay_log_info* rli)
close_temporary_tables(thd); close_temporary_tables(thd);
cleanup_load_tmpdir(); cleanup_load_tmpdir();
} }
/*
As a transaction NEVER spans on 2 or more binlogs:
if we have an active transaction at this point, the master died
while writing the transaction to the binary log, i.e. while
flushing the binlog cache to the binlog. As the write was started,
the transaction had been committed on the master, so we lack of
information to replay this transaction on the slave; all we can do
is stop with error.
Note: this event could be sent by the master to inform us of the
format of its binlog; in other words maybe it is not at its
original place when it comes to us; we'll know this by checking
log_pos ("artificial" events have log_pos == 0).
TODO test whether it's really necessary, as slave.cc does ROLLBACK
itself
*/
if (!artificial_event && (thd->options & OPTION_BEGIN))
{
slave_print_error(rli, 0, "\
Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. \
A probable cause is that the master died while writing the transaction to its \
binary log.");
return(1);
}
break; break;
/* /*
Now the older formats; in that case load_tmpdir is cleaned up by the I/O Now the older formats; in that case load_tmpdir is cleaned up by the I/O
thread. thread.
*/ */
case 1: case 1:
if (strncmp(rli->relay_log.description_event_for_exec->server_version, if (strncmp(rli->relay_log.description_event_for_exec->server_version,
"3.23.57",7) >= 0 && created) "3.23.57",7) >= 0 && created)
{ {
/* /*
...@@ -1828,7 +1810,7 @@ binary log."); ...@@ -1828,7 +1810,7 @@ binary log.");
SYNOPSIS SYNOPSIS
Format_description_log_event::Format_description_log_event Format_description_log_event::Format_description_log_event
binlog_version the binlog version for which we want to build binlog_version the binlog version for which we want to build
an event. Can be 1 (=MySQL 3.23), 3 (=4.0.x an event. Can be 1 (=MySQL 3.23), 3 (=4.0.x
x>=2 and 4.1) or 4 (MySQL 5.0). Note that the x>=2 and 4.1) or 4 (MySQL 5.0). Note that the
old 4.0 (binlog version 2) is not supported; old 4.0 (binlog version 2) is not supported;
...@@ -1892,7 +1874,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) ...@@ -1892,7 +1874,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
else else
strmov(server_version, server_ver ? server_ver : "4.0"); strmov(server_version, server_ver ? server_ver : "4.0");
common_header_len= binlog_ver==1 ? OLD_HEADER_LEN : common_header_len= binlog_ver==1 ? OLD_HEADER_LEN :
LOG_EVENT_MINIMAL_HEADER_LEN; LOG_EVENT_MINIMAL_HEADER_LEN;
/* /*
The first new event in binlog version 4 is Format_desc. So any event type The first new event in binlog version 4 is Format_desc. So any event type
after that does not exist in older versions. We use the events known by after that does not exist in older versions. We use the events known by
...@@ -1902,7 +1884,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) ...@@ -1902,7 +1884,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
*/ */
number_of_event_types= FORMAT_DESCRIPTION_EVENT - 1; number_of_event_types= FORMAT_DESCRIPTION_EVENT - 1;
post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8), post_header_len=(uint8*) my_malloc(number_of_event_types*sizeof(uint8),
MYF(0)); MYF(0));
if (post_header_len) if (post_header_len)
{ {
post_header_len[START_EVENT_V3-1]= START_V3_HEADER_LEN; post_header_len[START_EVENT_V3-1]= START_V3_HEADER_LEN;
...@@ -1933,7 +1915,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver) ...@@ -1933,7 +1915,7 @@ Format_description_log_event(uint8 binlog_ver, const char* server_ver)
length different from this version, but we don't know this length as we length different from this version, but we don't know this length as we
have not read the Format_description_log_event which says it, yet. This have not read the Format_description_log_event which says it, yet. This
length is in the post-header of the event, but we don't know where the length is in the post-header of the event, but we don't know where the
post-header starts. post-header starts.
So this type of event HAS to: So this type of event HAS to:
- either have the header's length at the beginning (in the header, at a - either have the header's length at the beginning (in the header, at a
fixed position which will never be changed), not in the post-header. That fixed position which will never be changed), not in the post-header. That
...@@ -1949,7 +1931,7 @@ Format_description_log_event(const char* buf, ...@@ -1949,7 +1931,7 @@ Format_description_log_event(const char* buf,
uint event_len, uint event_len,
const const
Format_description_log_event* Format_description_log_event*
description_event) description_event)
:Start_log_event_v3(buf, description_event) :Start_log_event_v3(buf, description_event)
{ {
DBUG_ENTER("Format_description_log_event::Format_description_log_event(char*,...)"); DBUG_ENTER("Format_description_log_event::Format_description_log_event(char*,...)");
...@@ -1959,7 +1941,7 @@ Format_description_log_event(const char* buf, ...@@ -1959,7 +1941,7 @@ Format_description_log_event(const char* buf,
number_of_event_types= number_of_event_types=
event_len-(LOG_EVENT_MINIMAL_HEADER_LEN+ST_COMMON_HEADER_LEN_OFFSET+1); event_len-(LOG_EVENT_MINIMAL_HEADER_LEN+ST_COMMON_HEADER_LEN_OFFSET+1);
DBUG_PRINT("info", ("common_header_len=%d number_of_event_types=%d", DBUG_PRINT("info", ("common_header_len=%d number_of_event_types=%d",
common_header_len, number_of_event_types)); common_header_len, number_of_event_types));
/* If alloc fails, we'll detect it in is_valid() */ /* If alloc fails, we'll detect it in is_valid() */
post_header_len= (uint8*) my_memdup((byte*)buf+ST_COMMON_HEADER_LEN_OFFSET+1, post_header_len= (uint8*) my_memdup((byte*)buf+ST_COMMON_HEADER_LEN_OFFSET+1,
number_of_event_types* number_of_event_types*
...@@ -1978,17 +1960,17 @@ bool Format_description_log_event::write(IO_CACHE* file) ...@@ -1978,17 +1960,17 @@ bool Format_description_log_event::write(IO_CACHE* file)
int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version); int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version);
memcpy((char*) buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN); memcpy((char*) buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
int4store(buff + ST_CREATED_OFFSET,created); int4store(buff + ST_CREATED_OFFSET,created);
buff[ST_COMMON_HEADER_LEN_OFFSET]= LOG_EVENT_HEADER_LEN; buff[ST_COMMON_HEADER_LEN_OFFSET]= LOG_EVENT_HEADER_LEN;
memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (byte*) post_header_len, memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (byte*) post_header_len,
LOG_EVENT_TYPES); LOG_EVENT_TYPES);
return (write_header(file, sizeof(buff)) || return (write_header(file, sizeof(buff)) ||
my_b_safe_write(file, buff, sizeof(buff))); my_b_safe_write(file, buff, sizeof(buff)));
} }
/* /*
SYNOPSIS SYNOPSIS
Format_description_log_event::exec_event() Format_description_log_event::exec_event()
IMPLEMENTATION IMPLEMENTATION
Save the information which describes the binlog's format, to be able to Save the information which describes the binlog's format, to be able to
read all coming events. read all coming events.
...@@ -1999,11 +1981,32 @@ bool Format_description_log_event::write(IO_CACHE* file) ...@@ -1999,11 +1981,32 @@ bool Format_description_log_event::write(IO_CACHE* file)
int Format_description_log_event::exec_event(struct st_relay_log_info* rli) int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
{ {
DBUG_ENTER("Format_description_log_event::exec_event"); DBUG_ENTER("Format_description_log_event::exec_event");
/* save the information describing this binlog */ /* save the information describing this binlog */
delete rli->relay_log.description_event_for_exec; delete rli->relay_log.description_event_for_exec;
rli->relay_log.description_event_for_exec= this; rli->relay_log.description_event_for_exec= this;
/*
As a transaction NEVER spans on 2 or more binlogs:
if we have an active transaction at this point, the master died
while writing the transaction to the binary log, i.e. while
flushing the binlog cache to the binlog. As the write was started,
the transaction had been committed on the master, so we lack of
information to replay this transaction on the slave; all we can do
is stop with error.
Note: this event could be sent by the master to inform us of the
format of its binlog; in other words maybe it is not at its
original place when it comes to us; we'll know this by checking
log_pos ("artificial" events have log_pos == 0).
*/
if (!artificial_event && created && thd->transaction.all.nht)
{
slave_print_error(rli, 0, "Rolling back unfinished transaction (no "
"COMMIT or ROLLBACK) from relay log. A probable cause "
"is that the master died while writing the transaction "
"to its binary log.");
end_trans(thd, ROLLBACK);
}
/* /*
If this event comes from ourselves, there is no cleaning task to perform, If this event comes from ourselves, there is no cleaning task to perform,
we don't call Start_log_event_v3::exec_event() (this was just to update the we don't call Start_log_event_v3::exec_event() (this was just to update the
...@@ -2032,16 +2035,16 @@ int Format_description_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -2032,16 +2035,16 @@ int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
If the event was not requested by the slave i.e. the master sent it while If the event was not requested by the slave i.e. the master sent it while
the slave asked for a position >4, the event will make the slave asked for a position >4, the event will make
rli->group_master_log_pos advance. Say that the slave asked for position rli->group_master_log_pos advance. Say that the slave asked for position
1000, and the Format_desc event's end is 95. Then in the beginning of 1000, and the Format_desc event's end is 96. Then in the beginning of
replication rli->group_master_log_pos will be 0, then 95, then jump to first replication rli->group_master_log_pos will be 0, then 96, then jump to
really asked event (which is >95). So this is ok. first really asked event (which is >96). So this is ok.
*/ */
DBUG_RETURN(Start_log_event_v3::exec_event(rli)); DBUG_RETURN(Start_log_event_v3::exec_event(rli));
} }
#endif #endif
/************************************************************************** /**************************************************************************
Load_log_event methods Load_log_event methods
General note about Load_log_event: the binlogging of LOAD DATA INFILE is General note about Load_log_event: the binlogging of LOAD DATA INFILE is
going to be changed in 5.0 (or maybe in 5.1; not decided yet). going to be changed in 5.0 (or maybe in 5.1; not decided yet).
However, the 5.0 slave could still have to read such events (from a 4.x However, the 5.0 slave could still have to read such events (from a 4.x
...@@ -2067,7 +2070,7 @@ void Load_log_event::pack_info(Protocol *protocol) ...@@ -2067,7 +2070,7 @@ void Load_log_event::pack_info(Protocol *protocol)
char *buf, *pos; char *buf, *pos;
uint buf_len; uint buf_len;
buf_len= buf_len=
5 + db_len + 3 + // "use DB; " 5 + db_len + 3 + // "use DB; "
18 + fname_len + 2 + // "LOAD DATA INFILE 'file''" 18 + fname_len + 2 + // "LOAD DATA INFILE 'file''"
7 + // LOCAL 7 + // LOCAL
...@@ -2077,8 +2080,8 @@ void Load_log_event::pack_info(Protocol *protocol) ...@@ -2077,8 +2080,8 @@ void Load_log_event::pack_info(Protocol *protocol)
23 + sql_ex.enclosed_len*4 + 2 + // " OPTIONALLY ENCLOSED BY 'str'" 23 + sql_ex.enclosed_len*4 + 2 + // " OPTIONALLY ENCLOSED BY 'str'"
12 + sql_ex.escaped_len*4 + 2 + // " ESCAPED BY 'str'" 12 + sql_ex.escaped_len*4 + 2 + // " ESCAPED BY 'str'"
21 + sql_ex.line_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'" 21 + sql_ex.line_term_len*4 + 2 + // " FIELDS TERMINATED BY 'str'"
19 + sql_ex.line_start_len*4 + 2 + // " LINES STARTING BY 'str'" 19 + sql_ex.line_start_len*4 + 2 + // " LINES STARTING BY 'str'"
15 + 22 + // " IGNORE xxx LINES" 15 + 22 + // " IGNORE xxx LINES"
3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)" 3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)"
if (!(buf= my_malloc(buf_len, MYF(MY_WME)))) if (!(buf= my_malloc(buf_len, MYF(MY_WME))))
...@@ -3134,9 +3137,7 @@ int Xid_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -3134,9 +3137,7 @@ int Xid_log_event::exec_event(struct st_relay_log_info* rli)
{ {
rli->inc_event_relay_log_pos(); rli->inc_event_relay_log_pos();
/* For a slave Xid_log_event is COMMIT */ /* For a slave Xid_log_event is COMMIT */
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); return end_trans(thd, COMMIT);
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
return ha_commit(thd);
} }
#endif /* !MYSQL_CLIENT */ #endif /* !MYSQL_CLIENT */
...@@ -3516,7 +3517,7 @@ Slave_log_event::Slave_log_event(THD* thd_arg, ...@@ -3516,7 +3517,7 @@ Slave_log_event::Slave_log_event(THD* thd_arg,
DBUG_ENTER("Slave_log_event"); DBUG_ENTER("Slave_log_event");
if (!rli->inited) // QQ When can this happen ? if (!rli->inited) // QQ When can this happen ?
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
MASTER_INFO* mi = rli->mi; MASTER_INFO* mi = rli->mi;
// TODO: re-write this better without holding both locks at the same time // TODO: re-write this better without holding both locks at the same time
pthread_mutex_lock(&mi->data_lock); pthread_mutex_lock(&mi->data_lock);
...@@ -3650,7 +3651,7 @@ void Stop_log_event::print(FILE* file, bool short_form, LAST_EVENT_INFO* last_ev ...@@ -3650,7 +3651,7 @@ void Stop_log_event::print(FILE* file, bool short_form, LAST_EVENT_INFO* last_ev
/* /*
Stop_log_event::exec_event() Stop_log_event::exec_event()
The master stopped. The master stopped.
We used to clean up all temporary tables but this is useless as, as the We used to clean up all temporary tables but this is useless as, as the
master has shut down properly, it has written all DROP TEMPORARY TABLE and DO master has shut down properly, it has written all DROP TEMPORARY TABLE and DO
RELEASE_LOCK (prepared statements' deletion is TODO). RELEASE_LOCK (prepared statements' deletion is TODO).
......
...@@ -312,14 +312,14 @@ struct sql_ex_info ...@@ -312,14 +312,14 @@ struct sql_ex_info
small chance that mysqld crashes in the middle of insert and end of small chance that mysqld crashes in the middle of insert and end of
the binlog would look like a Stop_log_event). the binlog would look like a Stop_log_event).
This flag is used to detect a restart after a crash, This flag is used to detect a restart after a crash, and to provide
and to provide "unbreakable" binlog. The problem is that on a crash "unbreakable" binlog. The problem is that on a crash storage engines
storage engines rollback automatically, while binlog does not. rollback automatically, while binlog does not. To solve this we use this
To solve this we use this flag and automatically append ROLLBACK flag and automatically append ROLLBACK to every non-closed binlog (append
to every non-closed binlog (append virtually, on reading, file itself virtually, on reading, file itself is not changed). If this flag is found,
is not changed). If this flag is found, mysqlbinlog simply prints "ROLLBACK" mysqlbinlog simply prints "ROLLBACK" Replication master does not abort on
Replication master does not abort on binlog corruption, but takes it as EOF, binlog corruption, but takes it as EOF, and replication slave forces a
and replication slave forces a rollback in this case (see below). rollback in this case.
Note, that old binlogs does not have this flag set, so we get a Note, that old binlogs does not have this flag set, so we get a
a backward-compatible behaviour. a backward-compatible behaviour.
...@@ -327,16 +327,6 @@ struct sql_ex_info ...@@ -327,16 +327,6 @@ struct sql_ex_info
#define LOG_EVENT_BINLOG_IN_USE_F 0x1 #define LOG_EVENT_BINLOG_IN_USE_F 0x1
/*
This flag is only used for fake Rotate_log_event. When a master, doing
binlog dump, reaches the end of the binlog and fakes a rotate to make
the slave to go to a new file, this flag is used if there was no
"natural" Rotate_log_event.
If this flag is set, slave will execute ROLLBACK before going further
*/
#define LOG_EVENT_FORCE_ROLLBACK_F 0x1
/* /*
If the query depends on the thread (for example: TEMPORARY TABLE). If the query depends on the thread (for example: TEMPORARY TABLE).
Currently this is used by mysqlbinlog to know it must print Currently this is used by mysqlbinlog to know it must print
...@@ -903,8 +893,8 @@ class Start_log_event_v3: public Log_event ...@@ -903,8 +893,8 @@ class Start_log_event_v3: public Log_event
binary log) was created. In the other case (i.e. this event is at binary log) was created. In the other case (i.e. this event is at
the start of a binary log created by FLUSH LOGS or automatic the start of a binary log created by FLUSH LOGS or automatic
rotation), 'created' should be 0. This "trick" is used by MySQL rotation), 'created' should be 0. This "trick" is used by MySQL
>=4.0.14 slaves to know if they must drop the stale temporary >=4.0.14 slaves to know whether they must drop stale temporary
tables or not. tables and whether they should abort unfinished transaction.
Note that when 'created'!=0, it is always equal to the event's Note that when 'created'!=0, it is always equal to the event's
timestamp; indeed Start_log_event is written only in log.cc where timestamp; indeed Start_log_event is written only in log.cc where
......
...@@ -456,6 +456,14 @@ bool delete_precheck(THD *thd, TABLE_LIST *tables); ...@@ -456,6 +456,14 @@ bool delete_precheck(THD *thd, TABLE_LIST *tables);
bool insert_precheck(THD *thd, TABLE_LIST *tables); bool insert_precheck(THD *thd, TABLE_LIST *tables);
bool create_table_precheck(THD *thd, TABLE_LIST *tables, bool create_table_precheck(THD *thd, TABLE_LIST *tables,
TABLE_LIST *create_table); TABLE_LIST *create_table);
enum enum_mysql_completiontype {
ROLLBACK_RELEASE=-2, ROLLBACK=1, ROLLBACK_AND_CHAIN=7,
COMMIT_RELEASE=-1, COMMIT=0, COMMIT_AND_CHAIN=6
};
int end_trans(THD *thd, enum enum_mysql_completiontype completion);
Item *negate_expression(THD *thd, Item *expr); Item *negate_expression(THD *thd, Item *expr);
#include "sql_class.h" #include "sql_class.h"
#include "sql_acl.h" #include "sql_acl.h"
......
...@@ -1722,7 +1722,7 @@ static int init_relay_log_info(RELAY_LOG_INFO* rli, ...@@ -1722,7 +1722,7 @@ static int init_relay_log_info(RELAY_LOG_INFO* rli,
if (rli->relay_log.open_index_file(opt_relaylog_index_name, ln) || if (rli->relay_log.open_index_file(opt_relaylog_index_name, ln) ||
rli->relay_log.open(ln, LOG_BIN, 0, SEQ_READ_APPEND, 0, rli->relay_log.open(ln, LOG_BIN, 0, SEQ_READ_APPEND, 0,
(max_relay_log_size ? max_relay_log_size : (max_relay_log_size ? max_relay_log_size :
max_binlog_size), 0)) max_binlog_size), 1))
{ {
pthread_mutex_unlock(&rli->data_lock); pthread_mutex_unlock(&rli->data_lock);
sql_print_error("Failed in open_log() called from init_relay_log_info()"); sql_print_error("Failed in open_log() called from init_relay_log_info()");
...@@ -3111,17 +3111,17 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -3111,17 +3111,17 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
{ {
/* /*
We acquire this mutex since we need it for all operations except We acquire this mutex since we need it for all operations except
event execution. But we will release it in places where we will event execution. But we will release it in places where we will
wait for something for example inside of next_event(). wait for something for example inside of next_event().
*/ */
pthread_mutex_lock(&rli->data_lock); pthread_mutex_lock(&rli->data_lock);
if (rli->until_condition!=RELAY_LOG_INFO::UNTIL_NONE && if (rli->until_condition!=RELAY_LOG_INFO::UNTIL_NONE &&
rli->is_until_satisfied()) rli->is_until_satisfied())
{ {
sql_print_error("Slave SQL thread stopped because it reached its" sql_print_error("Slave SQL thread stopped because it reached its"
" UNTIL position %ld", (long) rli->until_pos()); " UNTIL position %ld", (long) rli->until_pos());
/* /*
Setting abort_slave flag because we do not want additional message about Setting abort_slave flag because we do not want additional message about
error in query execution to be printed. error in query execution to be printed.
*/ */
...@@ -3129,11 +3129,11 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -3129,11 +3129,11 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
pthread_mutex_unlock(&rli->data_lock); pthread_mutex_unlock(&rli->data_lock);
return 1; return 1;
} }
Log_event * ev = next_event(rli); Log_event * ev = next_event(rli);
DBUG_ASSERT(rli->sql_thd==thd); DBUG_ASSERT(rli->sql_thd==thd);
if (sql_slave_killed(thd,rli)) if (sql_slave_killed(thd,rli))
{ {
pthread_mutex_unlock(&rli->data_lock); pthread_mutex_unlock(&rli->data_lock);
...@@ -3158,13 +3158,13 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -3158,13 +3158,13 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
events created by the creation/rotation of the relay log (remember that events created by the creation/rotation of the relay log (remember that
now the relay log starts with its Format_desc, has a Rotate etc). now the relay log starts with its Format_desc, has a Rotate etc).
*/ */
DBUG_PRINT("info",("type_code=%d, server_id=%d",type_code,ev->server_id)); DBUG_PRINT("info",("type_code=%d, server_id=%d",type_code,ev->server_id));
if ((ev->server_id == (uint32) ::server_id && if ((ev->server_id == (uint32) ::server_id &&
!replicate_same_server_id && !replicate_same_server_id &&
type_code != FORMAT_DESCRIPTION_EVENT) || type_code != FORMAT_DESCRIPTION_EVENT) ||
(rli->slave_skip_counter && (rli->slave_skip_counter &&
type_code != ROTATE_EVENT && type_code != STOP_EVENT && type_code != ROTATE_EVENT && type_code != STOP_EVENT &&
type_code != START_EVENT_V3 && type_code!= FORMAT_DESCRIPTION_EVENT)) type_code != START_EVENT_V3 && type_code!= FORMAT_DESCRIPTION_EVENT))
{ {
...@@ -3173,24 +3173,24 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -3173,24 +3173,24 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
rli->inc_event_relay_log_pos(); rli->inc_event_relay_log_pos();
else else
{ {
rli->inc_group_relay_log_pos((type_code == ROTATE_EVENT || rli->inc_group_relay_log_pos((type_code == ROTATE_EVENT ||
type_code == STOP_EVENT || type_code == STOP_EVENT ||
type_code == FORMAT_DESCRIPTION_EVENT) ? type_code == FORMAT_DESCRIPTION_EVENT) ?
LL(0) : ev->log_pos, LL(0) : ev->log_pos,
1/* skip lock*/); 1/* skip lock*/);
flush_relay_log_info(rli); flush_relay_log_info(rli);
} }
/* /*
Protect against common user error of setting the counter to 1 Protect against common user error of setting the counter to 1
instead of 2 while recovering from an insert which used auto_increment, instead of 2 while recovering from an insert which used auto_increment,
rand or user var. rand or user var.
*/ */
if (rli->slave_skip_counter && if (rli->slave_skip_counter &&
!((type_code == INTVAR_EVENT || !((type_code == INTVAR_EVENT ||
type_code == RAND_EVENT || type_code == RAND_EVENT ||
type_code == USER_VAR_EVENT) && type_code == USER_VAR_EVENT) &&
rli->slave_skip_counter == 1) && rli->slave_skip_counter == 1) &&
/* /*
The events from ourselves which have something to do with the relay The events from ourselves which have something to do with the relay
log itself must be skipped, true, but they mustn't decrement log itself must be skipped, true, but they mustn't decrement
...@@ -3205,34 +3205,20 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -3205,34 +3205,20 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
type_code == START_EVENT_V3 || type_code == FORMAT_DESCRIPTION_EVENT))) type_code == START_EVENT_V3 || type_code == FORMAT_DESCRIPTION_EVENT)))
--rli->slave_skip_counter; --rli->slave_skip_counter;
pthread_mutex_unlock(&rli->data_lock); pthread_mutex_unlock(&rli->data_lock);
delete ev; delete ev;
return 0; // avoid infinite update loops return 0; // avoid infinite update loops
} }
pthread_mutex_unlock(&rli->data_lock); pthread_mutex_unlock(&rli->data_lock);
thd->server_id = ev->server_id; // use the original server id for logging thd->server_id = ev->server_id; // use the original server id for logging
thd->set_time(); // time the query thd->set_time(); // time the query
thd->lex->current_select= 0; thd->lex->current_select= 0;
if (!ev->when) if (!ev->when)
{
ev->when = time(NULL); ev->when = time(NULL);
/*
fake Rotate: it means that normal execution flow of statements is
interrupted. Let's fake ROLLBACK to undo any half-executed transaction
*/
if (ev->get_type_code() == ROTATE_EVENT &&
ev->flags & LOG_EVENT_FORCE_ROLLBACK_F)
{
ha_rollback_stmt(thd);
ha_rollback(thd);
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE);
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
}
}
ev->thd = thd; ev->thd = thd;
exec_res = ev->exec_event(rli); exec_res = ev->exec_event(rli);
DBUG_ASSERT(rli->sql_thd==thd); DBUG_ASSERT(rli->sql_thd==thd);
/* /*
Format_description_log_event should not be deleted because it will be Format_description_log_event should not be deleted because it will be
used to read info about the relay log's format; it will be deleted when used to read info about the relay log's format; it will be deleted when
the SQL thread does not need it, i.e. when this thread terminates. the SQL thread does not need it, i.e. when this thread terminates.
...@@ -3267,17 +3253,17 @@ extern "C" pthread_handler_decl(handle_slave_io,arg) ...@@ -3267,17 +3253,17 @@ extern "C" pthread_handler_decl(handle_slave_io,arg)
{ {
THD *thd; // needs to be first for thread_stack THD *thd; // needs to be first for thread_stack
MYSQL *mysql; MYSQL *mysql;
MASTER_INFO *mi = (MASTER_INFO*)arg; MASTER_INFO *mi = (MASTER_INFO*)arg;
char llbuff[22]; char llbuff[22];
uint retry_count; uint retry_count;
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init(); my_thread_init();
DBUG_ENTER("handle_slave_io"); DBUG_ENTER("handle_slave_io");
#ifndef DBUG_OFF #ifndef DBUG_OFF
slave_begin: slave_begin:
#endif #endif
DBUG_ASSERT(mi->inited); DBUG_ASSERT(mi->inited);
mysql= NULL ; mysql= NULL ;
retry_count= 0; retry_count= 0;
...@@ -3286,10 +3272,10 @@ extern "C" pthread_handler_decl(handle_slave_io,arg) ...@@ -3286,10 +3272,10 @@ extern "C" pthread_handler_decl(handle_slave_io,arg)
/* Inform waiting threads that slave has started */ /* Inform waiting threads that slave has started */
mi->slave_run_id++; mi->slave_run_id++;
#ifndef DBUG_OFF #ifndef DBUG_OFF
mi->events_till_abort = abort_slave_event_count; mi->events_till_abort = abort_slave_event_count;
#endif #endif
thd= new THD; // note that contructor of THD uses DBUG_ ! thd= new THD; // note that contructor of THD uses DBUG_ !
THD_CHECK_SENTRY(thd); THD_CHECK_SENTRY(thd);
...@@ -3310,17 +3296,17 @@ extern "C" pthread_handler_decl(handle_slave_io,arg) ...@@ -3310,17 +3296,17 @@ extern "C" pthread_handler_decl(handle_slave_io,arg)
mi->abort_slave = 0; mi->abort_slave = 0;
pthread_mutex_unlock(&mi->run_lock); pthread_mutex_unlock(&mi->run_lock);
pthread_cond_broadcast(&mi->start_cond); pthread_cond_broadcast(&mi->start_cond);
DBUG_PRINT("master_info",("log_file_name: '%s' position: %s", DBUG_PRINT("master_info",("log_file_name: '%s' position: %s",
mi->master_log_name, mi->master_log_name,
llstr(mi->master_log_pos,llbuff))); llstr(mi->master_log_pos,llbuff)));
if (!(mi->mysql = mysql = mysql_init(NULL))) if (!(mi->mysql = mysql = mysql_init(NULL)))
{ {
sql_print_error("Slave I/O thread: error in mysql_init()"); sql_print_error("Slave I/O thread: error in mysql_init()");
goto err; goto err;
} }
thd->proc_info = "Connecting to master"; thd->proc_info = "Connecting to master";
// we can get killed during safe_connect // we can get killed during safe_connect
if (!safe_connect(thd, mysql, mi)) if (!safe_connect(thd, mysql, mi))
...@@ -3355,11 +3341,11 @@ extern "C" pthread_handler_decl(handle_slave_io,arg) ...@@ -3355,11 +3341,11 @@ extern "C" pthread_handler_decl(handle_slave_io,arg)
if (register_slave_on_master(mysql) || update_slave_list(mysql, mi)) if (register_slave_on_master(mysql) || update_slave_list(mysql, mi))
goto err; goto err;
} }
DBUG_PRINT("info",("Starting reading binary log from master")); DBUG_PRINT("info",("Starting reading binary log from master"));
while (!io_slave_killed(thd,mi)) while (!io_slave_killed(thd,mi))
{ {
bool suppress_warnings= 0; bool suppress_warnings= 0;
thd->proc_info = "Requesting binlog dump"; thd->proc_info = "Requesting binlog dump";
if (request_dump(mysql, mi, &suppress_warnings)) if (request_dump(mysql, mi, &suppress_warnings))
{ {
...@@ -3370,7 +3356,7 @@ extern "C" pthread_handler_decl(handle_slave_io,arg) ...@@ -3370,7 +3356,7 @@ extern "C" pthread_handler_decl(handle_slave_io,arg)
dump"); dump");
goto err; goto err;
} }
mi->slave_running= MYSQL_SLAVE_RUN_NOT_CONNECT; mi->slave_running= MYSQL_SLAVE_RUN_NOT_CONNECT;
thd->proc_info= "Waiting to reconnect after a failed binlog dump request"; thd->proc_info= "Waiting to reconnect after a failed binlog dump request";
#ifdef SIGNAL_WITH_VIO_CLOSE #ifdef SIGNAL_WITH_VIO_CLOSE
...@@ -3414,8 +3400,8 @@ after reconnect"); ...@@ -3414,8 +3400,8 @@ after reconnect");
while (!io_slave_killed(thd,mi)) while (!io_slave_killed(thd,mi))
{ {
bool suppress_warnings= 0; bool suppress_warnings= 0;
/* /*
We say "waiting" because read_event() will wait if there's nothing to We say "waiting" because read_event() will wait if there's nothing to
read. But if there's something to read, it will not wait. The read. But if there's something to read, it will not wait. The
important thing is to not confuse users by saying "reading" whereas important thing is to not confuse users by saying "reading" whereas
...@@ -3429,7 +3415,7 @@ after reconnect"); ...@@ -3429,7 +3415,7 @@ after reconnect");
sql_print_information("Slave I/O thread killed while reading event"); sql_print_information("Slave I/O thread killed while reading event");
goto err; goto err;
} }
if (event_len == packet_error) if (event_len == packet_error)
{ {
uint mysql_error_number= mysql_errno(mysql); uint mysql_error_number= mysql_errno(mysql);
...@@ -3460,7 +3446,7 @@ max_allowed_packet", ...@@ -3460,7 +3446,7 @@ max_allowed_packet",
goto err; // Don't retry forever goto err; // Don't retry forever
safe_sleep(thd,mi->connect_retry,(CHECK_KILLED_FUNC)io_slave_killed, safe_sleep(thd,mi->connect_retry,(CHECK_KILLED_FUNC)io_slave_killed,
(void*) mi); (void*) mi);
} }
if (io_slave_killed(thd,mi)) if (io_slave_killed(thd,mi))
{ {
if (global_system_variables.log_warnings) if (global_system_variables.log_warnings)
...@@ -3483,7 +3469,7 @@ reconnect done to recover from failed read"); ...@@ -3483,7 +3469,7 @@ reconnect done to recover from failed read");
} }
goto connected; goto connected;
} // if (event_len == packet_error) } // if (event_len == packet_error)
retry_count=0; // ok event, reset retry counter retry_count=0; // ok event, reset retry counter
thd->proc_info = "Queueing master event to the relay log"; thd->proc_info = "Queueing master event to the relay log";
if (queue_event(mi,(const char*)mysql->net.read_pos + 1, if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
......
...@@ -1286,33 +1286,22 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd) ...@@ -1286,33 +1286,22 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
/* /*
Ends the current transaction and (maybe) begin the next Ends the current transaction and (maybe) begin the next
First uint4 in packet is completion type
SYNOPSIS SYNOPSIS
end_trans_and_send_ok() end_trans()
thd Current thread thd Current thread
completion Completion type completion Completion type
release (OUT) indicator for release operation
RETURN RETURN
0 - OK 0 - OK
*/ */
enum enum_mysql_completiontype { int end_trans(THD *thd, enum enum_mysql_completiontype completion)
ROLLBACK_RELEASE=-2,
COMMIT_RELEASE=-1,
COMMIT=0,
ROLLBACK=1,
COMMIT_AND_CHAIN=6,
ROLLBACK_AND_CHAIN=7
};
int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion)
{ {
bool do_release= 0; bool do_release= 0;
int res= 0; int res= 0;
LEX *lex= thd->lex; LEX *lex= thd->lex;
DBUG_ENTER("end_trans_and_send_ok"); DBUG_ENTER("end_trans");
switch (completion) { switch (completion) {
case COMMIT: case COMMIT:
...@@ -1323,8 +1312,7 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion) ...@@ -1323,8 +1312,7 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion)
*/ */
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE);
thd->server_status&= ~SERVER_STATUS_IN_TRANS; thd->server_status&= ~SERVER_STATUS_IN_TRANS;
if (!(res= ha_commit(thd))) res= ha_commit(thd);
send_ok(thd);
break; break;
case COMMIT_RELEASE: case COMMIT_RELEASE:
do_release= 1; /* fall through */ do_release= 1; /* fall through */
...@@ -1332,8 +1320,6 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion) ...@@ -1332,8 +1320,6 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion)
res= end_active_trans(thd); res= end_active_trans(thd);
if (!res && completion == COMMIT_AND_CHAIN) if (!res && completion == COMMIT_AND_CHAIN)
res= begin_trans(thd); res= begin_trans(thd);
if (!res)
send_ok(thd);
break; break;
case ROLLBACK_RELEASE: case ROLLBACK_RELEASE:
do_release= 1; /* fall through */ do_release= 1; /* fall through */
...@@ -1346,9 +1332,6 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion) ...@@ -1346,9 +1332,6 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion)
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE);
if (!res && (completion == ROLLBACK_AND_CHAIN)) if (!res && (completion == ROLLBACK_AND_CHAIN))
res= begin_trans(thd); res= begin_trans(thd);
if (!res)
send_ok(thd);
break; break;
} }
default: default:
...@@ -3853,14 +3836,16 @@ mysql_execute_command(THD *thd) ...@@ -3853,14 +3836,16 @@ mysql_execute_command(THD *thd)
send_ok(thd); send_ok(thd);
break; break;
case SQLCOM_COMMIT: case SQLCOM_COMMIT:
if (end_trans_and_send_ok(thd, lex->tx_release ? COMMIT_RELEASE : if (end_trans(thd, lex->tx_release ? COMMIT_RELEASE :
lex->tx_chain ? COMMIT_AND_CHAIN : COMMIT)) lex->tx_chain ? COMMIT_AND_CHAIN : COMMIT))
goto error; goto error;
send_ok(thd);
break; break;
case SQLCOM_ROLLBACK: case SQLCOM_ROLLBACK:
if (end_trans_and_send_ok(thd, lex->tx_release ? ROLLBACK_RELEASE : if (end_trans(thd, lex->tx_release ? ROLLBACK_RELEASE :
lex->tx_chain ? ROLLBACK_AND_CHAIN : ROLLBACK)) lex->tx_chain ? ROLLBACK_AND_CHAIN : ROLLBACK))
goto error; goto error;
send_ok(thd);
break; break;
case SQLCOM_RELEASE_SAVEPOINT: case SQLCOM_RELEASE_SAVEPOINT:
{ {
......
...@@ -44,7 +44,7 @@ static int binlog_dump_count = 0; ...@@ -44,7 +44,7 @@ static int binlog_dump_count = 0;
*/ */
static int fake_rotate_event(NET* net, String* packet, char* log_file_name, static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
ulonglong position, int flags, const char** errmsg) ulonglong position, const char** errmsg)
{ {
DBUG_ENTER("fake_rotate_event"); DBUG_ENTER("fake_rotate_event");
char header[LOG_EVENT_HEADER_LEN], buf[ROTATE_HEADER_LEN+100]; char header[LOG_EVENT_HEADER_LEN], buf[ROTATE_HEADER_LEN+100];
...@@ -60,7 +60,7 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, ...@@ -60,7 +60,7 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
ulong event_len = ident_len + LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN; ulong event_len = ident_len + LOG_EVENT_HEADER_LEN + ROTATE_HEADER_LEN;
int4store(header + SERVER_ID_OFFSET, server_id); int4store(header + SERVER_ID_OFFSET, server_id);
int4store(header + EVENT_LEN_OFFSET, event_len); int4store(header + EVENT_LEN_OFFSET, event_len);
int2store(header + FLAGS_OFFSET, flags); int2store(header + FLAGS_OFFSET, 0);
// TODO: check what problems this may cause and fix them // TODO: check what problems this may cause and fix them
int4store(header + LOG_POS_OFFSET, 0); int4store(header + LOG_POS_OFFSET, 0);
...@@ -325,7 +325,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ...@@ -325,7 +325,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
const char *errmsg = "Unknown error"; const char *errmsg = "Unknown error";
NET* net = &thd->net; NET* net = &thd->net;
pthread_mutex_t *log_lock; pthread_mutex_t *log_lock;
bool binlog_can_be_corrupted= FALSE, rotate_was_found=FALSE; bool binlog_can_be_corrupted= FALSE;
#ifndef DBUG_OFF #ifndef DBUG_OFF
int left_events = max_binlog_dump_events; int left_events = max_binlog_dump_events;
#endif #endif
...@@ -419,7 +419,7 @@ impossible position"; ...@@ -419,7 +419,7 @@ impossible position";
given that we want minimum modification of 4.0, we send the normal given that we want minimum modification of 4.0, we send the normal
and fake Rotates. and fake Rotates.
*/ */
if (fake_rotate_event(net, packet, log_file_name, pos, 0, &errmsg)) if (fake_rotate_event(net, packet, log_file_name, pos, &errmsg))
{ {
/* /*
This error code is not perfect, as fake_rotate_event() does not This error code is not perfect, as fake_rotate_event() does not
...@@ -509,8 +509,6 @@ impossible position"; ...@@ -509,8 +509,6 @@ impossible position";
binlog_can_be_corrupted= (*packet)[FLAGS_OFFSET+1] & LOG_EVENT_BINLOG_IN_USE_F; binlog_can_be_corrupted= (*packet)[FLAGS_OFFSET+1] & LOG_EVENT_BINLOG_IN_USE_F;
else if ((*packet)[EVENT_TYPE_OFFSET+1] == STOP_EVENT) else if ((*packet)[EVENT_TYPE_OFFSET+1] == STOP_EVENT)
binlog_can_be_corrupted= FALSE; binlog_can_be_corrupted= FALSE;
else if ((*packet)[EVENT_TYPE_OFFSET+1] == ROTATE_EVENT)
rotate_was_found=TRUE;
if (my_net_write(net, (char*)packet->ptr(), packet->length())) if (my_net_write(net, (char*)packet->ptr(), packet->length()))
{ {
...@@ -690,13 +688,11 @@ impossible position"; ...@@ -690,13 +688,11 @@ impossible position";
*/ */
if ((file=open_binlog(&log, log_file_name, &errmsg)) < 0 || if ((file=open_binlog(&log, log_file_name, &errmsg)) < 0 ||
fake_rotate_event(net, packet, log_file_name, BIN_LOG_HEADER_SIZE, fake_rotate_event(net, packet, log_file_name, BIN_LOG_HEADER_SIZE,
rotate_was_found ? 0 : LOG_EVENT_FORCE_ROLLBACK_F,
&errmsg)) &errmsg))
{ {
my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
goto err; goto err;
} }
rotate_was_found=FALSE;
packet->length(0); packet->length(0);
packet->append('\0'); packet->append('\0');
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment