From cd34946657b18582ab3dc9c6ad45e66d1e9bf2e2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Feb 2011 18:46:31 +0200 Subject: Fix LP BUG#715034 Analysis: The failed assert is a result of calling Item_sum_distinct::clear() on an incomplete object for which Item_sum_distinct::setup() was not yet called. The reason is that JOIN::exec for the outer query calls JOIN::reinit() for all its subqueries, which in turn calls clear() for all aggregate functions of the subqueries. The call stack is: mysql_explain_union -> mysql_select -> JOIN::exec -> select_desribe -> mysql_explain_union -> mysql_select -> JOIN::reinit This assert doesn't fail in the main 5.3 because constant subqueries are being executed during the optimize phase of the outer query, thus the Unique object is created before calling JOIN::exec for the outer query, and Item_sum_distinct::clear() actually cleans the Unique object. Solution: The best solution is the obvious one - substitute the assert with a test whether Item_sum_distinct::tree is NULL. --- sql/item_sum.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/item_sum.cc') diff --git a/sql/item_sum.cc b/sql/item_sum.cc index f5fc52828c7..c2a75d755e6 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1050,9 +1050,10 @@ bool Item_sum_distinct::unique_walk_function(void *element) void Item_sum_distinct::clear() { DBUG_ENTER("Item_sum_distinct::clear"); - DBUG_ASSERT(tree != 0); /* we always have a tree */ + /* During EXPLAIN there is no tree because it is created during execution. */ + if (tree != 0) + tree->reset(); null_value= 1; - tree->reset(); is_evaluated= FALSE; DBUG_VOID_RETURN; } -- cgit v1.2.1