summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect.test
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-07-06 23:47:33 +0200
committerSergei Golubchik <serg@mariadb.org>2017-07-06 23:47:33 +0200
commit89dc445a55156881318ca94ce042dbaf98e53e26 (patch)
tree04da8a074a8ceac347cb21e0c6e2ee1d05a990c6 /mysql-test/t/subselect.test
parent4d2131354914f54f85abf0bb8cb4bdd42d817f73 (diff)
parentf305a7ce4bccbd56520d874e1d81a4f29bc17a96 (diff)
downloadmariadb-git-89dc445a55156881318ca94ce042dbaf98e53e26.tar.gz
Merge branch '5.5' into 10.0
Diffstat (limited to 'mysql-test/t/subselect.test')
-rw-r--r--mysql-test/t/subselect.test25
1 files changed, 25 insertions, 0 deletions
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index ab864803864..c9b2d88e9c4 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -6021,3 +6021,28 @@ INSERT INTO t1 VALUES ('foo','bar');
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-10146: Wrong result (or questionable result and behavior)
+--echo # with aggregate function in uncorrelated SELECT subquery
+--echo #
+CREATE TABLE t1 (f1 INT);
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2 (f2 int);
+
+INSERT INTO t2 VALUES (3);
+SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
+
+SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
+
+INSERT INTO t2 VALUES (4);
+
+--error ER_SUBQUERY_NO_1_ROW
+SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
+--error ER_SUBQUERY_NO_1_ROW
+SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
+
+drop view v1;
+drop table t1,t2;