summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect_sj_mat.test
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2015-06-25 23:26:29 +0300
committerMonty <monty@mariadb.org>2015-06-25 23:26:29 +0300
commit8c815751c92313dfa45ef0398b609c9988a0a451 (patch)
tree8818073046a1bbe69eb6156c682a1c592bfac6b0 /mysql-test/t/subselect_sj_mat.test
parent2e941fe9fce7f1667993916ff3f238a283286d3f (diff)
downloadmariadb-git-8c815751c92313dfa45ef0398b609c9988a0a451.tar.gz
Problem was that for cases like:
SELECT ... WHERE XX IN (SELECT YY) this was transformed to something like: SELECT ... WHERE IF_EXISTS(SELECT ... HAVING XX=YY) The bug was that for normal execution XX was fixed in the original outer SELECT context while in PS it was fixed in the sub query context and this confused the optimizer. Fixed by ensuring that XX is always fixed in the outer context.
Diffstat (limited to 'mysql-test/t/subselect_sj_mat.test')
-rw-r--r--mysql-test/t/subselect_sj_mat.test21
1 files changed, 20 insertions, 1 deletions
diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test
index 912e9d5befd..63c72f20e21 100644
--- a/mysql-test/t/subselect_sj_mat.test
+++ b/mysql-test/t/subselect_sj_mat.test
@@ -1841,5 +1841,24 @@ drop database mysqltest2;
drop database mysqltest3;
drop database mysqltest4;
---echo # End of 5.5 tests
+--echo #
+--echo # MDEV-7810 Wrong result on execution of a query as a PS
+--echo # (both 1st and further executions)
+
+CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (0),(8);
+
+SELECT DISTINCT t9.* FROM t1 AS t9, t1 AS t2;
+SELECT MIN(t3.a) FROM ( t1 AS t3 INNER JOIN t1 AS t4 ON (t3.a = t4.a));
+SELECT a FROM ( SELECT DISTINCT t9.* FROM t1 AS t9, t1 AS t2 ) AS sq
+WHERE a IN ( SELECT MIN(t3.a) FROM ( t1 AS t3 INNER JOIN t1 AS t4 ON (t3.a = t4.a) ) );
+PREPARE stmt FROM "
+SELECT a FROM ( SELECT DISTINCT t9.* FROM t1 AS t9, t1 AS t2 ) AS sq
+WHERE a IN ( SELECT MIN(t3.a) FROM ( t1 AS t3 INNER JOIN t1 AS t4 ON (t3.a = t4.a) ) )
+";
+execute stmt;
+execute stmt;
+drop table t1;
+
+--echo # End of 5.5 tests