summaryrefslogtreecommitdiff
path: root/mysql-test/t/derived_view.test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-07-09 22:34:56 -0700
committerIgor Babaev <igor@askmonty.org>2011-07-09 22:34:56 -0700
commita515802c5b1bda9444a2d19b5725deeabeb5fb02 (patch)
tree2d4f1a37781f60f6af6307df89536a3c97209505 /mysql-test/t/derived_view.test
parent9e7495df836a93e610ccd1a9e9f6ce11930a7767 (diff)
downloadmariadb-git-a515802c5b1bda9444a2d19b5725deeabeb5fb02.tar.gz
Fixed LP bug #806097.
The value of THD::used tables should be re-evaluated after merges of views and derived tables into the main query. Now it's done in the function SELECT_LEX::update_used_tables. The re-evaluation of the 'used_table' bitmaps for the items in HAVING, GROUP BY and ORDER BY clauses has been added as well.
Diffstat (limited to 'mysql-test/t/derived_view.test')
-rw-r--r--mysql-test/t/derived_view.test28
1 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test
index 26f428571ee..d7055f71382 100644
--- a/mysql-test/t/derived_view.test
+++ b/mysql-test/t/derived_view.test
@@ -503,3 +503,31 @@ SELECT * FROM v1 t
DROP VIEW v1;
DROP TABLE t1,t2,t3;
+
+--echo #
+--echo # LP bug #806097: left join over a view + DISTINCT
+--echo #
+
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (252,6), (232,0), (174,232);
+
+CREATE TABLE t2 (a int);
+INSERT INTO t2 VALUES (232), (174);
+
+CREATE TABLE t3 (c int);
+INSERT INTO t3 VALUES (1), (2);
+
+CREATE VIEW v1 AS SELECT t2.a FROM t3,t2;
+
+SELECT v1.a FROM t1 LEFT JOIN v1 ON t1.b = 0;
+
+SELECT DISTINCT t2.a FROM t1 LEFT JOIN (t3,t2) ON t1.b = 0;
+EXPLAIN
+SELECT DISTINCT t2.a FROM t1 LEFT JOIN (t3,t2) ON t1.b = 0;
+
+SELECT DISTINCT v1.a FROM t1 LEFT JOIN v1 ON t1.b = 0;
+EXPLAIN
+SELECT DISTINCT v1.a FROM t1 LEFT JOIN v1 ON t1.b = 0;
+
+DROP VIEW v1;
+DROP TABLE t1,t2,t3;