Commit cd4fd3c7 authored by Alfranio Correia's avatar Alfranio Correia

merge mysql-5.1 --> mysql-5.5

Conflicts:
  
  . mysql-test/extra/rpl_tests/rpl_insert_ignore.test
  . mysql-test/suite/rpl/t/disabled.def
  . mysql-test/suite/rpl/t/rpl_insert_ignore.test
  . sql/sql_insert.cc
  . sql/sql_repl.cc
parents 61163b51 cb52e82e
# BUG#59338 Inconsistency in binlog for statements that don't change any rows STATEMENT SBR
# In SBR, if a statement does not fail, it is always written to the binary log,
# regardless if rows are changed or not. If there is a failure, a statement is
# only written to the binary log if a non-transactional (.e.g. MyIsam) engine
# is updated. INSERT ON DUPLICATE KEY UPDATE was not following the rule above
# and was not written to the binary log, if then engine was Innodb.
#
# In this test case, we check if INSERT ON DUPLICATE KEY UPDATE that does not
# change anything is still written to the binary log.
# Prepare environment
--connection master
eval CREATE TABLE t1 (
a INT UNSIGNED NOT NULL PRIMARY KEY
) ENGINE=$engine_type;
eval CREATE TABLE t2 (
a INT UNSIGNED
) ENGINE=$engine_type;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
# An insert duplicate that does not update anything must be written to the binary
# log in SBR and MIXED modes. We check this property by summing a before and after
# the update and comparing the binlog positions. The sum should be the same at both
# points and the statement should be in the binary log.
--let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1)
--let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1)
--let $statement_file=INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a
--eval $statement_file
--let $assert_cond= SUM(a) = 1 FROM t1
--let $assert_text= Sum of elements in t1 should be 1.
--source include/assert.inc
if (`SELECT @@BINLOG_FORMAT = 'ROW'`)
{
--let $binlog_position_cmp= =
--let $assert_cond= [SHOW MASTER STATUS, Position, 1] $binlog_position_cmp $binlog_start
--let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
}
if (`SELECT @@BINLOG_FORMAT != 'ROW'`)
{
--let $assert_cond= \'[\'SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_start LIMIT 1, 1\', Info, 1]\' LIKE \'%$statement_file\'
--let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
}
--source include/assert.inc
# Compare master and slave
--sync_slave_with_master
--let $diff_tables= master:test.t1 , slave:test.t1
--source include/diff_tables.inc
# Clean up
--connection master
drop table t1, t2;
--sync_slave_with_master
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# Slave needs to be started with --innodb to store table in InnoDB. # Slave needs to be started with --innodb to store table in InnoDB.
# Same test for MyISAM (which had no bug). # Same test for MyISAM (which had no bug).
--connection master
eval CREATE TABLE t1 ( eval CREATE TABLE t1 (
a int unsigned not null auto_increment primary key, a int unsigned not null auto_increment primary key,
b int unsigned, b int unsigned,
...@@ -32,40 +33,44 @@ INSERT INTO t2 VALUES (5, 4); ...@@ -32,40 +33,44 @@ INSERT INTO t2 VALUES (5, 4);
INSERT INTO t2 VALUES (6, 6); INSERT INTO t2 VALUES (6, 6);
INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
--let $assert_cond= COUNT(*) = 6 FROM t1
# Compare results --let $assert_text= Count of elements in t1 should be 6.
--source include/assert.inc
SELECT * FROM t1 ORDER BY a;
# Compare master and slave
sync_slave_with_master; --sync_slave_with_master
SELECT * FROM t1 ORDER BY a; --let $diff_tables= master:test.t1 , slave:test.t1
--source include/diff_tables.inc
# Now do the same for MyISAM
# BUG#59338 Inconsistency in binlog for statements that don't change any rows STATEMENT SBR
connection master; # An insert ignore that does not update anything must be written to the binary log in SBR
drop table t1; # and MIXED modes. We check this property by counting occurrences in t1 before and after
eval CREATE TABLE t1 ( # the insert and comparing the binlog positions. The count should be the same in both points
a int unsigned not null auto_increment primary key, # and the statement should be in the binary log.
b int unsigned, --connection master
unique (b) --let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1)
) ENGINE=$engine_type2; --let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1)
--let $statement_file=INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a
INSERT INTO t1 VALUES (1, 1); --eval $statement_file
INSERT INTO t1 VALUES (2, 2);
INSERT INTO t1 VALUES (3, 3); --let $assert_cond= COUNT(*) = 6 FROM t1
INSERT INTO t1 VALUES (4, 4); --let $assert_text= Count of elements in t1 should be 6.
--source include/assert.inc
--disable_warnings
INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; if (`SELECT @@BINLOG_FORMAT = 'ROW'`)
--enable_warnings {
--let $binlog_position_cmp= =
SELECT * FROM t1 ORDER BY a; --let $assert_cond= [SHOW MASTER STATUS, Position, 1] $binlog_position_cmp $binlog_start
--let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
sync_slave_with_master; }
SELECT * FROM t1 ORDER BY a; if (`SELECT @@BINLOG_FORMAT != 'ROW'`)
{
connection master; --let $assert_cond= \'[\'SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_start LIMIT 2, 1\', Info, 1]\' LIKE \'%$statement_file\'
--let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.
}
--source include/assert.inc
# Clean up
--connection master
drop table t1, t2; drop table t1, t2;
sync_slave_with_master; --sync_slave_with_master
# End of 4.1 tests
...@@ -502,16 +502,16 @@ call p_verify_status_increment(2, 2, 2, 2); ...@@ -502,16 +502,16 @@ call p_verify_status_increment(2, 2, 2, 2);
--echo # 12. Read-write statement: IODKU, change 0 rows. --echo # 12. Read-write statement: IODKU, change 0 rows.
--echo # --echo #
insert t1 set a=2 on duplicate key update a=2; insert t1 set a=2 on duplicate key update a=2;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 2, 1, 0);
commit; commit;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 2, 1, 0);
--echo # 13. Read-write statement: INSERT IGNORE, change 0 rows. --echo # 13. Read-write statement: INSERT IGNORE, change 0 rows.
--echo # --echo #
insert ignore t1 set a=2; insert ignore t1 set a=2;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 2, 1, 0);
commit; commit;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 2, 1, 0);
--echo # 14. Read-write statement: INSERT IGNORE, change 1 row. --echo # 14. Read-write statement: INSERT IGNORE, change 1 row.
--echo # --echo #
......
...@@ -519,21 +519,21 @@ SUCCESS ...@@ -519,21 +519,21 @@ SUCCESS
# 12. Read-write statement: IODKU, change 0 rows. # 12. Read-write statement: IODKU, change 0 rows.
# #
insert t1 set a=2 on duplicate key update a=2; insert t1 set a=2 on duplicate key update a=2;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 2, 1, 0);
SUCCESS SUCCESS
commit; commit;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 2, 1, 0);
SUCCESS SUCCESS
# 13. Read-write statement: INSERT IGNORE, change 0 rows. # 13. Read-write statement: INSERT IGNORE, change 0 rows.
# #
insert ignore t1 set a=2; insert ignore t1 set a=2;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 2, 1, 0);
SUCCESS SUCCESS
commit; commit;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 2, 1, 0);
SUCCESS SUCCESS
# 14. Read-write statement: INSERT IGNORE, change 1 row. # 14. Read-write statement: INSERT IGNORE, change 1 row.
......
include/master-slave.inc
[connection master]
CREATE TABLE t1 (
a INT UNSIGNED NOT NULL PRIMARY KEY
) ENGINE=innodb;
CREATE TABLE t2 (
a INT UNSIGNED
) ENGINE=innodb;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a;
include/assert.inc [Sum of elements in t1 should be 1.]
include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.]
include/diff_tables.inc [master:test.t1 , slave:test.t1]
drop table t1, t2;
CREATE TABLE t1 (
a INT UNSIGNED NOT NULL PRIMARY KEY
) ENGINE=myisam;
CREATE TABLE t2 (
a INT UNSIGNED
) ENGINE=myisam;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a;
include/assert.inc [Sum of elements in t1 should be 1.]
include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.]
include/diff_tables.inc [master:test.t1 , slave:test.t1]
drop table t1, t2;
include/rpl_end.inc
...@@ -21,48 +21,36 @@ INSERT INTO t2 VALUES (4, 3); ...@@ -21,48 +21,36 @@ INSERT INTO t2 VALUES (4, 3);
INSERT INTO t2 VALUES (5, 4); INSERT INTO t2 VALUES (5, 4);
INSERT INTO t2 VALUES (6, 6); INSERT INTO t2 VALUES (6, 6);
INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
SELECT * FROM t1 ORDER BY a; include/assert.inc [Count of elements in t1 should be 6.]
a b include/diff_tables.inc [master:test.t1 , slave:test.t1]
1 1 INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
2 2 include/assert.inc [Count of elements in t1 should be 6.]
3 3 include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.]
4 4 drop table t1, t2;
5 5
6 6
SELECT * FROM t1 ORDER BY a;
a b
1 1
2 2
3 3
4 4
5 5
6 6
drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
a int unsigned not null auto_increment primary key, a int unsigned not null auto_increment primary key,
b int unsigned, b int unsigned,
unique (b) unique (b)
) ENGINE=myisam; ) ENGINE=myisam;
INSERT INTO t1 VALUES (1, 1); CREATE TABLE t2 (
INSERT INTO t1 VALUES (2, 2); a int unsigned, # to force INSERT SELECT to have a certain order
INSERT INTO t1 VALUES (3, 3); b int unsigned
INSERT INTO t1 VALUES (4, 4); ) ENGINE=myisam;
INSERT INTO t1 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 2);
INSERT INTO t1 VALUES (NULL, 3);
INSERT INTO t1 VALUES (NULL, 4);
INSERT INTO t2 VALUES (1, 1);
INSERT INTO t2 VALUES (2, 2);
INSERT INTO t2 VALUES (3, 5);
INSERT INTO t2 VALUES (4, 3);
INSERT INTO t2 VALUES (5, 4);
INSERT INTO t2 VALUES (6, 6);
INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
include/assert.inc [Count of elements in t1 should be 6.]
include/diff_tables.inc [master:test.t1 , slave:test.t1]
INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
SELECT * FROM t1 ORDER BY a; include/assert.inc [Count of elements in t1 should be 6.]
a b include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.]
1 1
2 2
3 3
4 4
5 5
6 6
SELECT * FROM t1 ORDER BY a;
a b
1 1
2 2
3 3
4 4
5 5
6 6
drop table t1, t2; drop table t1, t2;
include/rpl_end.inc include/rpl_end.inc
...@@ -9,7 +9,7 @@ change master to master_log_pos=MASTER_LOG_POS; ...@@ -9,7 +9,7 @@ change master to master_log_pos=MASTER_LOG_POS;
Read_Master_Log_Pos = '75' Read_Master_Log_Pos = '75'
start slave; start slave;
include/wait_for_slave_io_error.inc [errno=1236] include/wait_for_slave_io_error.inc [errno=1236]
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event'' Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master''
include/stop_slave_sql.inc include/stop_slave_sql.inc
show master status; show master status;
File Position Binlog_Do_DB Binlog_Ignore_DB File Position Binlog_Do_DB Binlog_Ignore_DB
......
...@@ -14,7 +14,6 @@ rpl_failed_optimize : WL#4284: Can't optimize table used by a pending tran ...@@ -14,7 +14,6 @@ rpl_failed_optimize : WL#4284: Can't optimize table used by a pending tran
rpl_read_only : WL#4284: Setting Read only won't succeed until all metadata locks are released. rpl_read_only : WL#4284: Setting Read only won't succeed until all metadata locks are released.
rpl_row_create_table : Bug#51574 2010-02-27 andrei failed different way than earlier with bug#45576 rpl_row_create_table : Bug#51574 2010-02-27 andrei failed different way than earlier with bug#45576
rpl_spec_variables : BUG#47661 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux rpl_spec_variables : BUG#47661 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux
rpl_log_pos : BUG#55675 2010-09-10 alfranio rpl.rpl_log_pos fails sporadically with error binlog truncated in the middle
rpl_get_master_version_and_clock : Bug#59178 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock rpl_get_master_version_and_clock : Bug#59178 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock
rpl_row_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out rpl_row_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
rpl_stm_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out rpl_stm_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
#########################################
# Wrapper for rpl_insert_duplicate.test #
#########################################
-- source include/master-slave.inc
-- source include/have_innodb.inc
#-- source include/have_binlog_format_mixed_or_statement.inc
let $engine_type=innodb;
-- source extra/rpl_tests/rpl_insert_duplicate.test
let $engine_type=myisam;
-- source extra/rpl_tests/rpl_insert_duplicate.test
--source include/rpl_end.inc
...@@ -7,7 +7,10 @@ ...@@ -7,7 +7,10 @@
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
let $engine_type=innodb; -- let $engine_type=innodb
let $engine_type2=myisam;
-- source extra/rpl_tests/rpl_insert_ignore.test -- source extra/rpl_tests/rpl_insert_ignore.test
-- let $engine_type=myisam
-- source extra/rpl_tests/rpl_insert_ignore.test
--source include/rpl_end.inc --source include/rpl_end.inc
...@@ -979,7 +979,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, ...@@ -979,7 +979,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
if (thd->transaction.stmt.modified_non_trans_table) if (thd->transaction.stmt.modified_non_trans_table)
thd->transaction.all.modified_non_trans_table= TRUE; thd->transaction.all.modified_non_trans_table= TRUE;
if ((changed && error <= 0) || if (error <= 0 ||
thd->transaction.stmt.modified_non_trans_table || thd->transaction.stmt.modified_non_trans_table ||
was_insert_delayed) was_insert_delayed)
{ {
......
...@@ -676,8 +676,11 @@ impossible position"; ...@@ -676,8 +676,11 @@ impossible position";
file */ file */
if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg)) if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg))
goto err; goto err;
my_off_t prev_pos= pos;
while (!(error = Log_event::read_log_event(&log, packet, log_lock))) while (!(error = Log_event::read_log_event(&log, packet, log_lock)))
{ {
prev_pos= my_b_tell(&log);
#ifndef DBUG_OFF #ifndef DBUG_OFF
if (max_binlog_dump_events && !left_events--) if (max_binlog_dump_events && !left_events--)
{ {
...@@ -767,8 +770,13 @@ impossible position"; ...@@ -767,8 +770,13 @@ impossible position";
here we were reading binlog that was not closed properly (as a result here we were reading binlog that was not closed properly (as a result
of a crash ?). treat any corruption as EOF of a crash ?). treat any corruption as EOF
*/ */
if (binlog_can_be_corrupted && error != LOG_READ_MEM) if (binlog_can_be_corrupted &&
error != LOG_READ_MEM && error != LOG_READ_EOF)
{
my_b_seek(&log, prev_pos);
error=LOG_READ_EOF; error=LOG_READ_EOF;
}
/* /*
TODO: now that we are logging the offset, check to make sure TODO: now that we are logging the offset, check to make sure
the recorded offset and the actual match. the recorded offset and the actual match.
......
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