1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Fix bug #13218: InnoDB: using a partial-field key prefix in search

This is backport from 5.0 of fix for bug #11039


mysql-test/t/innodb.test:
  Backport from 5.0 of test case for bug#11039
mysql-test/r/innodb.result:
  Backport from 5.0 of test case for bug#11039
sql/opt_sum.cc:
  Fix bug #13218:  backport from 5.0 of bug #11039 fix
This commit is contained in:
unknown
2005-09-19 04:39:49 +04:00
parent 4014d76cd1
commit 5bc4501259
3 changed files with 20 additions and 1 deletions

View File

@ -1685,3 +1685,12 @@ explain select * from t1 order by a,b,c,d;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
drop table t1; drop table t1;
create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
insert into t1 values ('8', '6'), ('4', '7');
select min(a) from t1;
min(a)
4
select min(b) from t1 where a='8';
min(b)
6
drop table t1;

View File

@ -1230,4 +1230,13 @@ select * from t1 order by a,b,c,d;
explain select * from t1 order by a,b,c,d; explain select * from t1 order by a,b,c,d;
drop table t1; drop table t1;
#
# BUG#11039,#13218 Wrong key length in min()
#
create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
insert into t1 values ('8', '6'), ('4', '7');
select min(a) from t1;
select min(b) from t1 where a='8';
drop table t1;
# End of 4.1 tests # End of 4.1 tests

View File

@ -661,7 +661,8 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
If key_part2 may be NULL, then we want to find the first row If key_part2 may be NULL, then we want to find the first row
that is not null that is not null
*/ */
ref->key_buff[ref->key_length++]= 1; ref->key_buff[ref->key_length]= 1;
ref->key_length+= part->store_length;
*range_fl&= ~NO_MIN_RANGE; *range_fl&= ~NO_MIN_RANGE;
*range_fl|= NEAR_MIN; // > NULL *range_fl|= NEAR_MIN; // > NULL
} }