summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChaithra Gopalareddy <chaithra.gopalareddy@oracle.com>2012-04-18 11:34:36 +0530
committerChaithra Gopalareddy <chaithra.gopalareddy@oracle.com>2012-04-18 11:34:36 +0530
commiteff1ec5fcc21b3767867cf1768a77a0d8abe0a29 (patch)
treed41acd578fe151e096b34602ac3e0a258dc07fc9
parent75ff20a2b4311e9235fba71544c256481fe7f24b (diff)
parent25f82f8a261963f633ccfdabce27dfc1e0309286 (diff)
downloadmariadb-git-eff1ec5fcc21b3767867cf1768a77a0d8abe0a29.tar.gz
Merge from 5.1 to 5.5
mysql-test/r/select.result: Added test result for Bug#12713907 mysql-test/t/select.test: Added test case for Bug#12713907 sql/sql_select.cc: Remove the call to set_keyread as we do it from access functions 'join_read_first' and 'join_read_last'
-rw-r--r--mysql-test/r/select.result27
-rw-r--r--mysql-test/t/select.test32
-rw-r--r--sql/sql_select.cc2
3 files changed, 59 insertions, 2 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 57f650f4c56..a32580a1278 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -4988,3 +4988,30 @@ f1
DROP TABLE t1;
DROP VIEW view_t1;
# End of test BUG#63020
+#
+# Bug#12713907: STRANGE OPTIMIZE & WRONG RESULT UNDER ORDER BY
+# COUNT(*) LIMIT.
+#
+CREATE TABLE t1 (
+id BIGINT(20) ,
+member_id_to INT(11) ,
+r_date DATE ,
+PRIMARY KEY (id,r_date),
+KEY r_date_idx (r_date),
+KEY t1_idx01 (member_id_to)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(107924526,518491,'2011-05-01'),
+(107924527,518491,'2011-05-01'),
+(107924534,518491,'2011-06-21'),
+(107924535,518491,'2011-06-21'),
+(107924542,1601319,'2011-06-21'),
+(107924543,1601319,'2011-06-21'),
+(107924544,1601319,'2011-06-21'),
+(107924545,1601319,'2011-06-21');
+SELECT member_id_to, COUNT(*) FROM t1 WHERE r_date =
+'2011-06-21' GROUP BY member_id_to ORDER BY 2 LIMIT 1;
+member_id_to COUNT(*)
+518491 2
+DROP TABLE t1;
+# End of test BUG#12713907
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index d9e9c27650f..dc63733768e 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -4253,3 +4253,35 @@ DROP VIEW view_t1;
--echo # End of test BUG#63020
+
+--echo #
+--echo # Bug#12713907: STRANGE OPTIMIZE & WRONG RESULT UNDER ORDER BY
+--echo # COUNT(*) LIMIT.
+--echo #
+
+CREATE TABLE t1 (
+id BIGINT(20) ,
+member_id_to INT(11) ,
+r_date DATE ,
+PRIMARY KEY (id,r_date),
+KEY r_date_idx (r_date),
+KEY t1_idx01 (member_id_to)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES
+(107924526,518491,'2011-05-01'),
+(107924527,518491,'2011-05-01'),
+(107924534,518491,'2011-06-21'),
+(107924535,518491,'2011-06-21'),
+(107924542,1601319,'2011-06-21'),
+(107924543,1601319,'2011-06-21'),
+(107924544,1601319,'2011-06-21'),
+(107924545,1601319,'2011-06-21');
+
+SELECT member_id_to, COUNT(*) FROM t1 WHERE r_date =
+ '2011-06-21' GROUP BY member_id_to ORDER BY 2 LIMIT 1;
+
+DROP TABLE t1;
+
+--echo # End of test BUG#12713907
+
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 50ae8916707..423c59d34cc 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -13925,8 +13925,6 @@ check_reverse_order:
join_read_first:join_read_last;
tab->type=JT_NEXT; // Read with index_first(), index_next()
- if (table->covering_keys.is_set(best_key))
- table->set_keyread(TRUE);
table->file->ha_index_or_rnd_end();
if (tab->join->select_options & SELECT_DESCRIBE)
{