mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.1
into dl145h.mysql.com:/data0/mkindahl/mysql-5.1-new-rpl
This commit is contained in:
@ -39,6 +39,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
ha_rows deleted= 0;
|
||||
uint usable_index= MAX_KEY;
|
||||
SELECT_LEX *select_lex= &thd->lex->select_lex;
|
||||
THD::killed_state killed_status= THD::NOT_KILLED;
|
||||
DBUG_ENTER("mysql_delete");
|
||||
|
||||
if (open_and_lock_tables(thd, table_list))
|
||||
@ -307,7 +308,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
else
|
||||
table->file->unlock_row(); // Row failed selection, release lock on it
|
||||
}
|
||||
if (thd->killed || thd->is_error())
|
||||
killed_status= thd->killed;
|
||||
if (killed_status == THD::NOT_KILLED || thd->is_error())
|
||||
error= 1; // Aborted
|
||||
if (will_batch && (loc_error= table->file->end_bulk_delete()))
|
||||
{
|
||||
@ -352,13 +354,12 @@ cleanup:
|
||||
thd->transaction.stmt.modified_non_trans_table= TRUE;
|
||||
|
||||
/* See similar binlogging code in sql_update.cc, for comments */
|
||||
if ((error < 0) || (deleted && !transactional_table))
|
||||
if ((error < 0) || thd->transaction.stmt.modified_non_trans_table)
|
||||
{
|
||||
if (mysql_bin_log.is_open())
|
||||
{
|
||||
if (error < 0)
|
||||
thd->clear_error();
|
||||
|
||||
/*
|
||||
[binlog]: If 'handler::delete_all_rows()' was called and the
|
||||
storage engine does not inject the rows itself, we replicate
|
||||
@ -367,7 +368,7 @@ cleanup:
|
||||
*/
|
||||
int log_result= thd->binlog_query(THD::ROW_QUERY_TYPE,
|
||||
thd->query, thd->query_length,
|
||||
transactional_table, FALSE);
|
||||
transactional_table, FALSE, killed_status);
|
||||
|
||||
if (log_result && transactional_table)
|
||||
{
|
||||
@ -548,7 +549,7 @@ bool mysql_multi_delete_prepare(THD *thd)
|
||||
multi_delete::multi_delete(TABLE_LIST *dt, uint num_of_tables_arg)
|
||||
: delete_tables(dt), deleted(0), found(0),
|
||||
num_of_tables(num_of_tables_arg), error(0),
|
||||
do_delete(0), transactional_tables(0), normal_tables(0)
|
||||
do_delete(0), transactional_tables(0), normal_tables(0), error_handled(0)
|
||||
{
|
||||
tempfiles= (Unique **) sql_calloc(sizeof(Unique *) * num_of_tables);
|
||||
}
|
||||
@ -727,12 +728,14 @@ void multi_delete::send_error(uint errcode,const char *err)
|
||||
/* First send error what ever it is ... */
|
||||
my_message(errcode, err, MYF(0));
|
||||
|
||||
/* If nothing deleted return */
|
||||
if (!deleted)
|
||||
/* the error was handled or nothing deleted and no side effects return */
|
||||
if (error_handled ||
|
||||
!thd->transaction.stmt.modified_non_trans_table && !deleted)
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
/* Something already deleted so we have to invalidate cache */
|
||||
query_cache_invalidate3(thd, delete_tables, 1);
|
||||
if (deleted)
|
||||
query_cache_invalidate3(thd, delete_tables, 1);
|
||||
|
||||
/*
|
||||
If rows from the first table only has been deleted and it is
|
||||
@ -752,12 +755,30 @@ void multi_delete::send_error(uint errcode,const char *err)
|
||||
*/
|
||||
error= 1;
|
||||
send_eof();
|
||||
DBUG_ASSERT(error_handled);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
DBUG_ASSERT(!normal_tables || !deleted || thd->transaction.stmt.modified_non_trans_table);
|
||||
|
||||
if (thd->transaction.stmt.modified_non_trans_table)
|
||||
{
|
||||
/*
|
||||
there is only side effects; to binlog with the error
|
||||
*/
|
||||
if (mysql_bin_log.is_open())
|
||||
{
|
||||
thd->binlog_query(THD::ROW_QUERY_TYPE,
|
||||
thd->query, thd->query_length,
|
||||
transactional_tables, FALSE);
|
||||
}
|
||||
thd->transaction.all.modified_non_trans_table= true;
|
||||
}
|
||||
DBUG_ASSERT(!normal_tables || !deleted ||
|
||||
thd->transaction.stmt.modified_non_trans_table);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Do delete from other tables.
|
||||
Returns values:
|
||||
@ -850,6 +871,7 @@ int multi_delete::do_deletes()
|
||||
|
||||
bool multi_delete::send_eof()
|
||||
{
|
||||
THD::killed_state killed_status= THD::NOT_KILLED;
|
||||
thd->proc_info="deleting from reference tables";
|
||||
|
||||
/* Does deletes for the last n - 1 tables, returns 0 if ok */
|
||||
@ -857,7 +879,7 @@ bool multi_delete::send_eof()
|
||||
|
||||
/* compute a total error to know if something failed */
|
||||
local_error= local_error || error;
|
||||
|
||||
killed_status= (local_error == 0)? THD::NOT_KILLED : thd->killed;
|
||||
/* reset used flags */
|
||||
thd->proc_info="end";
|
||||
|
||||
@ -869,7 +891,9 @@ bool multi_delete::send_eof()
|
||||
{
|
||||
query_cache_invalidate3(thd, delete_tables, 1);
|
||||
}
|
||||
if ((local_error == 0) || (deleted && normal_tables))
|
||||
DBUG_ASSERT(!normal_tables || !deleted ||
|
||||
thd->transaction.stmt.modified_non_trans_table);
|
||||
if ((local_error == 0) || thd->transaction.stmt.modified_non_trans_table)
|
||||
{
|
||||
if (mysql_bin_log.is_open())
|
||||
{
|
||||
@ -877,7 +901,7 @@ bool multi_delete::send_eof()
|
||||
thd->clear_error();
|
||||
if (thd->binlog_query(THD::ROW_QUERY_TYPE,
|
||||
thd->query, thd->query_length,
|
||||
transactional_tables, FALSE) &&
|
||||
transactional_tables, FALSE, killed_status) &&
|
||||
!normal_tables)
|
||||
{
|
||||
local_error=1; // Log write failed: roll back the SQL statement
|
||||
@ -886,7 +910,8 @@ bool multi_delete::send_eof()
|
||||
if (thd->transaction.stmt.modified_non_trans_table)
|
||||
thd->transaction.all.modified_non_trans_table= TRUE;
|
||||
}
|
||||
DBUG_ASSERT(!normal_tables || !deleted || thd->transaction.stmt.modified_non_trans_table);
|
||||
if (local_error != 0)
|
||||
error_handled= TRUE; // to force early leave from ::send_error()
|
||||
|
||||
/* Commit or rollback the current SQL statement */
|
||||
if (transactional_tables)
|
||||
|
Reference in New Issue
Block a user