summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc40
1 files changed, 25 insertions, 15 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index e2eccff7ef1..f6a1654ec74 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2010, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -53,7 +53,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
THD::killed_state killed_status= THD::NOT_KILLED;
DBUG_ENTER("mysql_delete");
bool save_binlog_row_based;
- bool skip_record;
THD::enum_binlog_query_type query_type=
thd->lex->sql_command == SQLCOM_TRUNCATE ?
@@ -310,9 +309,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
{
thd->examined_row_count++;
// thd->is_error() is tested to disallow delete row on error
- if (!select || (!select->skip_record(thd, &skip_record) && !skip_record))
+ if (!select || select->skip_record(thd) > 0)
{
-
if (triggers_applicable &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_BEFORE, FALSE))
@@ -348,8 +346,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
InnoDB it can fail in a FOREIGN KEY error or an
out-of-tablespace error.
*/
- error= 1;
- break;
+ if (!select_lex->no_error)
+ {
+ error= 1;
+ break;
+ }
}
}
else
@@ -751,7 +752,7 @@ multi_delete::~multi_delete()
}
-bool multi_delete::send_data(List<Item> &values)
+int multi_delete::send_data(List<Item> &values)
{
int secure_counter= delete_while_scanning ? -1 : 0;
TABLE_LIST *del_table;
@@ -1104,6 +1105,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
HA_CREATE_INFO create_info;
char path[FN_REFLEN + 1];
TABLE *table;
+ TABLE_LIST *tbl;
bool error;
uint path_length;
bool is_temporary_table= false;
@@ -1117,14 +1119,19 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
/* If it is a temporary table, close and regenerate it */
if (!dont_send_ok && (table= find_temporary_table(thd, table_list)))
{
- is_temporary_table= true;
- handlerton *table_type= table->s->db_type();
TABLE_SHARE *share= table->s;
+ handlerton *table_type= share->db_type();
+ is_temporary_table= true;
+
if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE))
goto trunc_by_del;
+ for (tbl= table_list; tbl; tbl= tbl->next_local)
+ tbl->deleting= TRUE; /* to trigger HA_PREPARE_FOR_DROP */
+
table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK);
-
+
+ create_info.options|= HA_LEX_CREATE_TMP_TABLE;
close_temporary_table(thd, table, 0, 0); // Don't free share
ha_create_table(thd, share->normalized_path.str,
share->db.str, share->table_name.str, &create_info, 1);
@@ -1132,7 +1139,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
if ((error= (int) !(open_temporary_table(thd, share->path.str,
share->db.str,
share->table_name.str, 1))))
- (void) rm_temporary_table(table_type, path);
+ (void) rm_temporary_table(table_type, share->path.str);
else
thd->thread_specific_used= TRUE;
@@ -1158,7 +1165,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_check_storage_engine_flag(ha_resolve_by_legacy_type(thd, table_type),
+ if (!ha_check_storage_engine_flag(ha_resolve_by_legacy_type(thd,
+ table_type),
HTON_CAN_RECREATE))
goto trunc_by_del;
@@ -1166,9 +1174,11 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
DBUG_RETURN(TRUE);
}
- // Remove the .frm extension AIX 5.2 64-bit compiler bug (BUG#16155): this
- // crashes, replacement works. *(path + path_length - reg_ext_length)=
- // '\0';
+ /*
+ Remove the .frm extension AIX 5.2 64-bit compiler bug (BUG#16155): this
+ crashes, replacement works. *(path + path_length - reg_ext_length)=
+ '\0';
+ */
path[path_length - reg_ext_length] = 0;
VOID(pthread_mutex_lock(&LOCK_open));
error= ha_create_table(thd, path, table_list->db, table_list->table_name,