diff options
author | Igor Babaev <igor@askmonty.org> | 2016-02-09 12:35:59 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2016-02-09 12:35:59 -0800 |
commit | 2cfc450bf78c2d951729d1a0e8f731c0d987b1d5 (patch) | |
tree | 6c15f411927c9da723265d5f9891592390e97cea /sql/sql_delete.cc | |
parent | 7b50447aa6d051b8d14bb01ef14802cb8ffee223 (diff) | |
download | mariadb-git-bb-10.2-mdev8646.tar.gz |
This is the consolidated patch for mdev-8646:bb-10.2-mdev8646
"Re-factor the code for post-join operations".
The patch mainly contains the code ported from mysql-5.6 and
created for two essential architectural changes:
1. WL#5558: Resolve ORDER BY execution method at the optimization stage
2. WL#6071: Inline tmp tables into the nested loops algorithm
The first task was implemented for mysql-5.6 by Ole John Aske.
It allows to make all decisions on ORDER BY operation at the optimization
stage.
The second task implemented for mysql-5.6 by Evgeny Potemkin adds JOIN_TAB
nodes for post-join operations that require temporary tables. It allows
to execute these operations within the nested loops algorithm that used to
be used before this task only for join queries. Besides these task moves
all planning on the execution of these operations from the execution phase
to the optimization phase.
Some other re-factoring changes of mysql-5.6 were pulled in, mainly because
it was easier to pull them in than roll them back. In particular all
changes concerning Ref_ptr_array were incorporated.
The port required some changes in the MariaDB code that concerned the
functionality of EXPLAIN and ANALYZE. This was done mainly by Sergey
Petrunia.
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r-- | sql/sql_delete.cc | 26 |
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); |