diff options
author | unknown <mats@mysql.com> | 2006-01-05 10:52:58 +0100 |
---|---|---|
committer | unknown <mats@mysql.com> | 2006-01-05 10:52:58 +0100 |
commit | 30e23524240ae2755b5cd1641fa2fc5ed9628dfd (patch) | |
tree | dccb9a19586e501b1e0268915721ba097ec76460 /sql/sql_delete.cc | |
parent | a74472c849037c97ee44b80336f045ab19607829 (diff) | |
download | mariadb-git-30e23524240ae2755b5cd1641fa2fc5ed9628dfd.tar.gz |
Bug#15923 (Test ps_7ndb cause master crash):
Always logging statements of the form "DELETE FROM x" statement-based.
mysql-test/r/binlog_row_mix_innodb_myisam.result:
Result change.
mysql-test/t/disabled.def:
Enabling test ps_7ndb
sql/sql_delete.cc:
Always logging statements of the form "DELETE FROM x" statement-based,
not only when delete_all_rows() actually worked.
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r-- | sql/sql_delete.cc | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index ba1cce3abfe..c5b5958140b 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -40,7 +40,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ha_rows deleted; uint usable_index= MAX_KEY; SELECT_LEX *select_lex= &thd->lex->select_lex; - bool ha_delete_row_bypassed= 0; + bool ha_delete_all_rows= 0; DBUG_ENTER("mysql_delete"); if (open_and_lock_tables(thd, table_list)) @@ -79,17 +79,16 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, !(table->triggers && table->triggers->has_delete_triggers())) { ha_rows const maybe_deleted= table->file->records; + ha_delete_all_rows= 1; if (!(error=table->file->delete_all_rows())) { error= -1; // ok deleted= maybe_deleted; - ha_delete_row_bypassed= 1; goto cleanup; } if (error != HA_ERR_WRONG_COMMAND) { table->file->print_error(error,MYF(0)); - ha_delete_row_bypassed= 1; error=0; goto cleanup; } @@ -200,6 +199,16 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, init_ftfuncs(thd, select_lex, 1); thd->proc_info="updating"; will_batch= !table->file->start_bulk_delete(); + + /* + Save the thread options before clearing the OPTION_BIN_LOG, + effectively disabling the binary log (unless it was already + disabled, of course). + */ + ulonglong const saved_options= thd->options; + if (ha_delete_all_rows) + thd->options&= ~static_cast<ulonglong>(OPTION_BIN_LOG); + while (!(error=info.read_record(&info)) && !thd->killed && !thd->net.report_error) { @@ -290,6 +299,13 @@ cleanup: delete select; transactional_table= table->file->has_transactions(); + + /* + Restore the saved value of the OPTION_BIN_LOG bit in the thread + options before executing binlog_query() below. + */ + thd->options|= (saved_options & OPTION_BIN_LOG); + /* See similar binlogging code in sql_update.cc, for comments */ if ((error < 0) || (deleted && !transactional_table)) { @@ -304,9 +320,9 @@ cleanup: delete specific rows which we might log row-based. */ THD::enum_binlog_query_type const - query_type(ha_delete_row_bypassed ? - THD::STMT_QUERY_TYPE : - THD::ROW_QUERY_TYPE); + query_type(ha_delete_all_rows ? + THD::STMT_QUERY_TYPE : + THD::ROW_QUERY_TYPE); int log_result= thd->binlog_query(query_type, thd->query, thd->query_length, transactional_table, FALSE); |