diff options
author | Sergei Golubchik <serg@mariadb.org> | 2019-10-08 14:54:52 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2019-10-14 10:29:31 +0200 |
commit | 904dc93439c25568c7318d2b98b8a583faae5be8 (patch) | |
tree | 7536b6f73d0bf35572ba84bb223af2460caa48f0 | |
parent | 837ad9ab9760db83b2d117a6183519f18448b782 (diff) | |
download | mariadb-git-904dc93439c25568c7318d2b98b8a583faae5be8.tar.gz |
bugfix: PS and dependent subqueries
when there are nested subqueries, and a field in a subquery is
resolved as an outer reference to a table few levels up, all subqueries
the subquery with a reference and all subqueries up to subquery with
the table must be marked as dependent.
in the text protocol and PS-prepare step it happens in
Item_field::fix_outer_field in a loop that walks contexts
using context->outer_context.
in PS-execute step Item_field->cached_table is set and subqueries
are walked in a PS-only mark_select_range_as_dependent(),
which inconsistently walks SELECT_LEX'es using select_lex->outer_select().
Fix mark_select_range_as_dependent() to walk contexts, not SELECT_LEX'es,
to have the same logic both in prepare and execute steps.
This fixes a crash in main.insert_returning in --ps-protocol
-rw-r--r-- | sql/item.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc index 9c0fa56329b..7d2647e9a78 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5018,8 +5018,8 @@ void mark_select_range_as_dependent(THD *thd, SELECT_LEX *last_select, resolving) */ SELECT_LEX *previous_select= current_sel; - for (; previous_select->outer_select() != last_select; - previous_select= previous_select->outer_select()) + for (; previous_select->context.outer_select() != last_select; + previous_select= previous_select->context.outer_select()) { Item_subselect *prev_subselect_item= previous_select->master_unit()->item; |