Fixed wrong key length when using MIN() optimization (non fatal, but caused InnoDB to write warnings to the log file)

This fixed bug : InnoDB: Warning: using a partial-field key prefix in search


mysql-test/r/innodb.result:
  Added extra test for bug : InnoDB: Warning: using a partial-field key prefix in search
mysql-test/t/innodb.test:
  Added extra test for bug : InnoDB: Warning: using a partial-field key prefix in search
sql/opt_sum.cc:
  Fixed wrong key length when using MIN() optimization
This commit is contained in:
unknown 2005-06-06 14:03:33 +03:00
parent 4eb26350cb
commit cdb905ead5
3 changed files with 21 additions and 1 deletions

View file

@ -2401,3 +2401,12 @@ CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
ERROR HY000: The used table type doesn't support FULLTEXT indexes
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

@ -1319,3 +1319,13 @@ CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB;
--error 1214;
SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE);
DROP TABLE t1;
#
# BUG#11039 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;

View file

@ -677,7 +677,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
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|= NEAR_MIN; // > NULL
}