diff options
author | Igor Babaev <igor@askmonty.org> | 2022-12-23 20:54:01 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2022-12-23 20:54:01 -0800 |
commit | cea5cdd0eb30444467420f91da10752cbe697d23 (patch) | |
tree | 07a7e87441d5e55d52cf6fcb4ba918c3a04a6c65 /sql/sql_union.cc | |
parent | a09612014a827dc3bc09ab50bbb1b6b0b930190e (diff) | |
download | mariadb-git-bb-10.11-MDEV-29971.tar.gz |
MDEV-29971 Re-design the upper level of handling SELECT statementsbb-10.11-MDEV-29971
The initial patch.
All tests from the main test suite passed.
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 0a92422676a..a61453d9d93 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1324,6 +1324,24 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, describe= additional_options & SELECT_DESCRIBE; + if (describe) + { + for (SELECT_LEX *sl= first_sl; sl; sl= sl->next_select()) + { + sl->set_explain_type(FALSE); + sl->options|= SELECT_DESCRIBE; + } + if (is_unit_op() || fake_select_lex) + { + if (union_needs_tmp_table() && fake_select_lex) + { + fake_select_lex->select_number= FAKE_SELECT_LEX_ID; // just for initialization + fake_select_lex->type= unit_operation_text[common_op()]; + fake_select_lex->options|= SELECT_DESCRIBE; + } + } + } + /* Save fake_select_lex in case we don't need it for anything but global parameters. @@ -2159,6 +2177,8 @@ bool st_select_lex_unit::exec() DBUG_ENTER("st_select_lex_unit::exec"); bool was_executed= executed; + describe= thd->lex->describe; + if (executed && !uncacheable && !describe) DBUG_RETURN(FALSE); executed= 1; @@ -2167,6 +2187,9 @@ bool st_select_lex_unit::exec() item->make_const(); saved_error= optimize(); + + if (outer_select() == NULL) + thd->accessed_rows_and_keys_at_exec_start= thd->accessed_rows_and_keys; create_explain_query_if_not_exists(thd->lex, thd->mem_root); @@ -2238,6 +2261,7 @@ bool st_select_lex_unit::exec() saved_error= sl->join->optimize(); } } + if (likely(!saved_error)) { records_at_start= table->file->stats.records; |