Commit cdb905ea authored by unknown's avatar unknown
Browse files

Fixed wrong key length when using MIN() optimization (non fatal, but caused...

Fixed wrong key length when using MIN() optimization (non fatal, but caused InnoDB to write warnings to the log file)
This fixed bug #11039: InnoDB: Warning: using a partial-field key prefix in search


mysql-test/r/innodb.result:
  Added extra test for bug #11039: InnoDB: Warning: using a partial-field key prefix in search
mysql-test/t/innodb.test:
  Added extra test for bug #11039: InnoDB: Warning: using a partial-field key prefix in search
sql/opt_sum.cc:
  Fixed wrong key length when using MIN() optimization
parent 4eb26350
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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;
+10 −0
Original line number Diff line number Diff line
@@ -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;
+2 −1
Original line number Diff line number Diff line
@@ -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
          }