← Back to team overview

maria-developers team mailing list archive

Igor please review: [Commits] Rev 2926: BUG#724275: Crash in JOIN::optimize in maria-5.3 in file:///home/psergey/dev2/5.3-2/]

 

Hello Igor,

Could you please review the below:

----- Forwarded message from Sergey Petrunya <psergey@xxxxxxxxxxxx> -----

From: Sergey Petrunya <psergey@xxxxxxxxxxxx>
To: commits@xxxxxxxxxxx
X-Mailer: mail (GNU Mailutils 1.2)
Date: Tue,  1 Mar 2011 00:30:02 +0300 (MSK)
Subject: [Commits] Rev 2926: BUG#724275: Crash in JOIN::optimize in
	maria-5.3 in file:///home/psergey/dev2/5.3-2/

At file:///home/psergey/dev2/5.3-2/

------------------------------------------------------------
revno: 2926
revision-id: psergey@xxxxxxxxxxxx-20110228212959-hl3selurcdou7d22
parent: igor@xxxxxxxxxxxx-20110227181411-k81vmi35o0no21ab
committer: Sergey Petrunya <psergey@xxxxxxxxxxxx>
branch nick: 5.3-2
timestamp: Tue 2011-03-01 00:29:59 +0300
message:
  BUG#724275: Crash in JOIN::optimize in maria-5.3
  - Make equality-substitution-for-ref-access code in JOIN::optimize() treat join_tab->ref.key_copy correctly
    (in the way create_ref_for_key() has filled it).
=== modified file 'mysql-test/r/join.result'
--- a/mysql-test/r/join.result	2010-10-30 13:07:45 +0000
+++ b/mysql-test/r/join.result	2011-02-28 21:29:59 +0000
@@ -1251,3 +1251,37 @@
 Handler_read_rnd_next	1
 DROP TABLE t1, t2;
 End of 5.1 tests
+#
+# BUG#724275: Crash in JOIN::optimize in maria-5.3
+#
+create table t1 (a int);
+insert into t1 values (1),(2);
+insert into t1 select * from t1;
+create table t2 (a int, b int, key(a,b));
+insert into t2 values (1,1),(1,2),(1,3),(1,4),(2,5),(2,6),(2,7),(2,8),(2,9);
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+create table t3 (a int, b int, key(a));
+insert into t3 values (1,1),(2,2);
+select * from 
+t3 straight_join t1 straight_join t2 force index(a) 
+where t2.a=1 and t2.b=t1.a and t1.a=t3.b and t3.a=1;
+a	b	a	a	b
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+1	1	1	1	1
+drop table t1,t2,t3;

=== modified file 'mysql-test/t/join.test'
--- a/mysql-test/t/join.test	2010-10-30 13:07:45 +0000
+++ b/mysql-test/t/join.test	2011-02-28 21:29:59 +0000
@@ -941,3 +941,26 @@
 DROP TABLE t1, t2;
 
 --echo End of 5.1 tests
+
+--echo #
+--echo # BUG#724275: Crash in JOIN::optimize in maria-5.3
+--echo #
+
+create table t1 (a int);
+insert into t1 values (1),(2);
+insert into t1 select * from t1;
+
+create table t2 (a int, b int, key(a,b));
+insert into t2 values (1,1),(1,2),(1,3),(1,4),(2,5),(2,6),(2,7),(2,8),(2,9);
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+insert into t2 select * from t2;
+
+create table t3 (a int, b int, key(a));
+insert into t3 values (1,1),(2,2);
+select * from 
+  t3 straight_join t1 straight_join t2 force index(a) 
+where t2.a=1 and t2.b=t1.a and t1.a=t3.b and t3.a=1;
+
+drop table t1,t2,t3;
+

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-02-27 18:14:11 +0000
+++ b/sql/sql_select.cc	2011-02-28 21:29:59 +0000
@@ -1056,6 +1056,7 @@
   */
   for (JOIN_TAB *tab= join_tab + const_tables; tab < join_tab + tables; tab++)
   {
+    uint key_copy_index=0;
     for (uint i=0; i < tab->ref.key_parts; i++)
     {
       
@@ -1071,13 +1072,14 @@
       {
         *ref_item_ptr= ref_item;
         Item *item= ref_item->real_item();
-        store_key *key_copy= tab->ref.key_copy[i];
+        store_key *key_copy= tab->ref.key_copy[key_copy_index];
         if (key_copy->type() == store_key::FIELD_STORE_KEY)
 	{
           store_key_field *field_copy= ((store_key_field *)key_copy);
           field_copy->change_source_field((Item_field *) item);
         }
       }
+      key_copy_index++;
     }
   }   
 

_______________________________________________
commits mailing list
commits@xxxxxxxxxxx
https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits

----- End forwarded message -----

-- 
BR
 Sergey
-- 
Sergey Petrunia, Software Developer
Monty Program AB, http://askmonty.org
Blog: http://s.petrunia.net/blog



Follow ups