Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1974 05/11/19 00:05:58 evgen@stripped +3 -0
Fix bug#13293 Wrongly used index results in endless loop.
Loose index scan using only second part of multipart index was choosen, which
results in creating wrong keys and endless loop.
get_best_group_min_max() now allows loose index scan for distinct only if all
keyparts of index are used and all fields are covered by index.
mysql-test/r/group_min_max.result
1.18 05/11/18 23:59:13 evgen@stripped +10 -0
Test case for bug#13293 Wrongly used index results in endless loop.
mysql-test/t/group_min_max.test
1.16 05/11/18 23:58:50 evgen@stripped +10 -0
Test case for bug#13293 Wrongly used index results in endless loop.
sql/opt_range.cc
1.197 05/11/18 23:56:24 evgen@stripped +10 -3
Fix bug #13293 Wrongly used index results in endless loop.
get_best_group_min_max() now allows loose index scan for distinct only if all
keyparts of index are used and all fields are covered by index.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /work/13293-bug-5.0-mysql
--- 1.196/sql/opt_range.cc 2005-11-03 17:42:03 +03:00
+++ 1.197/sql/opt_range.cc 2005-11-18 23:56:24 +03:00
@@ -6916,9 +6916,9 @@
SA5. The select list in DISTINCT queries should not contain expressions.
GA1. If Q has a GROUP BY clause, then GA is a prefix of I. That is, if
G_i = A_j => i = j.
- GA2. If Q has a DISTINCT clause, then there is a permutation of SA that
- forms a prefix of I. This permutation is used as the GROUP clause
- when the DISTINCT query is converted to a GROUP query.
+ GA2. If Q has a DISTINCT clause, then there is a permutation of SA.
+ This permutation is used as the GROUP clause when the DISTINCT
+ query is converted to a GROUP query.
GA3. The attributes in GA may participate in arbitrary predicates, divided
into two groups:
- RNG(G_1,...,G_q ; where q <= k) is a range condition over the
@@ -7208,6 +7208,13 @@
cur_used_key_parts.set_bit(key_part_nr);
++cur_group_key_parts;
}
+ /*
+ For loose index scan being applicable for distinct all fields
+ should be covered by index and all parts of index should be used.
+ */
+ if (cur_group_key_parts != join->fields_list.elements ||
+ cur_group_key_parts != cur_index_info->key_parts)
+ goto next_index;
}
else
DBUG_ASSERT(FALSE);
--- 1.17/mysql-test/r/group_min_max.result 2005-09-25 17:43:52 +04:00
+++ 1.18/mysql-test/r/group_min_max.result 2005-11-18 23:59:13 +03:00
@@ -2002,3 +2002,13 @@
1 1
NULL 1
drop table t1;
+create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb;
+insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
+alter table t1 drop primary key, add primary key (f2, f1);
+explain select distinct f1 a, f1 b from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 5 NULL 4 Using index; Using temporary
+explain select distinct f1, f2 from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL PRIMARY 5 NULL 3 Using index for group-by; Using temporary
+drop table t1;
--- 1.15/mysql-test/t/group_min_max.test 2005-09-25 17:43:53 +04:00
+++ 1.16/mysql-test/t/group_min_max.test 2005-11-18 23:58:50 +03:00
@@ -693,3 +693,13 @@
insert into t1 values(1);
select a, count(a) from t1 group by a with rollup;
drop table t1;
+
+#
+# Bug #13293 Wrongly used index results in endless loop.
+#
+create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb;
+insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
+alter table t1 drop primary key, add primary key (f2, f1);
+explain select distinct f1 a, f1 b from t1;
+explain select distinct f1, f2 from t1;
+drop table t1;
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.1974) BUG#13293 | eugene | 18 Nov |