Commit f07e4850 authored by unknown's avatar unknown
Browse files

WWe now store the catalog in Query_log_event in binlog WITHOUT its end zero.

This saves one byte per Query_log_event on disk compared to 5.0.[0..3]. Compatibility problems with 5.0.x where x<4
are explained in the comments in log_event.cc. Putting back s/my_open(O_TRUNC)/(my_delete+my_create) change which had
been wiped away by somebody doing a wrong 4.1->5.0 merge (which happened just
before 5.0.3 :( ). Applying it to new events for LOAD DATA INFILE.
If slave fails in Execute_load_query_log_event::exec_event(),
don't delete the file (so that it's re-usable at next START SLAVE).
And (youpi!) fix for BUG#3247 "a partially completed LOAD DATA INFILE is not
executed at all on the slave" (storing an Execute_load_query_log_event
to binlog, with its error code, instead of Delete_file_log_event).


mysql-test/r/mix_innodb_myisam_binlog.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_change_master.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_deadlock.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_error_ignored_table.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_flush_log_loop.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_loaddata.result:
  we now use one less byte when storing the catalog in binlog so positions change.
  Plus testing replication of LOAD DATA INFILE if duplicate key and non-transactional table.
mysql-test/r/rpl_log.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_max_relay_size.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_relayrotate.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_replicate_do.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_rotate_logs.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/r/rpl_until.result:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/t/mysqlbinlog.test:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/t/mysqlbinlog2.test:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/t/rpl_deadlock.test:
  we now use one less byte when storing the catalog in binlog so positions change
mysql-test/t/rpl_loaddata.test:
  we now use one less byte when storing the catalog in binlog so positions change.
  Plus testing replication of LOAD DATA INFILE if duplicate key and non-transactional table.
mysql-test/t/rpl_until.test:
  we now use one less byte when storing the catalog in binlog so positions change
sql/log_event.cc:
  a) We now store the catalog in Query_log_event in binlog WITHOUT its end zero.
  This saves one byte per Query_log_event on disk. Compatibility problems with 5.0.x where x<4
  are explained in the comments in this file.
  b) putting back s/my_open(O_TRUNC)/(my_delete+my_create) change which had
  been wiped away by somebody doing a wrong 4.1->5.0 merge (which happened just
  before 5.0.3 :( ). Applying it to new events for LOAD DATA INFILE.
  c) if slave fails in Execute_load_query_log_event::exec_event(),
  don't delete the file (so that it's re-usable at next START SLAVE).
