List:Internals« Previous MessageNext Message »
From:sanja Date:August 18 2005 11:07am
Subject:bk commit into 5.0 tree (bell:1.1989) BUG#12509
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of bell. When bell does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1989 05/08/18 12:07:14 bell@stripped +4 -0
  stop on NULL comparison only if it is allowed (BUG#12509)

  sql/item_cmpfunc.h
    1.107 05/08/18 12:07:10 bell@stripped +3 -1
    support optimisation in case of processing WHERE/HAVING, where NULL and FALSE are
equal

  sql/item_cmpfunc.cc
    1.168 05/08/18 12:07:10 bell@stripped +22 -4
    stop on NULL comparison only if it is allowed

  mysql-test/t/row.test
    1.20 05/08/18 12:07:10 bell@stripped +6 -0
    Correct NULL handling in row comporison (BUG#12509)

  mysql-test/r/row.result
    1.23 05/08/18 12:07:10 bell@stripped +7 -1
    Correct NULL handling in row comporison

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	bell
# Host:	sanja.is.com.ua
# Root:	/home/bell/mysql/bk/work-bug2-5.0

--- 1.167/sql/item_cmpfunc.cc	2005-08-16 21:54:48 +03:00
+++ 1.168/sql/item_cmpfunc.cc	2005-08-18 12:07:10 +03:00
@@ -614,17 +614,35 @@
 int Arg_comparator::compare_row()
 {
   int res= 0;
+  bool was_null= 0;
   (*a)->bring_value();
   (*b)->bring_value();
   uint n= (*a)->cols();
   for (uint i= 0; i<n; i++)
   {
-    if ((res= comparators[i].compare()))
-      return res;
+    res= comparators[i].compare();
     if (owner->null_value)
-      return -1;
+    {
+      // NULL was compared
+      if (owner->abort_on_null)
+        return -1; // We do not need correct NULL returning
+      was_null= 1;
+      owner->null_value= 0;
+      res= 0;  // continue comparison (maybe we will meet explicit difference)
+    }
+    if (res)
+      return res;
+  }
+  if (was_null)
+  {
+    /*
+      There was NULL(s) in comparison in some parts, but there was not
+      explicit difference in other parts, so we have to return NULL
+    */
+    owner->null_value= 1;
+    return -1;
   }
-  return res;
+  return 0;
 }
 
 int Arg_comparator::compare_e_row()

--- 1.106/sql/item_cmpfunc.h	2005-08-13 08:12:56 +03:00
+++ 1.107/sql/item_cmpfunc.h	2005-08-18 12:07:10 +03:00
@@ -193,10 +193,11 @@
 protected:
   Arg_comparator cmp;
   String tmp_value1,tmp_value2;
+  bool abort_on_null;
 
 public:
   Item_bool_func2(Item *a,Item *b)
-    :Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1) {}
+    :Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1), abort_on_null(FALSE) {}
   void fix_length_and_dec();
   void set_cmp_func()
   {
@@ -210,6 +211,7 @@
   bool is_bool_func() { return 1; }
   CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
   uint decimal_precision() const { return 1; }
+  void top_level_item() { abort_on_null=1; }
 
   friend class  Arg_comparator;
 };

--- 1.22/mysql-test/r/row.result	2005-04-06 13:51:17 +03:00
+++ 1.23/mysql-test/r/row.result	2005-08-18 12:07:10 +03:00
@@ -58,7 +58,7 @@
 NULL
 SELECT (1,2,3)=(1,NULL,0);
 (1,2,3)=(1,NULL,0)
-NULL
+0
 SELECT ROW(1,2,3)=ROW(1,2,3);
 ROW(1,2,3)=ROW(1,2,3)
 1
@@ -174,4 +174,10 @@
 0
 SELECT ROW(NULL,10) <=> ROW(3,NULL);
 ROW(NULL,10) <=> ROW(3,NULL)
+0
+SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) =
ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as
`null` ;
+1	0	0	0	null
+1	0	0	0	NULL
+select row(NULL,1)=(2,0);
+row(NULL,1)=(2,0)
 0

--- 1.19/mysql-test/t/row.test	2005-07-28 16:12:35 +03:00
+++ 1.20/mysql-test/t/row.test	2005-08-18 12:07:10 +03:00
@@ -86,3 +86,9 @@
 SELECT ROW(NULL,10) <=> ROW(3,NULL);
 
 # End of 4.1 tests
+
+#
+# Correct NULL handling in row comporison (BUG#12509)
+#
+SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) =
ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as
`null` ;
+select row(NULL,1)=(2,0);
Thread
bk commit into 5.0 tree (bell:1.1989) BUG#12509sanja18 Aug