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/item.cc | |
parent | f8bf2a0170b385bbba8f9f8dc97841f58229d39a (diff) | |
download | mariadb-git-68e0defc5be41e42f5f9d050a436a5f88277a586.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/item.cc')
-rw-r--r-- | sql/item.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc index 55d135c660e..42272fe0148 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4678,6 +4678,9 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, bool suppress_warning_output) { DBUG_ENTER("mark_as_dependent"); + DBUG_PRINT("info", ("current select: %d (%p) last: %d (%p)", + current->select_number, current, + (last ? last->select_number : 0), last)); /* store pointer on SELECT_LEX from which item is dependent */ if (mark_item && mark_item->can_be_depended) |