summaryrefslogtreecommitdiff
path: root/mysql-test/r/group_min_max.result
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2013-07-17 16:42:13 +0300
committerunknown <timour@askmonty.org>2013-07-17 16:42:13 +0300
commit66ec79fc87da6fea5bed2e5a6d9881c306d9e8fa (patch)
tree3e7b3dbda482b383c011b183027d2cd65e686984 /mysql-test/r/group_min_max.result
parenta5b534a08e5c666da6f1e909e24e40f5d6d626c0 (diff)
downloadmariadb-git-66ec79fc87da6fea5bed2e5a6d9881c306d9e8fa.tar.gz
Fix for MDEV-4219 A simple select query returns random data (upstream bug#68473)
In the case of loose scan used as input for order by, end_send() didn't detect correctly that a loose scan was used, and didn't copy the non-aggregated fields from the temp table used for ORDER BY. The fix uses the fact that the quick select used for sorting is attached to JOIN::pre_sort_join_tab instead of JOIN::join_tab.
Diffstat (limited to 'mysql-test/r/group_min_max.result')
-rw-r--r--mysql-test/r/group_min_max.result42
1 files changed, 42 insertions, 0 deletions
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index cc7c9c4d364..229481f5ec8 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -3561,3 +3561,45 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL PRIMARY 5 NULL 9 Using index for group-by (scanning)
drop table t1;
# End of test#50539.
+#
+# MDEV-4219 A simple select query returns random data (upstream bug#68473)
+#
+drop table if exists faulty;
+CREATE TABLE faulty (
+a int(11) unsigned NOT NULL AUTO_INCREMENT,
+b int(11) unsigned NOT NULL,
+c datetime NOT NULL,
+PRIMARY KEY (a),
+UNIQUE KEY b_and_c (b,c)
+);
+INSERT INTO faulty (b, c) VALUES
+(1801, '2013-02-15 09:00:00'),
+(1802, '2013-02-28 09:00:00'),
+(1802, '2013-03-01 09:00:00'),
+(5, '1990-02-15 09:00:00'),
+(5, '2013-02-15 09:00:00'),
+(5, '2009-02-15 17:00:00');
+EXPLAIN
+SELECT DISTINCT b, c FROM faulty WHERE b='1802' ORDER BY c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE faulty range b_and_c b_and_c 12 NULL 2 Using where; Using index for group-by; Using filesort
+SELECT DISTINCT b, c FROM faulty WHERE b='1802' ORDER BY c;
+b c
+1802 2013-02-28 09:00:00
+1802 2013-03-01 09:00:00
+drop table faulty;
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
+INSERT INTO t1 SELECT a + 1, b FROM t1;
+INSERT INTO t1 SELECT a + 2, b FROM t1;
+CREATE INDEX break_it ON t1 (a, b);
+EXPLAIN
+SELECT distinct a, b FROM t1 where a = '3' ORDER BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range break_it break_it 10 NULL 2 Using where; Using index for group-by; Using filesort
+SELECT distinct a, b FROM t1 where a = '3' ORDER BY b;
+a b
+3 1
+3 2
+3 3
+drop table t1;