From 945f12cf8fc361844f3553599795beb549fc8c1d Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 19 Oct 2011 23:28:37 -0700 Subject: Fixed LP bug #877316. This bug happened due to incompleteness of the fix for bug 872735: the occurrences of the fields in the conditions of correlated subqueries were not taken into account when recalculating covering keys bit maps. --- mysql-test/t/derived_view.test | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'mysql-test/t/derived_view.test') diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test index 044f6a1704f..d3ddc17de3c 100644 --- a/mysql-test/t/derived_view.test +++ b/mysql-test/t/derived_view.test @@ -946,6 +946,32 @@ SELECT * FROM t3 DROP VIEW v1; DROP TABLE t1,t2,t3; +--echo # +--echo # LP bug #877316: query over a view with correlated subquery in WHERE +--echo # + +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)) ; +INSERT INTO t1 VALUES (18,2), (19,9); + +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (10,8), (5,10); + +CREATE VIEW v1 AS SELECT * FROM t1; + +SELECT t1.a FROM t1 + WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < t1.b); +EXPLAIN +SELECT t1.a FROM t1 + WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < t1.b); + +SELECT v1.a FROM v1 + WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < v1.b); +EXPLAIN +SELECT v1.a FROM v1 + WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < v1.b); + +DROP VIEW v1; +DROP TABLE t1,t2; # The following command must be the last one the file set optimizer_switch=@exit_optimizer_switch; -- cgit v1.2.1