Commit ccc8dabc authored by unknown's avatar unknown

MWL#89: Cost-based choice between Materialization and IN->EXISTS transformation

Fixed a crash in Item_equal::fix_length_and_dec that was a result of the
architecture of the MWL#89 subquery optimization.

The injection of IN->EXISTS predicates for subqueries happened inside
make_join_statistics, after constant substitution, but before multiple
equality substitution done by substitute_for_best_equal_field. As a
result, when we called fix_fields for the WHERE clause after the injection
of IN->EXISTS predicates, Item_equal was not fixed, and it was in a state
not anticipated by Item_equal::fix_length_and_dec - the Item_equal
containted only a constant, and no fields at all.

The fix takes into account this new possible state when calling fix_fields.
parent 18ad3bdc
......@@ -5649,6 +5649,9 @@ longlong Item_equal::val_int()
Item_field *item_field;
if (cond_false)
return 0;
/* If there is a single constant and no fields, the equality is TRUE. */
if (const_item && !fields.elements)
return 1;
List_iterator_fast<Item_field> it(fields);
Item *item= const_item ? const_item : it++;
if ((null_value= item->null_value))
......@@ -5669,6 +5672,15 @@ longlong Item_equal::val_int()
void Item_equal::fix_length_and_dec()
{
Item *item= get_first(NULL);
if (!item)
{
/*
If there are no fields, there must be at least a constant, in which
case Item_equal::val_int evaluates to TRUE.
*/
DBUG_ASSERT(const_item);
return;
}
eval_item= cmp_item::get_comparator(item->result_type(),
item->collation.collation);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment