List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:September 18 2008 3:53pm
Subject:bzr commit into mysql-5.1-bugteam branch (gluh:2682) Bug#37460
View as plain text  
#At file:///home/gluh/MySQL/Bazaar/mysql-5.0-bug-37460/

 2682 Sergey Glukhov	2008-09-18
      Bug #37460 Assertion failed: !table->file || table->file->inited == handler::NONE
      The problem:
      At the end of execution top level join execution
      we cleanup this join with true argument.
      It leads to underlying join cleanup(subquery) with true argument too and
      sets join->table to 0 for underlying join.
      Next subquery calls do not execute 'file->ha_index_or_rnd_end()
      (see  JOIN::cleanup func). It leads to assertion failure.
      The fix:
      Call cleanup_all_joins() for with 'true' argument only if
      subquery->is_uncacheable is false.
modified:
  mysql-test/r/subselect.result
  mysql-test/t/subselect.test
  sql/sql_select.cc

per-file messages:
  mysql-test/r/subselect.result
    test result
  mysql-test/t/subselect.test
    test case
  sql/sql_select.cc
    The problem:
    At the end of execution top level join execution
    we cleanup this join with true argument.
    It leads to underlying join cleanup(subquery) with true argument too and
    sets join->table to 0 for underlying join.
    Next subquery calls do not execute 'file->ha_index_or_rnd_end()
    (see  JOIN::cleanup func). It leads to assertion failure.
    The fix:
    Call cleanup_all_joins() for with 'true' argument only if
    subquery->is_uncacheable is false.
=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2008-07-26 20:44:07 +0000
+++ b/mysql-test/r/subselect.result	2008-09-18 15:53:05 +0000
@@ -4407,4 +4407,22 @@ pk	a
 3	30
 2	20
 DROP TABLE t1,t2;
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int, c int);
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+CREATE VIEW v1 AS
+SELECT t2.c as c FROM t1, t2
+WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+UPDATE v1 SET c=1;
+SELECT * FROM v1;
+c
+1
+1
+1
+1
+DROP VIEW v1;
+DROP TABLE t1,t2;
 End of 5.0 tests.

=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test	2008-07-26 20:44:07 +0000
+++ b/mysql-test/t/subselect.test	2008-09-18 15:53:05 +0000
@@ -3307,5 +3307,26 @@ SELECT * FROM t1
    WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b);
 DROP TABLE t1,t2;
 
+#
+# Bug#37460 Assertion failed:
+# !table->file || table->file->inited == handler::NONE
+#
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int, c int);
+
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+
+CREATE VIEW v1 AS
+  SELECT t2.c as c FROM t1, t2
+      WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+UPDATE v1 SET c=1;
+
+SELECT * FROM v1;
+DROP VIEW v1;
+DROP TABLE t1,t2;
+
 --echo End of 5.0 tests.
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-08-27 13:03:17 +0000
+++ b/sql/sql_select.cc	2008-09-18 15:53:05 +0000
@@ -6380,7 +6380,9 @@ void JOIN::join_free()
     for (sl= tmp_unit->first_select(); sl; sl= sl->next_select())
     {
       Item_subselect *subselect= sl->master_unit()->item;
-      bool full_local= full && (!subselect || subselect->is_evaluated());
+      bool full_local= full && (!subselect ||
+                                subselect->is_evaluated() &&
+                                !subselect->is_uncacheable());
       /*
         If this join is evaluated, we can fully clean it up and clean up all
         its underlying joins even if they are correlated -- they will not be

Thread
bzr commit into mysql-5.1-bugteam branch (gluh:2682) Bug#37460Sergey Glukhov18 Sep