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.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index f49a053918b..3377a6736a0 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -259,7 +259,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
DBUG_RETURN(TRUE);
}
- if (!(table= table_list->table) || !table->created)
+ if (!(table= table_list->table) || !table->is_created())
{
my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
table_list->view_db.str, table_list->view_name.str);
@@ -488,10 +488,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
{
ha_rows examined_rows;
ha_rows found_rows;
- uint length= 0;
- SORT_FIELD *sortorder;
{
+ Filesort fsort(order, HA_POS_ERROR, select);
DBUG_ASSERT(query_plan.index == MAX_KEY);
table->sort.io_cache= (IO_CACHE *) my_malloc(sizeof(IO_CACHE),
MYF(MY_FAE | MY_ZEROFILL |
@@ -499,13 +498,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
Filesort_tracker *fs_tracker=
thd->lex->explain->get_upd_del_plan()->filesort_tracker;
- if (!(sortorder= make_unireg_sortorder(thd, order, &length, NULL)) ||
- (table->sort.found_records= filesort(thd, table, sortorder, length,
- select, HA_POS_ERROR,
- true,
+ if ((table->sort.found_records= filesort(thd, table, &fsort, true,
&examined_rows, &found_rows,
fs_tracker))
- == HA_POS_ERROR)
+ == HA_POS_ERROR)
{
delete select;
free_underlaid_joins(thd, &thd->lex->select_lex);
@@ -517,7 +513,14 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
so we don't need the where clause
*/
delete select;
- free_underlaid_joins(thd, select_lex);
+
+ /*
+ If we are not in DELETE ... RETURNING, we can free subqueries. (in
+ DELETE ... RETURNING we can't, because the RETURNING part may have
+ a subquery in it)
+ */
+ if (!with_select)
+ free_underlaid_joins(thd, select_lex);
select= 0;
}
}
@@ -745,7 +748,7 @@ send_nothing_and_leave:
wild_num - number of wildcards used in optional SELECT clause
field_list - list of items in optional SELECT clause
conds - conditions
-
+l
RETURN VALUE
FALSE OK
TRUE error
@@ -766,7 +769,8 @@ send_nothing_and_leave:
DELETE_ACL, SELECT_ACL, TRUE))
DBUG_RETURN(TRUE);
if ((wild_num && setup_wild(thd, table_list, field_list, NULL, wild_num)) ||
- setup_fields(thd, NULL, field_list, MARK_COLUMNS_READ, NULL, 0) ||
+ setup_fields(thd, Ref_ptr_array(),
+ field_list, MARK_COLUMNS_READ, NULL, 0) ||
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
setup_ftfuncs(select_lex))
DBUG_RETURN(TRUE);