MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:eugene Date:July 11 2006 9:52pm
Subject:bk commit into 4.1 tree (evgen:1.2516) BUG#18503
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of evgen. When evgen 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@stripped, 2006-07-12 01:52:18+04:00, evgen@stripped +3 -0
  Fixed bug#18503: Queries with a quantified subquery returning empty set
  may return a wrong result.
  
  An Item_sum_hybrid object has the was_values flag which indicates whether any
  values were added to the sum function. By default it is set to true and reset
  to false on any no_rows_in_result() call. This method is called only in
  return_zero_rows() function. An ALL/ANY subquery can be optimized by MIN/MAX
  optimization. The was_values flag is used to indicate whether the subquery
  has returned at least one row. This bug occurs because return_zero_rows() is
  called only when we know that the select will return zero rows before
  starting any scans but often such information is not known.
  In the reported case the return_zero_rows() function is not called and
  the was_values flag is not reset to false and yet the subquery return no rows
  Item_func_not_all and Item_func_nop_all functions return a wrong
  comparison result.
  
  The end_send_group() function now calls no_rows_in_result() for each item
  in the fields_list if there is no rows were found for the (sub)query.

  mysql-test/r/subselect.result@stripped, 2006-07-12 01:41:19+04:00, evgen@stripped +15 -0
    Added test case for bug#18503: Queries with a quantified subquery returning empty set may return a wrong result.
    

  mysql-test/t/subselect.test@stripped, 2006-07-12 01:41:01+04:00, evgen@stripped +14 -0
    Added test case for bug#18503: Queries with a quantified subquery returning empty set may return a wrong result.

  sql/sql_select.cc@stripped, 2006-07-12 01:41:22+04:00, evgen@stripped +5 -0
    Fixed bug#18503: Queries with a quantified subquery returning empty set may return a wrong result.
    
    The end_send_group() function now calls no_rows_in_result() for each item
    in the fields_list if there is no matching rows were found.

# 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:	evgen
# Host:	moonbone.local
# Root:	/work/18503-bug-4.1-mysql

--- 1.456/sql/sql_select.cc	2006-07-12 01:52:21 +04:00
+++ 1.457/sql/sql_select.cc	2006-07-12 01:52:21 +04:00
@@ -6746,8 +6746,13 @@
 	{
 	  if (!join->first_record)
 	  {
+            List_iterator_fast<Item> it(*join->fields);
+            Item *item;
 	    /* No matching rows for group function */
 	    join->clear();
+
+            while ((item= it++))
+              item->no_rows_in_result();
 	  }
 	  if (join->having && join->having->val_int() == 0)
 	    error= -1;				// Didn't satisfy having

--- 1.175/mysql-test/r/subselect.result	2006-07-12 01:52:21 +04:00
+++ 1.176/mysql-test/r/subselect.result	2006-07-12 01:52:21 +04:00
@@ -2835,3 +2835,18 @@
 4
 DROP TABLE t1,t2,t3;
 purge master logs before (select adddate(current_timestamp(), interval -4 day));
+CREATE TABLE t1 (f1 INT);
+CREATE TABLE t2 (f2 INT);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2);
+f1
+1
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2 WHERE 1=0);
+f1
+1
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2 WHERE f2=0);
+f1
+1
+DROP TABLE t1, t2;

--- 1.153/mysql-test/t/subselect.test	2006-07-12 01:52:21 +04:00
+++ 1.154/mysql-test/t/subselect.test	2006-07-12 01:52:21 +04:00
@@ -1820,4 +1820,18 @@
 
 purge master logs before (select adddate(current_timestamp(), interval -4 day));
 
+
+#
+# Bug#18503: Queries with a quantified subquery returning empty set may
+# return a wrong result. 
+#
+CREATE TABLE t1 (f1 INT);
+CREATE TABLE t2 (f2 INT);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2 WHERE 1=0);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2 WHERE f2=0);
+DROP TABLE t1, t2;
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (evgen:1.2516) BUG#18503eugene15 Jul