summaryrefslogtreecommitdiff
path: root/mysql-test/t/view.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/view.test')
-rw-r--r--mysql-test/t/view.test40
1 files changed, 40 insertions, 0 deletions
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 90a3c6a1e2d..1b229298896 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3163,4 +3163,44 @@ drop view view_24532_a;
drop view view_24532_b;
drop table table_24532;
+#
+# Bug#26560: view using subquery with a reference to an outer alias
+#
+
+CREATE TABLE t1 (
+ lid int NOT NULL PRIMARY KEY,
+ name char(10) NOT NULL
+);
+INSERT INTO t1 (lid, name) VALUES
+ (1, 'YES'), (2, 'NO');
+
+CREATE TABLE t2 (
+ id int NOT NULL PRIMARY KEY,
+ gid int NOT NULL,
+ lid int NOT NULL,
+ dt date
+);
+INSERT INTO t2 (id, gid, lid, dt) VALUES
+ (1, 1, 1, '2007-01-01'),(2, 1, 2, '2007-01-02'),
+ (3, 2, 2, '2007-02-01'),(4, 2, 1, '2007-02-02');
+
+SELECT DISTINCT t2.gid AS lgid,
+ (SELECT t1.name FROM t1, t2
+ WHERE t1.lid = t2.lid AND t2.gid = lgid
+ ORDER BY t2.dt DESC LIMIT 1
+ ) as clid
+ FROM t2;
+
+CREATE VIEW v1 AS
+SELECT DISTINCT t2.gid AS lgid,
+ (SELECT t1.name FROM t1, t2
+ WHERE t1.lid = t2.lid AND t2.gid = lgid
+ ORDER BY t2.dt DESC LIMIT 1
+ ) as clid
+ FROM t2;
+SELECT * FROM v1;
+
+DROP VIEW v1;
+DROP table t1,t2;
+
--echo End of 5.0 tests.