diff options
author | unknown <gbichot@quadita2.mysql.com> | 2005-03-25 14:51:17 +0100 |
---|---|---|
committer | unknown <gbichot@quadita2.mysql.com> | 2005-03-25 14:51:17 +0100 |
commit | f07e4850d025ccf0094d10328b291887f651544c (patch) | |
tree | 491287043eee4a43ead2c59964c69508b2df64ed | |
parent | fa4a075b6cb7ba7e71c842e6649bf7e7c516bef2 (diff) | |
download | mariadb-git-f07e4850d025ccf0094d10328b291887f651544c.tar.gz |
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).
-rw-r--r-- | mysql-test/r/mix_innodb_myisam_binlog.result | 78 | ||||
-rw-r--r-- | mysql-test/r/rpl_change_master.result | 4 | ||||
-rw-r--r-- | mysql-test/r/rpl_deadlock.result | 10 | ||||
-rw-r--r-- | mysql-test/r/rpl_error_ignored_table.result | 2 | ||||
-rw-r--r-- | mysql-test/r/rpl_flush_log_loop.result | 2 | ||||
-rw-r--r-- | mysql-test/r/rpl_loaddata.result | 27 | ||||
-rw-r--r-- | mysql-test/r/rpl_log.result | 82 | ||||
-rw-r--r-- | mysql-test/r/rpl_max_relay_size.result | 10 | ||||
-rw-r--r-- | mysql-test/r/rpl_relayrotate.result | 2 | ||||
-rw-r--r-- | mysql-test/r/rpl_replicate_do.result | 2 | ||||
-rw-r--r-- | mysql-test/r/rpl_rotate_logs.result | 8 | ||||
-rw-r--r-- | mysql-test/r/rpl_until.result | 30 | ||||
-rw-r--r-- | mysql-test/t/mysqlbinlog.test | 4 | ||||
-rw-r--r-- | mysql-test/t/mysqlbinlog2.test | 12 | ||||
-rw-r--r-- | mysql-test/t/rpl_deadlock.test | 4 | ||||
-rw-r--r-- | mysql-test/t/rpl_loaddata.test | 25 | ||||
-rw-r--r-- | mysql-test/t/rpl_until.test | 8 | ||||
-rw-r--r-- | sql/log_event.cc | 88 | ||||
-rw-r--r-- | sql/log_event.h | 16 | ||||
-rw-r--r-- | sql/sql_load.cc | 42 |
20 files changed, 271 insertions, 185 deletions
diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result index a5f4915384d..7821c074202 100644 --- a/mysql-test/r/mix_innodb_myisam_binlog.result +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -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; diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result index 6366a2d0f8f..7f2ba568fb3 100644 --- a/mysql-test/r/rpl_change_master.result +++ b/mysql-test/r/rpl_change_master.result @@ -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 diff --git a/mysql-test/r/rpl_deadlock.result b/mysql-test/r/rpl_deadlock.result index 74f24b8b180..866edb45cbb 100644 --- a/mysql-test/r/rpl_deadlock.result +++ b/mysql-test/r/rpl_deadlock.result @@ -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; diff --git a/mysql-test/r/rpl_error_ignored_table.result b/mysql-test/r/rpl_error_ignored_table.result index a5e025078b9..a0a808ce9a8 100644 --- a/mysql-test/r/rpl_error_ignored_table.result +++ b/mysql-test/r/rpl_error_ignored_table.result @@ -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; diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result index 083db5f440d..b4e840ba271 100644 --- a/mysql-test/r/rpl_flush_log_loop.result +++ b/mysql-test/r/rpl_flush_log_loop.result @@ -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 # diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 4060910c079..dc11d10fab8 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -22,7 +22,7 @@ day id category name 2003-03-22 2416 a bbbbb show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -slave-bin.000001 1292 +slave-bin.000001 1286 drop table t1; drop table t2; drop table t3; @@ -33,7 +33,7 @@ set global sql_slave_skip_counter=1; start 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_PORT 1 master-bin.000001 1800 # # master-bin.000001 Yes Yes 0 0 1800 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1789 # # master-bin.000001 Yes Yes 0 0 1789 # None 0 No # set sql_log_bin=0; delete from t1; set sql_log_bin=1; @@ -43,7 +43,7 @@ change master to master_user='test'; 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_PORT 1 master-bin.000001 1835 # # master-bin.000001 No No 0 0 1835 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1824 # # master-bin.000001 No No 0 0 1824 # None 0 No # set global sql_slave_skip_counter=1; start slave; set sql_log_bin=0; @@ -57,12 +57,25 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File # 127.0.0.1 root MASTER_PORT 1 4 # # No No 0 0 0 # None 0 No # reset master; create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), -unique(day)); +unique(day)) engine=MyISAM; load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; ERROR 23000: Duplicate entry '2003-03-22' for key 1 -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 441 +select * from t2; +day id category name +2003-02-22 2461 b a a a @ % ' " a +2003-03-22 2161 c asdf +start slave; +select * from t2; +day id category name +2003-02-22 2461 b a a a @ % ' " a +2003-03-22 2161 c asdf +alter table t2 drop key day; +delete from t2; +load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields +terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by +'\n##\n' starting by '>' ignore 1 lines; +ERROR 23000: Duplicate entry '2003-03-22' for key 1 +drop table t2; drop table t2; diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 85b27dcad34..5d61746b984 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -20,24 +20,24 @@ drop table t1; show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4 -master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key) -master-bin.000001 220 Intvar 1 248 INSERT_ID=1 -master-bin.000001 248 Query 1 340 use `test`; insert into t1 values (NULL) -master-bin.000001 340 Query 1 417 use `test`; drop table t1 -master-bin.000001 417 Query 1 521 use `test`; create table t1 (word char(20) not null) -master-bin.000001 521 Begin_load_query 1 1125 ;file_id=1;block_len=581 -master-bin.000001 1125 Execute_load_query 1 1274 use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1 -master-bin.000001 1274 Query 1 1351 use `test`; drop table t1 +master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 219 Intvar 1 247 INSERT_ID=1 +master-bin.000001 247 Query 1 338 use `test`; insert into t1 values (NULL) +master-bin.000001 338 Query 1 414 use `test`; drop table t1 +master-bin.000001 414 Query 1 517 use `test`; create table t1 (word char(20) not null) +master-bin.000001 517 Begin_load_query 1 1121 ;file_id=1;block_len=581 +master-bin.000001 1121 Execute_load_query 1 1269 use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1 +master-bin.000001 1269 Query 1 1345 use `test`; drop table t1 show binlog events from 98 limit 1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key) show binlog events from 98 limit 2; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key) -master-bin.000001 220 Intvar 1 248 INSERT_ID=1 +master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 219 Intvar 1 247 INSERT_ID=1 show binlog events from 98 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 248 Query 1 340 use `test`; insert into t1 values (NULL) +master-bin.000001 247 Query 1 338 use `test`; insert into t1 values (NULL) flush logs; create table t5 (a int); drop table t5; @@ -50,23 +50,23 @@ drop table t1; show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4 -master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key) -master-bin.000001 220 Intvar 1 248 INSERT_ID=1 -master-bin.000001 248 Query 1 340 use `test`; insert into t1 values (NULL) -master-bin.000001 340 Query 1 417 use `test`; drop table t1 -master-bin.000001 417 Query 1 521 use `test`; create table t1 (word char(20) not null) -master-bin.000001 521 Begin_load_query 1 1125 ;file_id=1;block_len=581 -master-bin.000001 1125 Execute_load_query 1 1274 use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1 -master-bin.000001 1274 Query 1 1351 use `test`; drop table t1 -master-bin.000001 1351 Rotate 1 1395 master-bin.000002;pos=4 +master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 219 Intvar 1 247 INSERT_ID=1 +master-bin.000001 247 Query 1 338 use `test`; insert into t1 values (NULL) +master-bin.000001 338 Query 1 414 use `test`; drop table t1 +master-bin.000001 414 Query 1 517 use `test`; create table t1 (word char(20) not null) +master-bin.000001 517 Begin_load_query 1 1121 ;file_id=1;block_len=581 +master-bin.000001 1121 Execute_load_query 1 1269 use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1 +master-bin.000001 1269 Query 1 1345 use `test`; drop table t1 +master-bin.000001 1345 Rotate 1 1389 master-bin.000002;pos=4 show binlog events in 'master-bin.000002'; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000002 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4 -master-bin.000002 98 Query 1 185 use `test`; create table t5 (a int) -master-bin.000002 185 Query 1 262 use `test`; drop table t5 -master-bin.000002 262 Query 1 349 use `test`; create table t1 (n int) -master-bin.000002 349 Query 1 438 use `test`; insert into t1 values (1) -master-bin.000002 438 Query 1 515 use `test`; drop table t1 +master-bin.000002 98 Query 1 184 use `test`; create table t5 (a int) +master-bin.000002 184 Query 1 260 use `test`; drop table t5 +master-bin.000002 260 Query 1 346 use `test`; create table t1 (n int) +master-bin.000002 346 Query 1 434 use `test`; insert into t1 values (1) +master-bin.000002 434 Query 1 510 use `test`; drop table t1 show binary logs; Log_name master-bin.000001 @@ -79,25 +79,25 @@ slave-bin.000002 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4 -slave-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key) -slave-bin.000001 220 Intvar 1 248 INSERT_ID=1 -slave-bin.000001 248 Query 1 340 use `test`; insert into t1 values (NULL) -slave-bin.000001 340 Query 1 417 use `test`; drop table t1 -slave-bin.000001 417 Query 1 521 use `test`; create table t1 (word char(20) not null) -slave-bin.000001 521 Begin_load_query 1 1125 ;file_id=1;block_len=581 -slave-bin.000001 1125 Execute_load_query 1 1283 use `test`; load data INFILE '../../var/tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1 -slave-bin.000001 1283 Query 1 1360 use `test`; drop table t1 -slave-bin.000001 1360 Query 1 1447 use `test`; create table t5 (a int) -slave-bin.000001 1447 Query 1 1524 use `test`; drop table t5 -slave-bin.000001 1524 Rotate 2 1567 slave-bin.000002;pos=4 +slave-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key) +slave-bin.000001 219 Intvar 1 247 INSERT_ID=1 +slave-bin.000001 247 Query 1 338 use `test`; insert into t1 values (NULL) +slave-bin.000001 338 Query 1 414 use `test`; drop table t1 +slave-bin.000001 414 Query 1 517 use `test`; create table t1 (word char(20) not null) +slave-bin.000001 517 Begin_load_query 1 1121 ;file_id=1;block_len=581 +slave-bin.000001 1121 Execute_load_query 1 1278 use `test`; load data INFILE '../../var/tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1 +slave-bin.000001 1278 Query 1 1354 use `test`; drop table t1 +slave-bin.000001 1354 Query 1 1440 use `test`; create table t5 (a int) +slave-bin.000001 1440 Query 1 1516 use `test`; drop table t5 +slave-bin.000001 1516 Rotate 2 1559 slave-bin.000002;pos=4 show binlog events in 'slave-bin.000002' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000002 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4 -slave-bin.000002 98 Query 1 185 use `test`; create table t1 (n int) -slave-bin.000002 185 Query 1 274 use `test`; insert into t1 values (1) -slave-bin.000002 274 Query 1 351 use `test`; drop table t1 +slave-bin.000002 98 Query 1 184 use `test`; create table t1 (n int) +slave-bin.000002 184 Query 1 272 use `test`; insert into t1 values (1) +slave-bin.000002 272 Query 1 348 use `test`; drop table t1 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 515 # # master-bin.000002 Yes Yes 0 0 515 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 510 # # master-bin.000002 Yes Yes 0 0 510 # None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log diff --git a/mysql-test/r/rpl_max_relay_size.result b/mysql-test/r/rpl_max_relay_size.result index 56cbe4d5ac8..fbe3b89828a 100644 --- a/mysql-test/r/rpl_max_relay_size.result +++ b/mysql-test/r/rpl_max_relay_size.result @@ -16,7 +16,7 @@ select @@global.max_relay_log_size; start 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_PORT 1 master-bin.000001 73754 # # master-bin.000001 Yes Yes 0 0 73754 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 72952 # # master-bin.000001 Yes Yes 0 0 72952 # None 0 No # stop slave; reset slave; set global max_relay_log_size=(5*4096); @@ -26,7 +26,7 @@ select @@global.max_relay_log_size; start 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_PORT 1 master-bin.000001 73754 # # master-bin.000001 Yes Yes 0 0 73754 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 72952 # # master-bin.000001 Yes Yes 0 0 72952 # None 0 No # stop slave; reset slave; set global max_relay_log_size=0; @@ -36,7 +36,7 @@ select @@global.max_relay_log_size; start 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_PORT 1 master-bin.000001 73754 # # master-bin.000001 Yes Yes 0 0 73754 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 72952 # # master-bin.000001 Yes Yes 0 0 72952 # None 0 No # stop slave; reset slave; flush logs; @@ -49,12 +49,12 @@ flush logs; create table t1 (a int); 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 73841 # # master-bin.000001 Yes Yes 0 0 73841 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73038 # # master-bin.000001 Yes Yes 0 0 73038 # None 0 No # flush logs; drop table t1; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73918 # # master-bin.000001 Yes Yes 0 0 73918 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73114 # # master-bin.000001 Yes Yes 0 0 73114 # None 0 No # flush logs; show master status; File Position Binlog_Do_DB Binlog_Ignore_DB diff --git a/mysql-test/r/rpl_relayrotate.result b/mysql-test/r/rpl_relayrotate.result index 0135e90dce9..c79187e12d0 100644 --- a/mysql-test/r/rpl_relayrotate.result +++ b/mysql-test/r/rpl_relayrotate.result @@ -18,5 +18,5 @@ max(a) 8000 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 743188 # # master-bin.000001 Yes Yes 0 0 743188 # None 0 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 735186 # # master-bin.000001 Yes Yes 0 0 735186 # None 0 No # drop table t1; diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result index 469504d06b4..8bcae3d25ad 100644 --- a/mysql-test/r/rpl_replicate_do.result +++ b/mysql-test/r/rpl_replicate_do.result @@ -28,4 +28,4 @@ ERROR 42S02: Table 'test.t11' doesn't exist drop table if exists t1,t2,t11; 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 1668 # # master-bin.000001 Yes Yes test.t1 0 0 1668 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1658 # # master-bin.000001 Yes Yes test.t1 0 0 1658 # None 0 No # diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index bd2e6dd685f..de177d12196 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -16,7 +16,7 @@ create table t1 (s text); insert into t1 values('Could not break slave'),('Tried hard'); 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 60 master-bin.000001 552 # # master-bin.000001 Yes Yes 0 0 552 # None 0 No # +# 127.0.0.1 root MASTER_PORT 60 master-bin.000001 548 # # master-bin.000001 Yes Yes 0 0 548 # None 0 No # select * from t1; s Could not break slave @@ -57,7 +57,7 @@ master-bin.000003 insert into t2 values (65); 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 60 master-bin.000003 500 # # master-bin.000003 Yes Yes 0 0 500 # None 0 No # +# 127.0.0.1 root MASTER_PORT 60 master-bin.000003 496 # # master-bin.000003 Yes Yes 0 0 496 # None 0 No # select * from t2; m 34 @@ -79,13 +79,13 @@ master-bin.000004 master-bin.000005 show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000005 2146 +master-bin.000005 2032 select * from t4; a testing temporary tables part 2 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 60 master-bin.000005 2146 # # master-bin.000005 Yes Yes 0 0 2146 # None 0 No # +# 127.0.0.1 root MASTER_PORT 60 master-bin.000005 2032 # # master-bin.000005 Yes Yes 0 0 2032 # None 0 No # lock tables t3 read; select count(*) from t3 where n >= 4; count(*) diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result index c9f9aa7b029..64efeab0145 100644 --- a/mysql-test/r/rpl_until.result +++ b/mysql-test/r/rpl_until.result @@ -15,14 +15,14 @@ drop table t2; show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4 -master-bin.000001 98 Query 1 220 use `test`; create table t1(n int not null auto_increment primary key) -master-bin.000001 220 Query 1 321 use `test`; insert into t1 values (1),(2),(3),(4) -master-bin.000001 321 Query 1 398 use `test`; drop table t1 -master-bin.000001 398 Query 1 520 use `test`; create table t2(n int not null auto_increment primary key) -master-bin.000001 520 Query 1 613 use `test`; insert into t2 values (1),(2) -master-bin.000001 613 Query 1 706 use `test`; insert into t2 values (3),(4) -master-bin.000001 706 Query 1 783 use `test`; drop table t2 -start slave until master_log_file='master-bin.000001', master_log_pos=321; +master-bin.000001 98 Query 1 219 use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 219 Query 1 319 use `test`; insert into t1 values (1),(2),(3),(4) +master-bin.000001 319 Query 1 395 use `test`; drop table t1 +master-bin.000001 395 Query 1 516 use `test`; create table t2(n int not null auto_increment primary key) +master-bin.000001 516 Query 1 608 use `test`; insert into t2 values (1),(2) +master-bin.000001 608 Query 1 700 use `test`; insert into t2 values (3),(4) +master-bin.000001 700 Query 1 776 use `test`; drop table t2 +start slave until master_log_file='master-bin.000001', master_log_pos=319; select * from t1; n 1 @@ -31,7 +31,7 @@ n 4 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 783 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 321 # Master master-bin.000001 321 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 319 # Master master-bin.000001 319 No # start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; select * from t1; n @@ -41,21 +41,21 @@ n 4 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 783 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 321 # Master master-no-such-bin.000001 291 No # -start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=751; +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 319 # Master master-no-such-bin.000001 291 No # +start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746; select * from t2; n 1 2 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 783 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 613 # Relay slave-relay-bin.000004 751 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 608 # Relay slave-relay-bin.000004 746 No # start slave; stop slave; -start slave until master_log_file='master-bin.000001', master_log_pos=783; +start slave until master_log_file='master-bin.000001', master_log_pos=776; 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 783 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 783 # Master master-bin.000001 783 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 776 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 776 # Master master-bin.000001 776 No # start slave until master_log_file='master-bin', master_log_pos=561; ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; @@ -67,6 +67,6 @@ ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UN start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561; ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL start slave sql_thread; -start slave until master_log_file='master-bin.000001', master_log_pos=783; +start slave until master_log_file='master-bin.000001', master_log_pos=776; Warnings: Note 1254 Slave is already running diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index df3b0acaa11..0988416942c 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -60,7 +60,7 @@ select "--- --database --" as ""; select "--- --position --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=232 $MYSQL_TEST_DIR/var/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=231 $MYSQL_TEST_DIR/var/log/master-bin.000002 # These are tests for remote binlog. # They should return the same as previous test. @@ -92,7 +92,7 @@ select "--- --database --" as ""; select "--- --position --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=232 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=231 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 # Bug#7853 (mysqlbinlog does not accept input from stdin) --disable_query_log diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test index 74ddf4e2be4..cbde6c93210 100644 --- a/mysql-test/t/mysqlbinlog2.test +++ b/mysql-test/t/mysqlbinlog2.test @@ -46,11 +46,11 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --start-position=600 $MYSQL_TEST_DIR/var/log/master-bin.000001 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=604 $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --stop-position=600 $MYSQL_TEST_DIR/var/log/master-bin.000001 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log @@ -75,7 +75,7 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --start-position=600 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002 --disable_query_log select "--- stop-position --" as ""; --enable_query_log @@ -102,11 +102,11 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 +--exec $MYSQL_BINLOG --short-form --start-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 +--exec $MYSQL_BINLOG --short-form --stop-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log @@ -129,7 +129,7 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 +--exec $MYSQL_BINLOG --short-form --start-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 --disable_query_log select "--- stop-position --" as ""; --enable_query_log diff --git a/mysql-test/t/rpl_deadlock.test b/mysql-test/t/rpl_deadlock.test index 800ff319ba0..3bcbb1d4567 100644 --- a/mysql-test/t/rpl_deadlock.test +++ b/mysql-test/t/rpl_deadlock.test @@ -72,7 +72,7 @@ show slave status; # 2) Test lock wait timeout stop slave; -change master to master_log_pos=536; # the BEGIN log event +change master to master_log_pos=532; # the BEGIN log event begin; select * from t2 for update; # hold lock start slave; @@ -93,7 +93,7 @@ set global max_relay_log_size=0; # This is really copy-paste of 2) of above stop slave; -change master to master_log_pos=536; +change master to master_log_pos=532; begin; select * from t2 for update; start slave; diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test index d1404dea211..3d54897adda 100644 --- a/mysql-test/t/rpl_loaddata.test +++ b/mysql-test/t/rpl_loaddata.test @@ -123,12 +123,29 @@ show slave status; connection master; reset master; create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), -unique(day)); +unique(day)) engine=MyISAM; # no transactions --error 1062; load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; -# To test that there is Create_file & Delete_file, we test if the binlog is as -# long as expected (can't do SHOW BINLOG EVENTS because of varying file_id). -show master status; +select * from t2; +save_master_pos; +connection slave; +start slave; +sync_with_master; +select * from t2; + +# verify that if no error on slave, this is an error + +alter table t2 drop key day; +connection master; +delete from t2; +--error 1062; +load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields +terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by +'\n##\n' starting by '>' ignore 1 lines; +connection slave; +wait_for_slave_to_stop; +drop table t2; +connection master; drop table t2; diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test index 9ee1dca9c11..714719f5441 100644 --- a/mysql-test/t/rpl_until.test +++ b/mysql-test/t/rpl_until.test @@ -24,7 +24,7 @@ show binlog events; # try to replicate all queries until drop of t1 connection slave; -start slave until master_log_file='master-bin.000001', master_log_pos=321; +start slave until master_log_file='master-bin.000001', master_log_pos=319; sleep 2; # here table should be still not deleted select * from t1; @@ -42,7 +42,7 @@ sleep 2; show slave status; # try replicate all until second insert to t2; -start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=751; +start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746; sleep 4; select * from t2; --replace_result $MASTER_MYPORT MASTER_MYPORT @@ -58,7 +58,7 @@ sync_with_master; stop slave; # this should stop immediately as we are already there -start slave until master_log_file='master-bin.000001', master_log_pos=783; +start slave until master_log_file='master-bin.000001', master_log_pos=776; # 2 is not enough when running with valgrind real_sleep 4 # here the sql slave thread should be stopped @@ -79,4 +79,4 @@ start slave until relay_log_file='slave-relay-bin.000002'; start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561; # Warning should be given for second command start slave sql_thread; -start slave until master_log_file='master-bin.000001', master_log_pos=783; +start slave until master_log_file='master-bin.000001', master_log_pos=776; diff --git a/sql/log_event.cc b/sql/log_event.cc index 27c30cadd11..cf145e33d1e 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1041,25 +1041,28 @@ bool Query_log_event::write(IO_CACHE* file) } if (catalog_len) // i.e. "catalog inited" (false for 4.0 events) { - *start++= Q_CATALOG_CODE; + *start++= Q_CATALOG_NZ_CODE; *start++= (uchar) catalog_len; bmove(start, catalog, catalog_len); start+= catalog_len; /* - We write a \0 at the end. As we also have written the length, it's - apparently useless; but in fact it enables us to just do - catalog= a_pointer_to_the_buffer_of_the_read_event - later in the slave SQL thread. - If we didn't have the \0, we would need to memdup to build the catalog in - the slave SQL thread. - And still the interest of having the length too is that in the slave SQL - thread we immediately know at which position the catalog ends (no need to - search for '\0'. In other words: length saves search, \0 saves mem alloc, - at the cost of 1 redundant byte on the disk. - Note that this is only a fix until we change 'catalog' to LEX_STRING - (then we won't need the \0). - */ - *(start++)= '\0'; + In 5.0.x where x<4 masters we used to store the end zero here. This was + a waste of one byte so we don't do it in x>=4 masters. We change code to + Q_CATALOG_NZ_CODE, because re-using the old code would make x<4 slaves + of this x>=4 master segfault (expecting a zero when there is + none). Remaining compatibility problems are: the older slave will not + find the catalog; but it is will not crash, and it's not an issue + that it does not find the catalog as catalogs were not used in these older + MySQL versions (we store it in binlog and read it from relay log but do + nothing useful with it). What is an issue is that the older slave will + stop processing the Q_* blocks (and jumps to the db/query) as soon as it + sees unknown Q_CATALOG_NZ_CODE; so it will not be able to read + Q_AUTO_INCREMENT*, Q_CHARSET and so replication will fail silently in + various ways. Documented that you should not mix alpha/beta versions if + they are not exactly the same version, with example of 5.0.2<->5.0.3 and + 5.0.3<->5.0.4. If replication is from older to new, the new won't find + the catalog and will have the same problems. + */ } if (auto_increment_increment != 1) { @@ -1259,10 +1262,10 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, pos+= 8; break; } - case Q_CATALOG_CODE: + case Q_CATALOG_NZ_CODE: if ((catalog_len= *pos)) catalog= (char*) pos+1; // Will be copied later - pos+= catalog_len+2; + pos+= catalog_len+1; break; case Q_AUTO_INCREMENT: auto_increment_increment= uint2korr(pos); @@ -1297,9 +1300,10 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, DBUG_VOID_RETURN; if (catalog_len) // If catalog is given { - memcpy(start, catalog, catalog_len+1); // Copy name and end \0 + memcpy(start, catalog, catalog_len); catalog= start; - start+= catalog_len+1; + start+= catalog_len; + *start++= 0; } if (time_zone_len) { @@ -4006,8 +4010,10 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli) strmov(p, ".info"); // strmov takes less code than memcpy strnmov(proc_info, "Making temp file ", 17); // no end 0 thd->proc_info= proc_info; - if ((fd = my_open(fname_buf, O_WRONLY|O_CREAT|O_BINARY|O_TRUNC, - MYF(MY_WME))) < 0 || + my_delete(fname_buf, MYF(0)); // old copy may exist already + if ((fd= my_create(fname_buf, CREATE_MODE, + O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, + MYF(MY_WME))) < 0 || init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0, MYF(MY_WME|MY_NABP))) { @@ -4031,8 +4037,10 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli) my_close(fd, MYF(0)); // fname_buf now already has .data, not .info, because we did our trick - if ((fd = my_open(fname_buf, O_WRONLY|O_CREAT|O_BINARY|O_TRUNC, - MYF(MY_WME))) < 0) + my_delete(fname_buf, MYF(0)); // old copy may exist already + if ((fd= my_create(fname_buf, CREATE_MODE, + O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, + MYF(MY_WME))) < 0) { slave_print_error(rli,my_errno, "Error in Create_file event: could not open file '%s'", fname_buf); goto err; @@ -4148,12 +4156,12 @@ void Append_block_log_event::pack_info(Protocol *protocol) /* - Append_block_log_event::get_open_mode() + Append_block_log_event::get_create_or_append() */ -int Append_block_log_event::get_open_mode() const +int Append_block_log_event::get_create_or_append() const { - return O_WRONLY | O_APPEND | O_BINARY; + return 0; /* append to the file, fail if not exists */ } /* @@ -4171,7 +4179,20 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli) memcpy(p, ".data", 6); strnmov(proc_info, "Making temp file ", 17); // no end 0 thd->proc_info= proc_info; - if ((fd = my_open(fname, get_open_mode(), MYF(MY_WME))) < 0) + if (get_create_or_append()) + { + my_delete(fname, MYF(0)); // old copy may exist already + if ((fd= my_create(fname, CREATE_MODE, + O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, + MYF(MY_WME))) < 0) + { + slave_print_error(rli, my_errno, + "Error in %s event: could not create file '%s'", + get_type_str(), fname); + goto err; + } + } + else if ((fd = my_open(fname, O_WRONLY|O_APPEND|O_BINARY|O_NOFOLLOW, MYF(MY_WME))) < 0) { slave_print_error(rli, my_errno, "Error in %s event: could not open file '%s'", @@ -4384,7 +4405,7 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli) Load_log_event* lev = 0; memcpy(p, ".info", 6); - if ((fd = my_open(fname, O_RDONLY|O_BINARY, MYF(MY_WME))) < 0 || + if ((fd = my_open(fname, O_RDONLY|O_BINARY|O_NOFOLLOW, MYF(MY_WME))) < 0 || init_io_cache(&file, fd, IO_SIZE, READ_CACHE, (my_off_t)0, 0, MYF(MY_WME|MY_NABP))) { @@ -4483,9 +4504,9 @@ Begin_load_query_log_event(const char* buf, uint len, #if defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT) -int Begin_load_query_log_event::get_open_mode() const +int Begin_load_query_log_event::get_create_or_append() const { - return O_CREAT | O_WRONLY | O_BINARY | O_TRUNC; + return 1; /* create the file */ } #endif /* defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ @@ -4662,7 +4683,12 @@ Execute_load_query_log_event::exec_event(struct st_relay_log_info* rli) /* Forging file name for deletion in same buffer */ *fname_end= 0; - (void) my_delete(fname, MYF(MY_WME)); + /* + If there was an error the slave is going to stop, leave the + file so that we can re-execute this event at START SLAVE. + */ + if (!error) + (void) my_delete(fname, MYF(MY_WME)); my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); return error; diff --git a/sql/log_event.h b/sql/log_event.h index 72142db0aa7..ba5d74b1784 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -234,10 +234,22 @@ struct sql_ex_info /* these are codes, not offsets; not more than 256 values (1 byte). */ #define Q_FLAGS2_CODE 0 #define Q_SQL_MODE_CODE 1 +/* + Q_CATALOG_CODE is catalog with end zero stored; it is used only by MySQL + 5.0.x where 0<=x<=3. +*/ #define Q_CATALOG_CODE 2 #define Q_AUTO_INCREMENT 3 #define Q_CHARSET_CODE 4 #define Q_TIME_ZONE_CODE 5 +/* + Q_CATALOG_NZ_CODE is catalog withOUT end zero stored; it is used by MySQL + 5.0.x where x>=4. Saves one byte in every Query_log_event in binlog, + compared to Q_CATALOG_CODE. The reason we didn't simply re-use + Q_CATALOG_CODE is that then a 5.0.3 slave of this 5.0.x (x>=4) master would + crash (segfault etc) because it would expect a 0 when there is none. +*/ +#define Q_CATALOG_NZ_CODE 6 /* Intvar event post-header */ @@ -1367,7 +1379,7 @@ public: #ifdef HAVE_REPLICATION int exec_event(struct st_relay_log_info* rli); void pack_info(Protocol* protocol); - virtual int get_open_mode() const; + virtual int get_create_or_append() const; #endif /* HAVE_REPLICATION */ #else void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0); @@ -1475,7 +1487,7 @@ public: bool using_trans); #ifdef HAVE_REPLICATION Begin_load_query_log_event(THD* thd); - int get_open_mode() const; + int get_create_or_append() const; #endif /* HAVE_REPLICATION */ #endif Begin_load_query_log_event(const char* buf, uint event_len, diff --git a/sql/sql_load.cc b/sql/sql_load.cc index e2f7c9d62c8..a0fed715405 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -81,6 +81,9 @@ static int read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, List<Item> &set_values, READ_INFO &read_info, String &enclosed, ulong skip_lines, bool ignore_check_option_errors); +static bool write_execute_load_query_log_event(THD *thd, + bool duplicates, bool ignore, + bool transactional_table); /* @@ -413,8 +416,14 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, /* If the file was not empty, wrote_create_file is true */ if (lf_info.wrote_create_file) { - Delete_file_log_event d(thd, db, transactional_table); - mysql_bin_log.write(&d); + if ((info.copied || info.deleted) && !transactional_table) + write_execute_load_query_log_event(thd, handle_duplicates, + ignore, transactional_table); + else + { + Delete_file_log_event d(thd, db, transactional_table); + mysql_bin_log.write(&d); + } } } #endif /*!EMBEDDED_LIBRARY*/ @@ -437,16 +446,8 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, */ read_info.end_io_cache(); if (lf_info.wrote_create_file) - { - Execute_load_query_log_event e(thd, thd->query, thd->query_length, - (char*)thd->lex->fname_start - (char*)thd->query, - (char*)thd->lex->fname_end - (char*)thd->query, - (handle_duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE : - (ignore ? LOAD_DUP_IGNORE : - LOAD_DUP_ERROR), - transactional_table, FALSE); - mysql_bin_log.write(&e); - } + write_execute_load_query_log_event(thd, handle_duplicates, + ignore, transactional_table); } #endif /*!EMBEDDED_LIBRARY*/ if (transactional_table) @@ -462,6 +463,23 @@ err: DBUG_RETURN(error); } + +/* Not a very useful function; just to avoid duplication of code */ +static bool write_execute_load_query_log_event(THD *thd, + bool duplicates, bool ignore, + bool transactional_table) +{ + Execute_load_query_log_event + e(thd, thd->query, thd->query_length, + (char*)thd->lex->fname_start - (char*)thd->query, + (char*)thd->lex->fname_end - (char*)thd->query, + (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE : + (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR), + transactional_table, FALSE); + return mysql_bin_log.write(&e); +} + + /**************************************************************************** ** Read of rows of fixed size + optional garage + optonal newline ****************************************************************************/ |