From 03045ee70ab6a3adf93c2a7506a3281f411d66fa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Sep 2005 17:41:47 +0200 Subject: 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. --- sql/sql_delete.cc | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'sql/sql_delete.cc') 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); -- cgit v1.2.1 From 466b46a66af37310b7d050448ab08913cb09671e Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Sep 2005 21:22:23 +0300 Subject: Fixed error found during review of new pushed code client/mysql.cc: Don't use c_ptr() for cgets() and ensure buffer is not overwritten mysql-test/r/cast.result: More test for CAST(0x.... as signed) sql/opt_sum.cc: Fix bugs found during review - Changed code to be able to remove one if - Ensure that count == 0 only if is_exact_count == TRUE sql/sql_delete.cc: Ensure 'allow_sum_func' is reset before call to setup_conds sql/sql_lex.cc: allow_sum_func doesn't have to be reset for each query (It's to be reset in setup_fields() or before call to setup_conds() sql/sql_load.cc: Move set of auto_increment_field_not_null so that it's not set if field value is NULL sql/sql_prepare.cc: allow_sum_func doesn't have to be reset for each query (It's to be reset in setup_fields() or before call to setup_conds() sql/sql_update.cc: Ensure 'allow_sum_func' is reset before call to setup_conds --- sql/sql_delete.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/sql_delete.cc') diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 7248adf6993..1dd52a2ba74 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -27,8 +27,8 @@ #include "ha_innodb.h" #include "sql_select.h" -int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, - ha_rows limit, ulong options) +int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, + SQL_LIST *order, ha_rows limit, ulong options) { int error; TABLE *table; @@ -266,6 +266,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) select_lex.table_list.first); DBUG_ENTER("mysql_prepare_delete"); + thd->allow_sum_func= 0; if (setup_conds(thd, delete_table_list, conds) || setup_ftfuncs(&thd->lex->select_lex)) DBUG_RETURN(-1); -- cgit v1.2.1 From d553b667911304ae14f9bed3b10fd3c1b77da649 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Sep 2005 16:26:48 -0700 Subject: Move handler specific options into handlerton flag check BUG#13108 mysql-test/r/federated.result: added test results for federated alter table mysql-test/t/federated.test: added test for federated alter table sql/examples/ha_example.cc: supports table re-creation sql/examples/ha_tina.cc: supports table re-creation sql/ha_blackhole.cc: supports table re-creation sql/ha_federated.cc: added flag for not supporting alter sql/ha_heap.cc: supports table recreation sql/ha_myisam.cc: supports table recreation sql/ha_myisammrg.cc: supports table re-creation sql/handler.cc: implemented flag check function sql/handler.h: added additional handlerton flags created a function to test flags replace ha_supports_generate macro with call to flag check sql/sql_delete.cc: replaced ha_supports_generate with handlerton flag check sql/sql_table.cc: added check for handlerton check for alter support --- sql/sql_delete.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/sql_delete.cc') diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 4001a51f459..d9734b7cae8 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -787,7 +787,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) TABLE *table= *table_ptr; table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK); db_type table_type= table->s->db_type; - if (!ha_supports_generate(table_type)) + if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE)) goto trunc_by_del; strmov(path, table->s->path); *table_ptr= table->next; // Unlink table from list @@ -818,7 +818,8 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) table_list->db, table_list->table_name); DBUG_RETURN(TRUE); } - if (!ha_supports_generate(table_type) || thd->lex->sphead) + if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE) + || thd->lex->sphead) goto trunc_by_del; if (lock_and_wait_for_table_name(thd, table_list)) DBUG_RETURN(TRUE); -- cgit v1.2.1