diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2021-04-12 15:46:23 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2021-04-12 15:59:23 +0200 |
commit | 68e0defc5be41e42f5f9d050a436a5f88277a586 (patch) | |
tree | 5148887c09c3a63b28b3f926b7ed7d5be62a61fc /sql/sql_select.cc | |
parent | f8bf2a0170b385bbba8f9f8dc97841f58229d39a (diff) | |
download | mariadb-git-bb-10.2-MDEV-25182.tar.gz |
MDEV-25182 Complex query in Store procedure corrupts resultsbb-10.2-MDEV-25182
At the second execution of the PS
1. mark_as_dependent() is called with the same parameters as at the first
execution (select#4 and select#3)
2. as outer_select (select#3) has been already merged at the first
execution of PS it cannot be reached using the outer_select() function
anymore (and so can not stop iteration).
3. as a result all selects towards the top level select including the
select for 'ca' are marked as uncacheable.
4. Marked uncacheable it executed incorrectly triggering filling its
temporary table several times and using freed memory at the end.
To avoid the problem we use name resolution context to go "up".
NOTE: problem also exists in 10.2 but has no visible effect on execution.
That is why the problem is fixed in 10.2.
The patch also add debug logging of important procedures and
better specify parameters types of st_select_lex::mark_as_dependent.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7bfbf719017..90c071803a1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12097,10 +12097,12 @@ ha_rows JOIN_TAB::get_examined_rows() bool JOIN_TAB::preread_init() { TABLE_LIST *derived= table->pos_in_table_list; + DBUG_ENTER("JOIN_TAB::preread_init"); + if (!derived || !derived->is_materialized_derived()) { preread_init_done= TRUE; - return FALSE; + DBUG_RETURN(FALSE); } /* Materialize derived table/view. */ @@ -12108,7 +12110,7 @@ bool JOIN_TAB::preread_init() derived->is_recursive_with_table()) && mysql_handle_single_derived(join->thd->lex, derived, DT_CREATE | DT_FILL)) - return TRUE; + DBUG_RETURN(TRUE); preread_init_done= TRUE; if (select && select->quick) @@ -12125,7 +12127,7 @@ bool JOIN_TAB::preread_init() if (table->fulltext_searched) init_ftfuncs(join->thd, join->select_lex, MY_TEST(join->order)); - return FALSE; + DBUG_RETURN(FALSE); } |