diff options
author | unknown <guilhem@mysql.com> | 2005-09-20 17:41:47 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2005-09-20 17:41:47 +0200 |
commit | 03045ee70ab6a3adf93c2a7506a3281f411d66fa (patch) | |
tree | a1843ec4af67e94bc6f5c15e3952b7ad581513a3 /sql/sql_delete.cc | |
parent | 2b24a2b5b57177db854cd93991afc3229f1a69cc (diff) | |
download | mariadb-git-03045ee70ab6a3adf93c2a7506a3281f411d66fa.tar.gz |
Fix fur BUG#13348: "multi-table updates and deletes are not logged if no rows were affected".
Not fixed in 4.1 as not critical. Also I'm correcting error checking of multi-UPDATE/DELETE
when it comes to binlogging, to make it consistent with when we rollback the statement.
mysql-test/r/rpl_multi_delete.result:
result update
mysql-test/r/rpl_multi_update.result:
result update
mysql-test/t/rpl_multi_delete.test:
test for BUG#13348
mysql-test/t/rpl_multi_update.test:
test of BUG#13348
sql/sql_delete.cc:
We now binlog multi-DELETE even if no row was updated (like we do for DELETE).
I'm also correcting some error checking (< instead of <=), basing myself on when we rollback.
sql/sql_update.cc:
we now binlog multi-UPDATE even if no row was updated (like we do for UPDATE).
Adding to existing tests to test new behaviour.
I'm also correcting some error checking (< instead of <=), basing myself on when we rollback.
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r-- | sql/sql_delete.cc | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 7fb9f9eccdd..7e99a5c65ee 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -258,19 +258,12 @@ cleanup: delete select; transactional_table= table->file->has_transactions(); - /* - We write to the binary log even if we deleted no row, because maybe the - user is using this command to ensure that a table is clean on master *and - on slave*. Think of the case of a user having played separately with the - master's table and slave's table and wanting to take a fresh identical - start now. - error < 0 means "really no error". error <= 0 means "maybe some error". - */ - if ((deleted || (error < 0)) && (error <= 0 || !transactional_table)) + /* See similar binlogging code in sql_update.cc, for comments */ + if ((error < 0) || (deleted && !transactional_table)) { if (mysql_bin_log.is_open()) { - if (error <= 0) + if (error < 0) thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, transactional_table, FALSE); @@ -718,6 +711,9 @@ bool multi_delete::send_eof() /* Does deletes for the last n - 1 tables, returns 0 if ok */ int local_error= do_deletes(); // returns 0 if success + /* compute a total error to know if something failed */ + local_error= local_error || error; + /* reset used flags */ thd->proc_info="end"; @@ -730,19 +726,11 @@ bool multi_delete::send_eof() query_cache_invalidate3(thd, delete_tables, 1); } - /* - Write the SQL statement to the binlog if we deleted - rows and we succeeded, or also in an error case when there - was a non-transaction-safe table involved, since - modifications in it cannot be rolled back. - Note that if we deleted nothing we don't write to the binlog (TODO: - fix this). - */ - if (deleted && ((error <= 0 && !local_error) || normal_tables)) + if ((local_error == 0) || (deleted && normal_tables)) { if (mysql_bin_log.is_open()) { - if (error <= 0 && !local_error) + if (local_error == 0) thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, transactional_tables, FALSE); |