diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result
index 5305c16c5d9e080ce65c43c50eefad95ef521ea6..dfd7750adaf866b1425d35950c210fadd36a4d6c 100644
--- a/mysql-test/r/func_set.result
+++ b/mysql-test/r/func_set.result
@@ -25,3 +25,6 @@ find_in_set("","a,b,c")	find_in_set("","a,b,c,")	find_in_set("",",a,b,c")
 select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
 find_in_set("abc","abc")	find_in_set("ab","abc")	find_in_set("abcd","abc")
 1	0	0
+select interval(null, 1, 10, 100);
+interval(null, 1, 10, 100)
+NULL
diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test
index cb1aa543d437564746a4912e08a779be5269ec7a..81f561989d5cf4c5411c9953a3ed01161a6554c3 100644
--- a/mysql-test/t/func_set.test
+++ b/mysql-test/t/func_set.test
@@ -15,3 +15,4 @@ select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N",""
 select elt(2,1),field(NULL,"a","b","c");
 select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
 select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
+select interval(null, 1, 10, 100);
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 5d47fa302f34d946d4727b8bb9509db2cb8cbdfb..731f9b61438ebdf0abe1c300744b5e3b3f2144e7 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;