mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
A fix (bug #6142: SELECT DISTINCT on key field crashes server)
This commit is contained in:
parent
c593ab8e6e
commit
5c8a14e9b7
3 changed files with 19 additions and 4 deletions
|
@ -1897,3 +1897,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
drop table t3;
|
drop table t3;
|
||||||
|
create table t1 (
|
||||||
|
a varchar(30), b varchar(30), primary key(a), key(b)
|
||||||
|
) engine=innodb;
|
||||||
|
select distinct a from t1;
|
||||||
|
a
|
||||||
|
drop table t1;
|
||||||
|
|
|
@ -577,3 +577,13 @@ explain select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
drop table t3;
|
drop table t3;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #6142: a problem with the empty innodb table
|
||||||
|
#
|
||||||
|
|
||||||
|
create table t1 (
|
||||||
|
a varchar(30), b varchar(30), primary key(a), key(b)
|
||||||
|
) engine=innodb;
|
||||||
|
select distinct a from t1;
|
||||||
|
drop table t1;
|
||||||
|
|
|
@ -7040,17 +7040,16 @@ get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree,
|
||||||
static inline uint
|
static inline uint
|
||||||
get_field_keypart(KEY *index, Field *field)
|
get_field_keypart(KEY *index, Field *field)
|
||||||
{
|
{
|
||||||
KEY_PART_INFO *part= index->key_part;
|
KEY_PART_INFO *part, *end;
|
||||||
uint key_part_num= 0;
|
uint key_part_num= 0;
|
||||||
|
|
||||||
while (part != part + index->key_parts)
|
for (part= index->key_part, end= part + index->key_parts; part < end; part++)
|
||||||
{
|
{
|
||||||
key_part_num++;
|
key_part_num++;
|
||||||
if (field->eq(part->field))
|
if (field->eq(part->field))
|
||||||
return key_part_num;
|
return key_part_num;
|
||||||
part++;
|
|
||||||
}
|
}
|
||||||
return key_part_num;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue