diff options
author | unknown <gkodinov/kgeorge@macbook.gmz> | 2007-02-23 18:49:41 +0200 |
---|---|---|
committer | unknown <gkodinov/kgeorge@macbook.gmz> | 2007-02-23 18:49:41 +0200 |
commit | 4e4152c56f70367a98717f2329ca1b8be39c2eb0 (patch) | |
tree | b505b29146f11fd016c6ab59c903d9eb4052ed2e /sql/sql_delete.cc | |
parent | 1f93b0c83af4b30b90e3a71eb6f2a663375feebc (diff) | |
download | mariadb-git-4e4152c56f70367a98717f2329ca1b8be39c2eb0.tar.gz |
Bug #26186:
When handling DELETE ... FROM if there is no
condition it is internally transformed to
TRUNCATE for more efficient execution by the
storage handler.
The check for validity of the optional ORDER BY
clause is done after the check for the above
optimization and will not be performed if the
optimization can be applied.
Moved the validity check for ORDER BY before
the optimization so it performed regardless of
the optimization.
mysql-test/r/delete.result:
Bug #26186: test case
mysql-test/t/delete.test:
Bug #26186: test case
sql/sql_delete.cc:
Bug #26186: do validity check of the ORDER BY
before deciding to skip it.
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r-- | sql/sql_delete.cc | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 749ee04493b..e4b013ef088 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -60,6 +60,27 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (mysql_prepare_delete(thd, table_list, &conds)) DBUG_RETURN(TRUE); + /* check ORDER BY even if it can be ignored */ + if (order && order->elements) + { + TABLE_LIST tables; + List<Item> fields; + List<Item> all_fields; + + bzero((char*) &tables,sizeof(tables)); + tables.table = table; + tables.alias = table_list->alias; + + if (select_lex->setup_ref_array(thd, order->elements) || + setup_order(thd, select_lex->ref_pointer_array, &tables, + fields, all_fields, (ORDER*) order->first)) + { + delete select; + free_underlaid_joins(thd, &thd->lex->select_lex); + DBUG_RETURN(TRUE); + } + } + const_cond= (!conds || conds->const_item()); safe_update=test(thd->options & OPTION_SAFE_UPDATES); if (safe_update && const_cond) @@ -148,23 +169,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { uint length= 0; SORT_FIELD *sortorder; - TABLE_LIST tables; - List<Item> fields; - List<Item> all_fields; ha_rows examined_rows; - - bzero((char*) &tables,sizeof(tables)); - tables.table = table; - tables.alias = table_list->alias; - - if (select_lex->setup_ref_array(thd, order->elements) || - setup_order(thd, select_lex->ref_pointer_array, &tables, - fields, all_fields, (ORDER*) order->first)) - { - delete select; - free_underlaid_joins(thd, &thd->lex->select_lex); - DBUG_RETURN(TRUE); - } if ((!select || table->quick_keys.is_clear_all()) && limit != HA_POS_ERROR) usable_index= get_index_for_order(table, (ORDER*)(order->first), limit); |