#At file:///home/acorreia/workspace.oracle/repository.mysql/bzrwork/bug-59338/mysql-5.1/ based on revid:georgi.kodinov@stripped
3535 Alfranio Correia 2011-01-07
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 and INSERT IGNORE were not following the rule above and were
not written to the binary log, if then engine was Innodb.
modified:
mysql-test/include/commit.inc
mysql-test/r/commit_1innodb.result
sql/sql_insert.cc
=== modified file 'mysql-test/include/commit.inc'
--- a/mysql-test/include/commit.inc 2010-07-20 17:36:15 +0000
+++ b/mysql-test/include/commit.inc 2011-01-07 16:12:47 +0000
@@ -502,16 +502,16 @@ call p_verify_status_increment(2, 2, 2,
--echo # 12. Read-write statement: IODKU, change 0 rows.
--echo #
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;
-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 #
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;
-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 #
=== modified file 'mysql-test/r/commit_1innodb.result'
--- a/mysql-test/r/commit_1innodb.result 2010-07-20 17:36:15 +0000
+++ b/mysql-test/r/commit_1innodb.result 2011-01-07 16:12:47 +0000
@@ -518,21 +518,21 @@ SUCCESS
# 12. Read-write statement: IODKU, change 0 rows.
#
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
commit;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
# 13. Read-write statement: INSERT IGNORE, change 0 rows.
#
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
commit;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(2, 2, 1, 0);
SUCCESS
# 14. Read-write statement: INSERT IGNORE, change 1 row.
=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc 2010-10-07 08:13:11 +0000
+++ b/sql/sql_insert.cc 2011-01-07 16:12:47 +0000
@@ -881,7 +881,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
*/
query_cache_invalidate3(thd, table_list, 1);
}
- if ((changed && error <= 0) ||
+ if ((error <= 0 &&
+ (changed || (duplic == DUP_UPDATE) || (duplic == DUP_ERROR))) ||
thd->transaction.stmt.modified_non_trans_table ||
was_insert_delayed)
{
Attachment: [text/bzr-bundle] bzr/alfranio.correia@oracle.com-20110107161247-ikuzu3db2xnyf5lo.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (alfranio.correia:3535) Bug#59338 | Alfranio Correia | 7 Jan |