List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:December 3 2009 3:52pm
Subject:bzr commit into mysql-5.0-bugteam branch (joro:2859) Bug#48709
View as plain text  
#At file:///home/kgeorge/mysql/work/B48709-5.0-bugteam/ based on revid:epotemkin@stripped

 2859 Georgi Kodinov	2009-12-03
      Bug #48709: Assertion failed in sql_select.cc:11782:
       int join_read_key(JOIN_TAB*)
      
      The eq_ref access method TABLE_REF (accessed through 
      JOIN_TAB) to save state and to track if this is the 
      first row it finds or not.
      This state was not reset on subquery re-execution
      causing an assert.
      
      Fixed by resetting the state before the subquery 
      re-execution.

    modified:
      mysql-test/mysql-test-run.pl
      mysql-test/r/subselect.result
      mysql-test/t/subselect.test
      sql/sql_select.cc
=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2009-09-02 13:36:52 +0000
+++ b/mysql-test/mysql-test-run.pl	2009-12-03 15:52:32 +0000
@@ -5109,7 +5109,6 @@ sub valgrind_arguments {
   else
   {
     mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
-    mtr_add_arg($args, "--alignment=8");
     mtr_add_arg($args, "--leak-check=yes");
     mtr_add_arg($args, "--num-callers=16");
     mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)

=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2009-10-30 09:40:44 +0000
+++ b/mysql-test/r/subselect.result	2009-12-03 15:52:32 +0000
@@ -4502,4 +4502,29 @@ WHERE a = 230;
 MAX(b)	(SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
 NULL	0
 DROP TABLE t1, st1, st2;
+#
+# Bug #48709: Assertion failed in sql_select.cc:11782: 
+#   int join_read_key(JOIN_TAB*)
+#
+CREATE TABLE t1 (pk int PRIMARY KEY, int_key int);
+INSERT INTO t1 VALUES (10,1), (14,1);
+CREATE TABLE t2 (pk int PRIMARY KEY, int_key int);
+INSERT INTO t2 VALUES (3,3), (5,NULL), (7,3);
+# should have eq_ref for t1
+EXPLAIN
+SELECT * FROM t2 outr
+WHERE outr.int_key NOT IN (SELECT t1.pk FROM t1, t2)  
+ORDER BY outr.pk;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+x	x	outr	ALL	x	x	x	x	x	x
+x	x	t1	eq_ref	x	x	x	x	x	x
+x	x	t2	index	x	x	x	x	x	x
+# should not crash on debug binaries
+SELECT * FROM t2 outr
+WHERE outr.int_key NOT IN (SELECT t1.pk FROM t1, t2)  
+ORDER BY outr.pk;
+pk	int_key
+3	3
+7	3
+DROP TABLE t1,t2;
 End of 5.0 tests.

=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test	2009-10-30 09:40:44 +0000
+++ b/mysql-test/t/subselect.test	2009-12-03 15:52:32 +0000
@@ -3481,4 +3481,30 @@ WHERE a = 230;
 
 DROP TABLE t1, st1, st2;
 
+--echo #
+--echo # Bug #48709: Assertion failed in sql_select.cc:11782: 
+--echo #   int join_read_key(JOIN_TAB*)
+--echo #
+
+CREATE TABLE t1 (pk int PRIMARY KEY, int_key int);
+INSERT INTO t1 VALUES (10,1), (14,1);
+
+CREATE TABLE t2 (pk int PRIMARY KEY, int_key int);
+INSERT INTO t2 VALUES (3,3), (5,NULL), (7,3);
+
+--echo # should have eq_ref for t1
+--replace_column 1 x 2 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t2 outr
+WHERE outr.int_key NOT IN (SELECT t1.pk FROM t1, t2)  
+ORDER BY outr.pk;
+
+--echo # should not crash on debug binaries
+SELECT * FROM t2 outr
+WHERE outr.int_key NOT IN (SELECT t1.pk FROM t1, t2)  
+ORDER BY outr.pk;
+
+DROP TABLE t1,t2;
+
+
 --echo End of 5.0 tests.

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2009-11-12 17:13:08 +0000
+++ b/sql/sql_select.cc	2009-12-03 15:52:32 +0000
@@ -1553,6 +1553,11 @@ JOIN::reinit()
   if (join_tab_save)
     memcpy(join_tab, join_tab_save, sizeof(JOIN_TAB) * tables);
 
+  /* need to reset ref access state (see join_read_key) */
+  if (join_tab)
+    for (int i= 0; i < tables; i++)
+      join_tab->ref.key_err= TRUE;
+
   if (tmp_join)
     restore_tmp();
 


Attachment: [text/bzr-bundle] bzr/joro@sun.com-20091203155232-m1w4il7pb9mtl48r.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (joro:2859) Bug#48709Georgi Kodinov3 Dec
  • Re: bzr commit into mysql-5.0-bugteam branch (joro:2859) Bug#48709Kevin Lewis3 Dec