sql/log_event.h:
  We now store the catalog in Query_log_event in binlog WITHOUT its end zero.
  This saves one byte per Query_log_event on disk. This new storage for
  the catalog is denoted by Q_CATALOG_NZ_CODE (couldn't re-use Q_CATALOG_CODE
  as 5.0.3 slaves of this 5.0.4 master would segfault because it would
  expect a 0 when there is none.
  Renaming get_open_mode() to get_create_or_append() (see log_event.cc)
sql/sql_load.cc:
  Fix for BUG#3247: if LOAD DATA INFILE fails but has permanently updated a table
  (i.e. has deleted/added/modified some rows in a non-transactional table),
  we must write an Execute_load_query_log_event to binlog (with the error code,
  as this class beautifully inherits from Query_log_event, it can store
  the error code - thanks Dmitri) and not a Delete_file_log_event (we use
  to write a Delete_file_log_event: no update happened on slave, bug).
parent fa4a075b
Loading
Loading
Loading
Loading
+39 −39
Original line number Diff line number Diff line
@@ -9,9 +9,9 @@ commit;
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; BEGIN
master-bin.000001	167	Query	1	#	use `test`; insert into t1 values(1)
master-bin.000001	255	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	350	Xid	1	#	COMMIT /* xid=7 */
master-bin.000001	166	Query	1	#	use `test`; insert into t1 values(1)
master-bin.000001	253	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	347	Xid	1	#	COMMIT /* xid=7 */
delete from t1;
delete from t2;
reset master;
@@ -24,9 +24,9 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; BEGIN
master-bin.000001	167	Query	1	#	use `test`; insert into t1 values(2)
master-bin.000001	255	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	350	Query	1	#	use `test`; ROLLBACK
master-bin.000001	166	Query	1	#	use `test`; insert into t1 values(2)
master-bin.000001	253	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	347	Query	1	#	use `test`; ROLLBACK
delete from t1;
delete from t2;
reset master;
@@ -42,12 +42,12 @@ commit;
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; BEGIN
master-bin.000001	167	Query	1	#	use `test`; insert into t1 values(3)
master-bin.000001	255	Query	1	#	use `test`; savepoint my_savepoint
master-bin.000001	341	Query	1	#	use `test`; insert into t1 values(4)
master-bin.000001	429	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	524	Query	1	#	use `test`; rollback to savepoint my_savepoint
master-bin.000001	622	Xid	1	#	COMMIT /* xid=24 */
master-bin.000001	166	Query	1	#	use `test`; insert into t1 values(3)
master-bin.000001	253	Query	1	#	use `test`; savepoint my_savepoint
master-bin.000001	338	Query	1	#	use `test`; insert into t1 values(4)
master-bin.000001	425	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	519	Query	1	#	use `test`; rollback to savepoint my_savepoint
master-bin.000001	616	Xid	1	#	COMMIT /* xid=24 */
delete from t1;
delete from t2;
reset master;
@@ -68,13 +68,13 @@ a
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; BEGIN
master-bin.000001	167	Query	1	#	use `test`; insert into t1 values(5)
master-bin.000001	255	Query	1	#	use `test`; savepoint my_savepoint
master-bin.000001	341	Query	1	#	use `test`; insert into t1 values(6)
master-bin.000001	429	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	524	Query	1	#	use `test`; rollback to savepoint my_savepoint
master-bin.000001	622	Query	1	#	use `test`; insert into t1 values(7)
master-bin.000001	710	Xid	1	#	COMMIT /* xid=36 */
master-bin.000001	166	Query	1	#	use `test`; insert into t1 values(5)
master-bin.000001	253	Query	1	#	use `test`; savepoint my_savepoint
master-bin.000001	338	Query	1	#	use `test`; insert into t1 values(6)
master-bin.000001	425	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	519	Query	1	#	use `test`; rollback to savepoint my_savepoint
master-bin.000001	616	Query	1	#	use `test`; insert into t1 values(7)
master-bin.000001	703	Xid	1	#	COMMIT /* xid=36 */
delete from t1;
delete from t2;
reset master;
@@ -90,9 +90,9 @@ get_lock("a",10)
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; BEGIN
master-bin.000001	167	Query	1	#	use `test`; insert into t1 values(8)
master-bin.000001	255	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	350	Query	1	#	use `test`; ROLLBACK
master-bin.000001	166	Query	1	#	use `test`; insert into t1 values(8)
master-bin.000001	253	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	347	Query	1	#	use `test`; ROLLBACK
delete from t1;
delete from t2;
reset master;
@@ -101,8 +101,8 @@ insert into t2 select * from t1;
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; insert into t1 values(9)
master-bin.000001	186	Xid	1	#	COMMIT /* xid=59 */
master-bin.000001	213	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	185	Xid	1	#	COMMIT /* xid=59 */
master-bin.000001	212	Query	1	#	use `test`; insert into t2 select * from t1
delete from t1;
delete from t2;
reset master;
@@ -112,18 +112,18 @@ insert into t2 select * from t1;
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; insert into t1 values(10)
master-bin.000001	187	Xid	1	#	COMMIT /* xid=65 */
master-bin.000001	214	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	186	Xid	1	#	COMMIT /* xid=65 */
master-bin.000001	213	Query	1	#	use `test`; insert into t2 select * from t1
insert into t1 values(11);
commit;
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; insert into t1 values(10)
master-bin.000001	187	Xid	1	#	COMMIT /* xid=65 */
master-bin.000001	214	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	309	Query	1	#	use `test`; BEGIN
master-bin.000001	378	Query	1	#	use `test`; insert into t1 values(11)
master-bin.000001	467	Xid	1	#	COMMIT /* xid=67 */
master-bin.000001	186	Xid	1	#	COMMIT /* xid=65 */
master-bin.000001	213	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	307	Query	1	#	use `test`; BEGIN
master-bin.000001	375	Query	1	#	use `test`; insert into t1 values(11)
master-bin.000001	463	Xid	1	#	COMMIT /* xid=67 */
alter table t2 engine=INNODB;
delete from t1;
delete from t2;
@@ -135,9 +135,9 @@ commit;
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; BEGIN
master-bin.000001	167	Query	1	#	use `test`; insert into t1 values(12)
master-bin.000001	256	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	351	Xid	1	#	COMMIT /* xid=77 */
master-bin.000001	166	Query	1	#	use `test`; insert into t1 values(12)
master-bin.000001	254	Query	1	#	use `test`; insert into t2 select * from t1
master-bin.000001	348	Xid	1	#	COMMIT /* xid=77 */
delete from t1;
delete from t2;
reset master;
@@ -160,8 +160,8 @@ commit;
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; BEGIN
master-bin.000001	167	Query	1	#	use `test`; insert into t1 values(14)
master-bin.000001	256	Xid	1	#	COMMIT /* xid=93 */
master-bin.000001	166	Query	1	#	use `test`; insert into t1 values(14)
master-bin.000001	254	Xid	1	#	COMMIT /* xid=93 */
delete from t1;
delete from t2;
reset master;
@@ -180,9 +180,9 @@ a
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Query	1	#	use `test`; BEGIN
master-bin.000001	167	Query	1	#	use `test`; insert into t1 values(16)
master-bin.000001	256	Query	1	#	use `test`; insert into t1 values(18)
master-bin.000001	345	Xid	1	#	COMMIT /* xid=104 */
master-bin.000001	166	Query	1	#	use `test`; insert into t1 values(16)
master-bin.000001	254	Query	1	#	use `test`; insert into t1 values(18)
master-bin.000001	342	Xid	1	#	COMMIT /* xid=104 */
delete from t1;
delete from t2;
alter table t2 type=MyISAM;
+2 −2
Original line number Diff line number Diff line
@@ -13,11 +13,11 @@ insert into t1 values(2);
stop slave;
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_MYPORT	1	master-bin.000001	360	#	#	master-bin.000001	No	No							0		0	184	#	None		0	No						#
#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	357	#	#	master-bin.000001	No	No							0		0	183	#	None		0	No						#
change master to master_user='root';
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_MYPORT	1	master-bin.000001	184	#	#	master-bin.000001	No	No							0		0	184	#	None		0	No						#
#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	183	#	#	master-bin.000001	No	No							0		0	183	#	None		0	No						#
start slave;
select * from t1;
n
+5 −5
Original line number Diff line number Diff line
@@ -45,9 +45,9 @@ a
22
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_MYPORT	1	master-bin.000001	19118	#	#	master-bin.000001	Yes	Yes							0		0	19118	#	None		0	No						#
#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	18911	#	#	master-bin.000001	Yes	Yes							0		0	18911	#	None		0	No						#
stop slave;
change master to master_log_pos=536;
change master to master_log_pos=532;
begin;
select * from t2 for update;
a
@@ -63,10 +63,10 @@ a
22
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_MYPORT	1	master-bin.000001	19118	#	#	master-bin.000001	Yes	Yes							0		0	19118	#	None		0	No						#
#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	18911	#	#	master-bin.000001	Yes	Yes							0		0	18911	#	None		0	No						#
set global max_relay_log_size=0;
stop slave;
change master to master_log_pos=536;
change master to master_log_pos=532;
begin;
select * from t2 for update;
a
@@ -83,5 +83,5 @@ a
22
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_MYPORT	1	master-bin.000001	19118	#	#	master-bin.000001	Yes	Yes							0		0	19118	#	None		0	No						#
#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	18911	#	#	master-bin.000001	Yes	Yes							0		0	18911	#	None		0	No						#
drop table t1,t2;
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ insert into t1 values (1),(1);
ERROR 23000: Duplicate entry '1' for key 1
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.000001	290	#	#	master-bin.000001	Yes	Yes				test.t3,test.t1,test.t2			0		0	290	#	None		0	No						#
#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	288	#	#	master-bin.000001	Yes	Yes				test.t3,test.t1,test.t2			0		0	288	#	None		0	No						#
show tables like 't1';
Tables_in_test (t1)
drop table t1;
+1 −1
Original line number Diff line number Diff line
@@ -14,4 +14,4 @@ start slave;
flush logs;
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	SLAVE_PORT	60	slave-bin.000001	209	#	#	slave-bin.000001	Yes	Yes							0		0	209	#	None		0	No						#
#	127.0.0.1	root	SLAVE_PORT	60	slave-bin.000001	208	#	#	slave-bin.000001	Yes	Yes							0		0	208	#	None		0	No						#
Loading