Commit 301a24e3 authored by unknown's avatar unknown

Bug #17896: MIN of CASE WHEN returns non-minimum value!

- after review fixes


sql/item_cmpfunc.cc:
  Bug #17896: MIN of CASE WHEN returns non-minimum value!
  - after review fixes.
parent f3726418
...@@ -39,19 +39,23 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems) ...@@ -39,19 +39,23 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems)
{ {
Item **item, **item_end; Item **item, **item_end;
/* Note: NULL items don't affect the result type */
*type= STRING_RESULT; *type= STRING_RESULT;
/* Skip beginning NULL items */ /* Skip beginning NULL items */
for (item= items, item_end= item + nitems; item < item_end; item++) for (item= items, item_end= item + nitems; item < item_end; item++)
{
if ((*item)->type() != Item::NULL_ITEM) if ((*item)->type() != Item::NULL_ITEM)
{ {
*type= (*item)->result_type(); *type= (*item)->result_type();
item++; item++;
break; break;
} }
}
/* Combine result types. Note: NULL items don't affect the result */
for (; item < item_end; item++) for (; item < item_end; item++)
{
if ((*item)->type() != Item::NULL_ITEM) if ((*item)->type() != Item::NULL_ITEM)
*type= item_store_type(type[0], (*item)->result_type()); *type= item_store_type(type[0], (*item)->result_type());
}
} }
static void agg_cmp_type(Item_result *type, Item **items, uint nitems) static void agg_cmp_type(Item_result *type, Item **items, uint nitems)
......
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