summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2011-09-28 17:20:43 +0300
committerunknown <timour@askmonty.org>2011-09-28 17:20:43 +0300
commitb53744b79ebb58dfc242638bfb4d9b8c01bb8251 (patch)
treeee9f3de7b74a6373957175acab5eb647288ec9a1 /sql/opt_sum.cc
parent92dd45fd02c4da3e5550704c79e089bc29989261 (diff)
downloadmariadb-git-b53744b79ebb58dfc242638bfb4d9b8c01bb8251.tar.gz
Fix bug lp:858148.
Analysis: The crash is a result of the same cause as all similar bugs (lp:827416, lp:718763, lp:778413, lp:806943, lp:611690). The general pattern is that some optimization requires the evaluation of some condition (e.g. the WHERE clause), and this condition contains a subquery, such that the subquery itself requires a temporary table for its execution. During the subquery execution the original tables in the FROM clause are replaced by the temporary table needed for the final GROUP or ORDER operation. All this happens during optimization of the outer query. Later when EXPLAIN is run for the subquery, explain attempts to print the name of the tables in the FROM clause, but it finds there a temporary table without a corresponding TABLE_LIST object. The attempt to print the name of a NULL table list results in a crash. Solution: This patch extends the fix to bug lp:702301, and dissalows constant substitution of aggregate functions if the filter condition used to check MIN/MAX keys is an expensive condition.
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index dc93548418a..7b4c48497fa 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -625,6 +625,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
/* Condition doesn't restrict the used table */
DBUG_RETURN(!cond->const_item());
}
+ else if (cond->is_expensive())
+ DBUG_RETURN(FALSE);
if (cond->type() == Item::COND_ITEM)
{
if (((Item_cond*) cond)->functype() == Item_func::COND_OR_FUNC)