summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
diff options
context:
space:
mode:
authorunknown <sanja@montyprogram.com>2013-11-11 20:38:04 +0200
committerunknown <sanja@montyprogram.com>2013-11-11 20:38:04 +0200
commitdfed447888e1ab71ec0c80b61459bde6ee6eaf66 (patch)
treeb921c0e431da431f8254f434f720fcc469547269 /sql/opt_subselect.cc
parent668a5a4ab814d14f95cfbda7776a1f05246dd52e (diff)
parentc98a054fdeab9c2d3a637cf4fce57a2f9756dcc8 (diff)
downloadmariadb-git-dfed447888e1ab71ec0c80b61459bde6ee6eaf66.tar.gz
merge 5.3->5.5
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r--sql/opt_subselect.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index c9bc0289ba9..d4cb33c759a 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -1268,11 +1268,11 @@ void get_delayed_table_estimates(TABLE *table,
@brief Replaces an expression destructively inside the expression tree of
the WHERE clase.
- @note Because of current requirements for semijoin flattening, we do not
- need to recurse here, hence this function will only examine the top-level
- AND conditions. (see JOIN::prepare, comment starting with "Check if the
- subquery predicate can be executed via materialization".
-
+ @note We substitute AND/OR structure because it was copied by
+ copy_andor_structure and some changes could be done in the copy but
+ should be left permanent, also there could be several layers of AND over
+ AND and OR over OR because ::fix_field() possibly is not called.
+
@param join The top-level query.
@param old_cond The expression to be replaced.
@param new_cond The expression to be substituted.
@@ -1300,13 +1300,20 @@ static bool replace_where_subcondition(JOIN *join, Item **expr,
Item *item;
while ((item= li++))
{
- if (item == old_cond)
+ if (item == old_cond)
{
li.replace(new_cond);
if (do_fix_fields)
new_cond->fix_fields(join->thd, li.ref());
return FALSE;
}
+ else if (item->type() == Item::COND_ITEM)
+ {
+ DBUG_ASSERT(!(*expr)->fixed);
+ replace_where_subcondition(join, li.ref(),
+ old_cond, new_cond,
+ do_fix_fields);
+ }
}
}
/*