summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect2.test
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2012-11-04 19:09:46 +0400
committerSergey Petrunya <psergey@askmonty.org>2012-11-04 19:09:46 +0400
commit39e7072d64f5ff36d61bf81970ec398f8d937cfd (patch)
treee7c0ca49db94cb0fbd39198e4dab1fd74b403d79 /mysql-test/t/subselect2.test
parent25b5831a77cd3a8f1b0a1dfdb9ef16d9f33da0b8 (diff)
downloadmariadb-git-39e7072d64f5ff36d61bf81970ec398f8d937cfd.tar.gz
MDEV-536: LP:1050806 - different result for a query using subquery, and
MDEV-567: Wrong result from a query with correlated subquery if ICP is allowed: backport the fix developed for SHOW EXPLAIN: revision-id: psergey@askmonty.org-20120719115219-212cxmm6qvf0wlrb branch nick: 5.5-show-explain-r21 timestamp: Thu 2012-07-19 15:52:19 +0400 BUG#992942 & MDEV-325: Pre-liminary commit for testing and adjust it so that it handles DS-MRR scans correctly.
Diffstat (limited to 'mysql-test/t/subselect2.test')
-rw-r--r--mysql-test/t/subselect2.test96
1 files changed, 95 insertions, 1 deletions
diff --git a/mysql-test/t/subselect2.test b/mysql-test/t/subselect2.test
index 75cf842fbdb..68894ad18cb 100644
--- a/mysql-test/t/subselect2.test
+++ b/mysql-test/t/subselect2.test
@@ -204,6 +204,32 @@ DROP VIEW v1;
DROP TABLE t1,t2,t3;
--echo #
+--echo # MDEV-536: LP:1050806 - different result for a query using subquery
+--echo #
+DROP TABLE IF EXISTS `t1`;
+
+CREATE TABLE `t1` (
+ `node_uid` bigint(20) unsigned DEFAULT NULL,
+ `date` datetime DEFAULT NULL,
+ `mirror_date` datetime DEFAULT NULL,
+ KEY `date` (`date`)
+) ENGINE=MyISAM;
+
+INSERT INTO `t1` VALUES (2085,'2012-01-01 00:00:00','2013-01-01 00:00:00');
+INSERT INTO `t1` VALUES (2084,'2012-02-01 00:00:00','2013-01-01 00:00:00');
+INSERT INTO `t1` VALUES (2088,'2012-03-01 00:00:00','2013-01-01 00:00:00');
+
+SELECT * FROM (
+ SELECT node_uid, date, mirror_date, @result := 0 AS result
+ FROM t1
+ WHERE date < '2012-12-12 12:12:12'
+ AND node_uid in (2085, 2084)
+ ORDER BY mirror_date ASC
+) AS calculated_result;
+
+DROP TABLE t1;
+
+--echo #
--echo # MDEV-567: Wrong result from a query with correlated subquery if ICP is allowed
--echo #
CREATE TABLE t1 (a int, b int, INDEX idx(a));
@@ -220,7 +246,75 @@ SELECT * FROM t3
WHERE t1.a = t2.a AND t2.a BETWEEN 7 AND 9
AND t3.b = t1.b
GROUP BY t1.b);
-DROP TABLE t1, t2, t3;
+
+
+set @tmp_mdev567=@@optimizer_switch;
+set optimizer_switch='mrr=off';
+SELECT * FROM t3
+ WHERE a = (SELECT COUNT(DISTINCT t2.b) FROM t1, t2
+ WHERE t1.a = t2.a AND t2.a BETWEEN 7 AND 9
+ AND t3.b = t1.b
+ GROUP BY t1.b);
+
+DROP TABLE t1,t2,t3;
+set optimizer_switch=@tmp_mdev567;
+
+--echo #
+--echo # MDEV-614, also MDEV-536, also LP:1050806:
+--echo # different result for a query using subquery between 5.5.25 and 5.5.27
+--echo #
+
+CREATE TABLE `t1` (
+ `node_uid` bigint(20) unsigned DEFAULT NULL,
+ `date` datetime DEFAULT NULL,
+ `mirror_date` datetime DEFAULT NULL,
+ KEY `date` (`date`)
+) ENGINE=MyISAM;
+
+INSERT INTO `t1` VALUES (2085,'2012-01-01 00:00:00','2013-01-01 00:00:00');
+INSERT INTO `t1` VALUES (2084,'2012-02-01 00:00:00','2013-01-01 00:00:00');
+INSERT INTO `t1` VALUES (2088,'2012-03-01 00:00:00','2013-01-01 00:00:00');
+
+explain
+SELECT * FROM (
+ SELECT node_uid, date, mirror_date, @result := 0 AS result
+ FROM t1
+ WHERE date < '2012-12-12 12:12:12'
+ AND node_uid in (2085, 2084)
+ ORDER BY mirror_date ASC
+) AS calculated_result;
+
+SELECT * FROM (
+ SELECT node_uid, date, mirror_date, @result := 0 AS result
+ FROM t1
+ WHERE date < '2012-12-12 12:12:12'
+ AND node_uid in (2085, 2084)
+ ORDER BY mirror_date ASC
+) AS calculated_result;
+
+set @tmp_mdev614=@@optimizer_switch;
+set optimizer_switch='mrr=off';
+explain
+SELECT * FROM (
+ SELECT node_uid, date, mirror_date, @result := 0 AS result
+ FROM t1
+ WHERE date < '2012-12-12 12:12:12'
+ AND node_uid in (2085, 2084)
+ ORDER BY mirror_date ASC
+) AS calculated_result;
+
+SELECT * FROM (
+ SELECT node_uid, date, mirror_date, @result := 0 AS result
+ FROM t1
+ WHERE date < '2012-12-12 12:12:12'
+ AND node_uid in (2085, 2084)
+ ORDER BY mirror_date ASC
+) AS calculated_result;
+
+set optimizer_switch=@tmp_mdev614;
+
+DROP TABLE t1;
+
set optimizer_switch=@subselect2_test_tmp;