summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <knielsen@mysql.com>2006-04-24 23:51:47 +0200
committerunknown <knielsen@mysql.com>2006-04-24 23:51:47 +0200
commit413256c814ad5099b07540bd064a83e37c09f24f (patch)
treec36acaddf0636985ab3b939b2bbad6b73d79d9c4 /sql/item_cmpfunc.cc
parent3e1ff238a7b67d04e721c3c89a7ccce57b0ea507 (diff)
parentf9216cdf8d40c0552382fd0788d03dc20db2d94c (diff)
downloadmariadb-git-413256c814ad5099b07540bd064a83e37c09f24f.tar.gz
Merge mysql.com:/usr/local/mysql/mysql-4.1
into mysql.com:/usr/local/mysql/mysql-5.0-mtr-fix mysql-test/mysql-test-run.pl: Auto merged mysql-test/t/case.test: Auto merged sql/item_cmpfunc.cc: Auto merged mysql-test/r/case.result: SCCS merged
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 590a98777dd..54e281a1f14 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -41,10 +41,25 @@ 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;
+
+ *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;
+ }
+ }
+ /* Combine result types. Note: NULL items don't affect the result */
+ for (; item < item_end; item++)
+ {
+ if ((*item)->type() != Item::NULL_ITEM)
+ *type= item_store_type(type[0], (*item)->result_type());
+ }
}