mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge mkindahl@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into mysql.com:/users/mkindahl/bk/b15923-mysql-5.1-new
This commit is contained in:
@ -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,20 @@ 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;
|
||||
/*
|
||||
If all rows shall be deleted, we always log this statement-based
|
||||
(see [binlog], below), so we set this flag and test it below.
|
||||
*/
|
||||
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 +203,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 +303,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))
|
||||
{
|
||||
@ -299,14 +319,14 @@ cleanup:
|
||||
thd->clear_error();
|
||||
|
||||
/*
|
||||
If 'handler::delete_all_rows()' was called, we replicate
|
||||
statement-based; otherwise, 'ha_delete_row()' was used to
|
||||
delete specific rows which we might log row-based.
|
||||
[binlog]: If 'handler::delete_all_rows()' was called, we
|
||||
replicate statement-based; otherwise, 'ha_delete_row()' was
|
||||
used to 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);
|
||||
|
Reference in New Issue
Block a user