[Commits] Rev 3156: BUG#818280: crash in do_copy_not_null() in maria-5.3 with semijoin in file:///home/psergey/dev2/5.3-push16/

Sergey Petrunya psergey at askmonty.org
Tue Aug 16 20:42:29 EEST 2011


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

------------------------------------------------------------
revno: 3156
revision-id: psergey at askmonty.org-20110816174225-gyw0dodlznn2edec
parent: sanja at askmonty.org-20110812113140-5jj5d2cdgzq1dbsy
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.3-push16
timestamp: Tue 2011-08-16 21:42:25 +0400
message:
  BUG#818280: crash in do_copy_not_null() in maria-5.3 with semijoin
  - Make simplify_joins() set maybe_null=FALSE for tables that were on the 
    inner sides of inner joins and then were moved to the inner sides of semi-joins.
=== modified file 'mysql-test/r/subselect_sj.result'
--- a/mysql-test/r/subselect_sj.result	2011-08-09 05:02:10 +0000
+++ b/mysql-test/r/subselect_sj.result	2011-08-16 17:42:25 +0000
@@ -1715,4 +1715,18 @@
 0	NULL	NULL	NULL
 DROP TABLE t1, t2, t3, t4;
 set @tmp803457=@@optimizer_switch;
+#
+# BUG#818280: crash in do_copy_not_null() in maria-5.3 with semijoin
+#
+CREATE TABLE t1 ( c1 int NOT NULL , c2 int NOT NULL, PRIMARY KEY (c1)) ;
+INSERT IGNORE INTO t1 VALUES (2,7),(1,3),(5,6);
+CREATE TABLE t3 ( c1 int NOT NULL , c2 int NOT NULL, PRIMARY KEY (c1)) ;
+INSERT IGNORE INTO t3 VALUES (2,7),(1,3),(5,6);
+CREATE TABLE t2 ( c1 int NOT NULL , c5 int NOT NULL );
+INSERT IGNORE INTO t2 VALUES (2,2),(2,2),(5,6);
+SELECT * FROM t1 WHERE c1 IN ( SELECT t3.c1 FROM t3 LEFT JOIN t2 ON t2 .c1 = t3 .c1 WHERE t2.c5 != 0 );
+c1	c2
+2	7
+5	6
+DROP TABLE t1, t2, t3;
 set optimizer_switch=@subselect_sj_tmp;

=== modified file 'mysql-test/r/subselect_sj_jcl6.result'
--- a/mysql-test/r/subselect_sj_jcl6.result	2011-08-09 05:02:10 +0000
+++ b/mysql-test/r/subselect_sj_jcl6.result	2011-08-16 17:42:25 +0000
@@ -1726,6 +1726,20 @@
 0	NULL	NULL	NULL
 DROP TABLE t1, t2, t3, t4;
 set @tmp803457=@@optimizer_switch;
+#
+# BUG#818280: crash in do_copy_not_null() in maria-5.3 with semijoin
+#
+CREATE TABLE t1 ( c1 int NOT NULL , c2 int NOT NULL, PRIMARY KEY (c1)) ;
+INSERT IGNORE INTO t1 VALUES (2,7),(1,3),(5,6);
+CREATE TABLE t3 ( c1 int NOT NULL , c2 int NOT NULL, PRIMARY KEY (c1)) ;
+INSERT IGNORE INTO t3 VALUES (2,7),(1,3),(5,6);
+CREATE TABLE t2 ( c1 int NOT NULL , c5 int NOT NULL );
+INSERT IGNORE INTO t2 VALUES (2,2),(2,2),(5,6);
+SELECT * FROM t1 WHERE c1 IN ( SELECT t3.c1 FROM t3 LEFT JOIN t2 ON t2 .c1 = t3 .c1 WHERE t2.c5 != 0 );
+c1	c2
+2	7
+5	6
+DROP TABLE t1, t2, t3;
 set optimizer_switch=@subselect_sj_tmp;
 #
 # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off

=== modified file 'mysql-test/t/subselect_sj.test'
--- a/mysql-test/t/subselect_sj.test	2011-07-21 15:14:34 +0000
+++ b/mysql-test/t/subselect_sj.test	2011-08-16 17:42:25 +0000
@@ -1555,5 +1555,21 @@
 DROP TABLE t1, t2, t3, t4;
 set @tmp803457=@@optimizer_switch;
 
+--echo #
+--echo # BUG#818280: crash in do_copy_not_null() in maria-5.3 with semijoin
+--echo #
+CREATE TABLE t1 ( c1 int NOT NULL , c2 int NOT NULL, PRIMARY KEY (c1)) ;
+INSERT IGNORE INTO t1 VALUES (2,7),(1,3),(5,6);
+
+CREATE TABLE t3 ( c1 int NOT NULL , c2 int NOT NULL, PRIMARY KEY (c1)) ;
+INSERT IGNORE INTO t3 VALUES (2,7),(1,3),(5,6);
+
+CREATE TABLE t2 ( c1 int NOT NULL , c5 int NOT NULL );
+INSERT IGNORE INTO t2 VALUES (2,2),(2,2),(5,6);
+
+SELECT * FROM t1 WHERE c1 IN ( SELECT t3.c1 FROM t3 LEFT JOIN t2 ON t2 .c1 = t3 .c1 WHERE t2.c5 != 0 );
+
+DROP TABLE t1, t2, t3;
+
 # The following command must be the last one the file 
 set optimizer_switch=@subselect_sj_tmp;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-08-09 07:28:57 +0000
+++ b/sql/sql_select.cc	2011-08-16 17:42:25 +0000
@@ -11928,6 +11928,18 @@
          leave it intact (otherwise it is flattened)
        */
       join->select_lex->sj_nests.push_back(table);
+
+      /* 
+        Also, walk through semi-join children and mark those that are now
+        top-level
+      */
+      TABLE_LIST *tbl;
+      List_iterator<TABLE_LIST> it(nested_join->join_list);
+      while ((tbl= it++))
+      {
+        if (!tbl->on_expr && tbl->table)
+          tbl->table->maybe_null= FALSE;
+      }
     }
     else if (nested_join && !table->on_expr)
     {



More information about the commits mailing list