summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2016-09-21 18:36:34 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2016-12-06 16:14:56 +0100
commitf988bcecfde819d3d3d2d7227789491fcc0ee430 (patch)
tree2465c7a929daa28e1e4c6bb85438238a6b34e05f /sql/sql_lex.cc
parent46dee0d1848e24e39fc236e78a438efa22356f8d (diff)
downloadmariadb-git-f988bcecfde819d3d3d2d7227789491fcc0ee430.tar.gz
MDEV-10776: Server crash on query
Exclude untouched in prepare phese subqueries from the select/unit tree because they became unreachable by execution.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 2462f0fea17..f2e7b4f7c3a 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -3486,12 +3486,28 @@ bool st_select_lex::add_index_hint (THD *thd, char *str, uint length)
bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
{
- for (SELECT_LEX_UNIT *un= first_inner_unit(); un; un= un->next_unit())
+ SELECT_LEX_UNIT *next_unit= NULL;
+ for (SELECT_LEX_UNIT *un= first_inner_unit();
+ un;
+ un= next_unit ? next_unit : un->next_unit())
{
Item_subselect *subquery_predicate= un->item;
-
+ next_unit= NULL;
+
if (subquery_predicate)
{
+ if (!subquery_predicate->fixed)
+ {
+ /*
+ This subquery was excluded as part of some expression so it is
+ invisible from all prepared expression.
+ */
+ next_unit= un->next_unit();
+ un->exclude_level();
+ if (next_unit)
+ continue;
+ break;
+ }
if (subquery_predicate->substype() == Item_subselect::IN_SUBS)
{
Item_in_subselect *in_subs= (Item_in_subselect*) subquery_predicate;