mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
A fix for Bug#32030 "DELETE does not return an error and deletes rows if
error evaluating WHERE" DELETE with a subquery in WHERE clause would sometimes ignore subquery evaluation error and proceed with deletion. The fix is to check for an error after evaluation of the WHERE clause in DELETE. Addressed review comments.
This commit is contained in:
@@ -35,6 +35,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
READ_RECORD info;
|
||||
bool using_limit=limit != HA_POS_ERROR;
|
||||
bool transactional_table, safe_update, const_cond;
|
||||
bool const_cond_result;
|
||||
ha_rows deleted= 0;
|
||||
uint usable_index= MAX_KEY;
|
||||
SELECT_LEX *select_lex= &thd->lex->select_lex;
|
||||
@@ -86,6 +87,12 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
|
||||
select_lex->no_error= thd->lex->ignore;
|
||||
|
||||
const_cond_result= const_cond && (!conds || conds->val_int());
|
||||
if (thd->is_error())
|
||||
{
|
||||
/* Error evaluating val_int(). */
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
Test if the user wants to delete all rows and deletion doesn't have
|
||||
any side-effects (because of triggers), so we can use optimized
|
||||
@@ -105,7 +112,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
- We should not be binlogging this statement row-based, and
|
||||
- there should be no delete triggers associated with the table.
|
||||
*/
|
||||
if (!using_limit && const_cond && (!conds || conds->val_int()) &&
|
||||
if (!using_limit && const_cond_result &&
|
||||
!(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) &&
|
||||
(thd->lex->sql_command == SQLCOM_TRUNCATE ||
|
||||
(!thd->current_stmt_binlog_row_based &&
|
||||
@@ -300,7 +307,7 @@ 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 && !error)
|
||||
if (thd->killed || thd->is_error())
|
||||
error= 1; // Aborted
|
||||
if (will_batch && (loc_error= table->file->end_bulk_delete()))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user