#At file:///home/gluh/MySQL/bazaar/mysql-5.0-bug-37460/
2647 Sergey Glukhov 2008-08-26
The Bug#37460 Assertion failed: !table->file || table->file->inited==handler::NONE(3rd 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:
Call cleanup_all_joins() with 'false' argument.
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:
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:
Call cleanup_all_joins() with 'false' argument.
=== 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-26 11:15:30 +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-26 11:15:30 +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-26 11:15:30 +0000
@@ -6389,7 +6389,7 @@ void JOIN::join_free()
... HAVING FALSE OR a IN (SELECT ...))
but all table cursors must be closed before the unlock.
*/
- sl->cleanup_all_joins(full_local);
+ sl->cleanup_all_joins(false);
/* Can't unlock if at least one JOIN is still needed */
can_unlock= can_unlock && full_local;
}