[Commits] b3b9153: Postreview

Oleksandr Byelkin sanja at mariadb.com
Wed Sep 28 23:24:25 EEST 2016


revision-id: b3b915350cb5585f59221a76dad2893da3fc2f65 (mariadb-5.5.52-3-gb3b9153)
parent(s): e1bd675446ccee64c81a0dd79dfb2b75f58c3726
committer: Oleksandr Byelkin
timestamp: 2016-09-28 22:24:24 +0200
message:

Postreview

---
 sql/item_subselect.cc |  2 +-
 sql/sql_lex.cc        | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 73b69f1..6427b0e 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -860,7 +860,7 @@ table_map Item_subselect::used_tables() const
 
 bool Item_subselect::const_item() const
 {
-  THD *thd= this->thd ? this->thd : current_thd;
+  DBUG_ASSERT(thd);
   return (thd->lex->context_analysis_only ?
           FALSE :
           forced_const || const_item_cache);
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index ee0e09a..129593c 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;


More information about the commits mailing list