#At file:///home/gluh/MySQL/bazaar/mysql-5.0-bug-37460/
2647 Sergey Glukhov 2008-08-07
The Bug#37460 Assertion failed: !table->file || table->file->inited ==handler::NONE(2nd version)
The problem:
subselect_single_select_engine on optimization stage is executed and
sets the 'executed' variable value to 'true'.
Because of that we call cleanup_all_joins() with 'true' argument in JOIN::join_free
and upper join sets lower join field 'table' to 0.
Next subquery calls do not execute 'file->ha_index_or_rnd_end()
(see JOIN::cleanup func). It leads to assertion failure.
The fix:
Set 'table' to 0 only for the current join and
do not touch underlying join 'table' values.
modified:
mysql-test/r/subselect.result
mysql-test/t/subselect.test
sql/sql_select.cc
per-file messages:
sql/sql_select.cc
The problem:
subselect_single_select_engine on optimization stage is executed and
sets the 'executed' variable value to 'true'.
Because of that we call cleanup_all_joins() with 'true' argument in JOIN::join_free
and upper join sets lower join field 'table' to 0.
Next subquery calls do not execute 'file->ha_index_or_rnd_end()
(see JOIN::cleanup func). It leads to assertion failure.
The fix:
Set 'table' to 0 only for the current join and
do not touch underlying join 'table' values.
=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result 2008-05-16 14:05:55 +0000
+++ b/mysql-test/r/subselect.result 2008-08-07 08:28:05 +0000
@@ -4396,4 +4396,22 @@ id select_type table type possible_keys
Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 AS `1` from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1))))
DROP TABLE t1;
+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-06-25 14:59:38 +0000
+++ b/mysql-test/t/subselect.test 2008-08-07 08:28:05 +0000
@@ -3295,5 +3295,25 @@ EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
DROP TABLE t1;
+#
+# 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-07-15 14:13:21 +0000
+++ b/sql/sql_select.cc 2008-08-07 08:28:05 +0000
@@ -6372,6 +6372,8 @@ void JOIN::join_free()
DBUG_ENTER("JOIN::join_free");
cleanup(full);
+ if (full)
+ table= 0;
for (tmp_unit= select_lex->first_inner_unit();
tmp_unit;
@@ -6449,7 +6451,6 @@ void JOIN::cleanup(bool full)
{
for (tab= join_tab, end= tab+tables; tab != end; tab++)
tab->cleanup();
- table= 0;
}
else
{