summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/view.result9
-rw-r--r--mysql-test/t/view.test14
2 files changed, 23 insertions, 0 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index c02e4e1f7c8..ab33b54bd2a 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -2553,3 +2553,12 @@ a b
3 3
drop view v2, v1;
drop table t1;
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (2);
+CREATE VIEW v1 AS SELECT SQRT(a) my_sqrt FROM t1;
+SELECT my_sqrt FROM v1 ORDER BY my_sqrt;
+my_sqrt
+1
+1.4142135623731
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index eb7940158ff..3e4797af8ef 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -2404,3 +2404,17 @@ update v2 set b=3 where a=2;
select * from v2;
drop view v2, v1;
drop table t1;
+
+#
+# Bug #18386: select from view over a table with ORDER BY view_col clause
+# given view_col is not an image of any column from the base table
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (2);
+
+CREATE VIEW v1 AS SELECT SQRT(a) my_sqrt FROM t1;
+
+SELECT my_sqrt FROM v1 ORDER BY my_sqrt;
+
+DROP VIEW v1;
+DROP TABLE t1;