List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:April 22 2011 8:05am
Subject:bzr commit into mysql-trunk branch (sergey.glukhov:3335)
View as plain text  
#At file:///home/gluh/MySQL/mysql-trunk/ based on revid:sergey.vojtovich@stripped

 3335 Sergey Glukhov	2011-04-22 [merge]
      5.5 -> trunk merge
     @ mysql-test/r/having.result
        5.5 -> trunk merge
     @ mysql-test/t/having.test
        5.5 -> trunk merge
     @ sql/sql_select.cc
        5.5 -> trunk merge

    modified:
      mysql-test/r/having.result
      mysql-test/t/having.test
      sql/sql_select.cc
=== modified file 'mysql-test/r/having.result'
--- a/mysql-test/r/having.result	2010-07-23 17:51:11 +0000
+++ b/mysql-test/r/having.result	2011-04-22 08:05:02 +0000
@@ -547,6 +547,28 @@ FROM t1 JOIN t2 ON t2.f2 LIKE 'x'
 HAVING field1 < 7;
 field1
 DROP TABLE t1,t2;
+#
+# Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
+#
+CREATE TABLE t1 (f1 INT, f2 INT);
+INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2);
+CREATE TABLE t2 (f1 INT, f2 INT);
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1  >= 0
+ORDER BY t1.f1;
+f1
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1  >= 0
+ORDER BY t1.f1;
+f1
+SELECT t1.f1
+FROM t1
+HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1  >= 0
+ORDER BY t1.f1;
+f1
+DROP TABLE t1,t2;
 End of 5.1 tests
 #
 # BUG#46077 "wrong result: HAVING + ORDER BY + MyISAM + ICP

=== modified file 'mysql-test/t/having.test'
--- a/mysql-test/t/having.test	2010-07-23 17:51:11 +0000
+++ b/mysql-test/t/having.test	2011-04-22 08:05:02 +0000
@@ -564,6 +564,32 @@ HAVING field1 < 7;
 
 DROP TABLE t1,t2;
 
+--echo #
+--echo # Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
+--echo #
+
+CREATE TABLE t1 (f1 INT, f2 INT);
+INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2);
+CREATE TABLE t2 (f1 INT, f2 INT);
+
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1  >= 0
+ORDER BY t1.f1;
+
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1  >= 0
+ORDER BY t1.f1;
+
+SELECT t1.f1
+FROM t1
+HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1  >= 0
+ORDER BY t1.f1;
+
+DROP TABLE t1,t2;
+
+
 --echo End of 5.1 tests
 
 --echo #

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-04-15 08:11:49 +0000
+++ b/sql/sql_select.cc	2011-04-22 08:05:02 +0000
@@ -3228,7 +3228,7 @@ JOIN::exec()
 
       Item* sort_table_cond= make_cond_for_table(curr_join->tmp_having,
 						 used_tables,
-						 used_tables, 0);
+						 (table_map) 0, 0);
       if (sort_table_cond)
       {
 	if (!curr_table->select)
@@ -19148,6 +19148,42 @@ static bool test_if_ref(Item *root_cond,
   return 0;					// keep test
 }
 
+/**
+   Extract a condition that can be checked after reading given table
+
+   @param cond       Condition to analyze
+   @param tables     Tables for which "current field values" are available
+   @param used_table Table that we're extracting the condition for (may
+                     also include PSEUDO_TABLE_BITS, and may be zero)
+   @param exclude_expensive_cond  Do not push expensive conditions
+
+   @retval <>NULL Generated condition
+   @retval =NULL  Already checked, OR error
+
+   @details
+     Extract the condition that can be checked after reading the table
+     specified in 'used_table', given that current-field values for tables
+     specified in 'tables' bitmap are available.
+     If 'used_table' is 0
+     - extract conditions for all tables in 'tables'.
+     - extract conditions are unrelated to any tables
+       in the same query block/level(i.e. conditions
+       which have used_tables == 0).
+
+     The function assumes that
+     - Constant parts of the condition has already been checked.
+     - Condition that could be checked for tables in 'tables' has already
+     been checked.
+
+     The function takes into account that some parts of the condition are
+     guaranteed to be true by employed 'ref' access methods (the code that
+     does this is located at the end, search down for "EQ_FUNC").
+
+   @note
+     Make sure to keep the implementations of make_cond_for_table() and
+     make_cond_after_sjm() synchronized.
+     make_cond_for_info_schema() uses similar algorithm as well.
+*/ 
 
 /**
    Destructively replaces a sub-condition inside a condition tree. The

No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
Thread
bzr commit into mysql-trunk branch (sergey.glukhov:3335) Sergey Glukhov22 Apr