List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:April 26 2010 8:06pm
Subject:bzr commit into mysql-5.0-bugteam branch (Alexey.Kopytov:2858)
Bug#50335
View as plain text  
#At file:///data/src/bzr/bugteam/mysql-5.0-bugteam/ based on revid:joro@stripped

 2858 Alexey Kopytov	2010-04-27
      Backport of the fix for bug #50335 to 5.0.
      
      The problem was in an incorrect debug assertion. The expression
      used in the failing assertion states that when finding
      references matching ORDER BY expressions, there can be only one
      reference to a single table. But that does not make any sense,
      all test cases for this bug are valid examples with multiple
      identical WHERE expressions referencing the same table which
      are also present in the ORDER BY list.
      
      Fixed by removing the failing assertion. We also have to take
      care of the 'found' counter so that we count multiple
      references only once. We rely on this fact later in
      eq_ref_table().
     @ mysql-test/r/join.result
        Added a test case for bug #50335.
     @ mysql-test/t/join.test
        Added a test case for bug #50335.
     @ sql/sql_select.cc
        Removing the assertion in eq_ref_table() as it does not make
        any sense. We also have to take care of the 'found' counter so
        that we count multiple references only once. We rely on this
        fact later in eq_ref_table().

    modified:
      mysql-test/r/join.result
      mysql-test/t/join.test
      sql/sql_select.cc
=== modified file 'mysql-test/r/join.result'
--- a/mysql-test/r/join.result	2010-03-26 07:44:24 +0000
+++ b/mysql-test/r/join.result	2010-04-26 20:06:00 +0000
@@ -942,4 +942,14 @@ ROW(t1.b, 1111.11) <=> ROW('','');
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 DROP TABLE t1;
+#
+# Bug #50335: Assertion `!(order->used & map)' in eq_ref_table
+# 
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b));
+INSERT INTO t1 VALUES (0,0), (1,1);
+SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a;
+a	b	a	b
+0	0	0	0
+1	1	1	1
+DROP TABLE t1;
 End of 5.0 tests.

=== modified file 'mysql-test/t/join.test'
--- a/mysql-test/t/join.test	2010-03-26 07:44:24 +0000
+++ b/mysql-test/t/join.test	2010-04-26 20:06:00 +0000
@@ -736,4 +736,15 @@ WHERE ROW(t1.a, 1111.11) = ROW(1111.11, 
 ROW(t1.b, 1111.11) <=> ROW('','');
 DROP TABLE t1;
 
+--echo #
+--echo # Bug #50335: Assertion `!(order->used & map)' in eq_ref_table
+--echo # 
+
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b));
+INSERT INTO t1 VALUES (0,0), (1,1);
+
+SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a;
+
+DROP TABLE t1;
+
 --echo End of 5.0 tests.

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-03-26 07:44:24 +0000
+++ b/sql/sql_select.cc	2010-04-26 20:06:00 +0000
@@ -6720,9 +6720,11 @@ eq_ref_table(JOIN *join, ORDER *start_or
       }
       if (order)
       {
-	found++;
-	DBUG_ASSERT(!(order->used & map));
-	order->used|=map;
+        if (!(order->used & map))
+        {
+          found++;
+          order->used|= map;
+        }
 	continue;				// Used in ORDER BY
       }
       if (!only_eq_ref_tables(join,start_order, (*ref_item)->used_tables()))


Attachment: [text/bzr-bundle] bzr/alexey.kopytov@sun.com-20100426200600-op06qy98llzpzgl1.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (Alexey.Kopytov:2858)Bug#50335Alexey Kopytov26 Apr