summaryrefslogtreecommitdiff
path: root/mysql-test/t/group_min_max.test
diff options
context:
space:
mode:
authorunknown <timour@mysql.com>2005-08-29 17:13:42 +0300
committerunknown <timour@mysql.com>2005-08-29 17:13:42 +0300
commit64e6d7b193b5e662c25364130ce1ec2eee0f75e3 (patch)
treecbcc6c417c6ece0a54075d1aed693dd3a7f14cee /mysql-test/t/group_min_max.test
parent3a65c1b1dbfe86ff8ade191eaf0a631fe6ddc63a (diff)
downloadmariadb-git-64e6d7b193b5e662c25364130ce1ec2eee0f75e3.tar.gz
Fix for BUG#12672.
mysql-test/r/group_min_max.result: Test for BUG#12672. mysql-test/t/group_min_max.test: Test for BUG#12672. sql/opt_range.cc: Some storage managers like InnoDB always retrieve the value of the primary key (if any) with any other key. For such storage managers the optimizer marks an index as covering if that index and the primary key contain all query fields. This is good for reading data from an index, but not for lookup. The patch detects such cases and tests whether an index is really a covering index by itself, without the primary key. If yes, then that index can be used for the index skip algorithm of the GROUP_MIN_MAX access method.
Diffstat (limited to 'mysql-test/t/group_min_max.test')
-rw-r--r--mysql-test/t/group_min_max.test19
1 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index 6731be615fd..dd5f8b43248 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -651,6 +651,25 @@ select a1 from t1 where a2 = 'b' group by a1;
explain select distinct a1 from t1 where a2 = 'b';
select distinct a1 from t1 where a2 = 'b';
+#
+# Bug #12672: primary key implcitly included in every innodb index
+#
+
+create table bug12672 (
+ pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
+) engine=innodb;
+
+insert into bug12672 (a1, a2, b, c, d, dummy) select * from t1;
+
+create index idx12672_0 on bug12672 (a1);
+create index idx12672_1 on bug12672 (a1,a2,b,c);
+create index idx12672_2 on bug12672 (a1,a2,b);
+analyze table t1;
+
+explain select distinct a1 from bug12672 where pk_col not in (1,2,3,4);
+select distinct a1 from bug12672 where pk_col not in (1,2,3,4);
+
+drop table bug12672;
drop table t1;
drop table t2;