summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <ramil@mysql.com>2006-03-06 16:38:35 +0400
committerunknown <ramil@mysql.com>2006-03-06 16:38:35 +0400
commitf372641876e7a560ce661693bfc5d8e62cc5a19d (patch)
tree5665bf9d1cfd10c122d62ffc42b4876d2a4f15c9 /sql/item_cmpfunc.cc
parent4391f938922a7f62831481c350ad4a680c64c827 (diff)
downloadmariadb-git-f372641876e7a560ce661693bfc5d8e62cc5a19d.tar.gz
Fix for bug #17896: MIN of CASE WHEN returns non-minimum value!
sql/item_cmpfunc.cc: Fix for bug #17896: MIN of CASE WHEN returns non-minimum value! - NULL items should not affect the result type.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index f9aa220c181..57a3c9e5623 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -37,10 +37,21 @@ static Item_result item_store_type(Item_result a,Item_result b)
static void agg_result_type(Item_result *type, Item **items, uint nitems)
{
- uint i;
- type[0]= items[0]->result_type();
- for (i=1 ; i < nitems ; i++)
- type[0]= item_store_type(type[0], items[i]->result_type());
+ Item **item, **item_end;
+
+ /* Note: NULL items don't affect the result type */
+ *type= STRING_RESULT;
+ /* Skip beginning NULL items */
+ for (item= items, item_end= item + nitems; item < item_end; item++)
+ if ((*item)->type() != Item::NULL_ITEM)
+ {
+ *type= (*item)->result_type();
+ item++;
+ break;
+ }
+ for (; item < item_end; item++)
+ if ((*item)->type() != Item::NULL_ITEM)
+ *type= item_store_type(type[0], (*item)->result_type());
}
static void agg_cmp_type(Item_result *type, Item **items, uint nitems)