summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <ram@mysql.r18.ru>2003-07-10 15:27:02 +0500
committerunknown <ram@mysql.r18.ru>2003-07-10 15:27:02 +0500
commit830e53c8b18b78639833ae840ac92163a8d364e7 (patch)
tree2ae77da84a262f24ee441f387de2d473853c732d /sql/item_cmpfunc.cc
parent8a1a63de902123b91c8564c3c323d670814b038f (diff)
downloadmariadb-git-830e53c8b18b78639833ae840ac92163a8d364e7.tar.gz
Fix for the bug #803.
Now INTERVAL(NULL, N1, N2, ...) returns NULL.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 5d47fa302f3..731f9b61438 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -311,7 +311,7 @@ void Item_func_interval::split_sum_func(List<Item> &fields)
}
/*
- return -1 if null value,
+ return NULL if null value,
0 if lower than lowest
1 - arg_count if between args[n] and args[n+1]
arg_count+1 if higher than biggest argument
@@ -319,26 +319,28 @@ void Item_func_interval::split_sum_func(List<Item> &fields)
longlong Item_func_interval::val_int()
{
- double value=item->val();
+ double value= item->val();
if (item->null_value)
- return -1; // -1 if null /* purecov: inspected */
+ {
+ null_value= 1;
+ return -1;
+ }
if (intervals)
{ // Use binary search to find interval
- uint start,end;
- start=0; end=arg_count-1;
+ uint start= 0, end= arg_count - 1;
while (start != end)
{
- uint mid=(start+end+1)/2;
+ uint mid= (start + end + 1) / 2;
if (intervals[mid] <= value)
- start=mid;
+ start= mid;
else
- end=mid-1;
+ end= mid - 1;
}
- return (value < intervals[start]) ? 0 : start+1;
+ return (value < intervals[start]) ? 0 : start + 1;
}
if (args[0]->val() > value)
return 0;
- for (uint i=1 ; i < arg_count ; i++)
+ for (uint i= 1; i < arg_count; i++)
{
if (args[i]->val() > value)
return i;