[Commits] Rev 3090: Fix for LP bug#823169 in file:///home/bell/maria/bzr/work-maria-5.1-lpb823169/

sanja at askmonty.org sanja at askmonty.org
Tue Aug 9 16:10:44 EEST 2011


At file:///home/bell/maria/bzr/work-maria-5.1-lpb823169/

------------------------------------------------------------
revno: 3090
revision-id: sanja at askmonty.org-20110809131042-db0nx1soeci7o5wu
parent: knielsen at knielsen-hq.org-20110731202537-0v8qbzoy9ov2yy0q
committer: sanja at askmonty.org
branch nick: work-maria-5.1-lpb823169
timestamp: Tue 2011-08-09 16:10:42 +0300
message:
  Fix for LP bug#823169
  
  In max/min subquery we should ignore NULL values (if NULL is not the only value).
  I.e. when we are finding MAX NULL should be less then everything when we are finding
  min NULL should be greater then everything.
  Min part was correct, max is fixed by this patch.
-------------- next part --------------
=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2011-05-02 17:58:45 +0000
+++ b/mysql-test/r/subselect.result	2011-08-09 13:10:42 +0000
@@ -4779,3 +4779,15 @@ SELECT 1 as foo FROM t1 WHERE a < SOME
 );
 foo
 DROP TABLE t1;
+#
+# LP BUG#823169
+#
+CREATE TABLE t1 (a int(11), b varchar(1));
+INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g');
+SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b );
+a
+5
+SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 );
+a
+5
+DROP TABLE t1;

=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test	2011-05-02 17:58:45 +0000
+++ b/mysql-test/t/subselect.test	2011-08-09 13:10:42 +0000
@@ -3797,3 +3797,13 @@ SELECT 1 as foo FROM t1 WHERE a < SOME
   ); 
 
 DROP TABLE t1;
+
+--echo #
+--echo # LP BUG#823169
+--echo #
+CREATE TABLE t1 (a int(11), b varchar(1));
+INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g');
+
+SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b );
+SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 );
+DROP TABLE t1;

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-03-09 17:45:48 +0000
+++ b/sql/sql_class.cc	2011-08-09 13:10:42 +0000
@@ -2453,7 +2453,7 @@ bool select_max_min_finder_subselect::cm
   Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0);
   double val1= cache->val_real(), val2= maxmin->val_real();
   if (fmax)
-    return (cache->null_value && !maxmin->null_value) ||
+    return (maxmin->null_value && !cache->null_value) ||
       (!cache->null_value && !maxmin->null_value &&
        val1 > val2);
   return (maxmin->null_value && !cache->null_value) ||
@@ -2466,7 +2466,7 @@ bool select_max_min_finder_subselect::cm
   Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0);
   longlong val1= cache->val_int(), val2= maxmin->val_int();
   if (fmax)
-    return (cache->null_value && !maxmin->null_value) ||
+    return (maxmin->null_value && !cache->null_value) ||
       (!cache->null_value && !maxmin->null_value &&
        val1 > val2);
   return (maxmin->null_value && !cache->null_value) ||
@@ -2480,7 +2480,7 @@ bool select_max_min_finder_subselect::cm
   my_decimal cval, *cvalue= cache->val_decimal(&cval);
   my_decimal mval, *mvalue= maxmin->val_decimal(&mval);
   if (fmax)
-    return (cache->null_value && !maxmin->null_value) ||
+    return (maxmin->null_value && !cache->null_value) ||
       (!cache->null_value && !maxmin->null_value &&
        my_decimal_cmp(cvalue, mvalue) > 0) ;
   return (maxmin->null_value && !cache->null_value) ||
@@ -2499,7 +2499,7 @@ bool select_max_min_finder_subselect::cm
   val1= cache->val_str(&buf1);
   val2= maxmin->val_str(&buf1);
   if (fmax)
-    return (cache->null_value && !maxmin->null_value) ||
+    return (maxmin->null_value && !cache->null_value) ||
       (!cache->null_value && !maxmin->null_value &&
        sortcmp(val1, val2, cache->collation.collation) > 0) ;
   return (maxmin->null_value && !cache->null_value) ||



More information about the commits mailing list