Commit 1241d867 authored by igor@rurik.mysql.com's avatar igor@rurik.mysql.com

Merge rurik.mysql.com:/home/igor/mysql-4.1-opt

into  rurik.mysql.com:/home/igor/mysql-5.0-opt
parents 9b7ecb55 5cdd1eb6
...@@ -845,6 +845,19 @@ EXPLAIN SELECT MAX(b) FROM t1; ...@@ -845,6 +845,19 @@ EXPLAIN SELECT MAX(b) FROM t1;
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 2 1 SIMPLE t1 ALL NULL NULL NULL NULL 2
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (id int , b varchar(512), INDEX(b(250))) COLLATE latin1_bin;
Warnings:
Warning 1246 Converting column 'b' from CHAR to TEXT
INSERT INTO t1 VALUES
(1,CONCAT(REPEAT('_', 250), "qq")), (1,CONCAT(REPEAT('_', 250), "zz")),
(1,CONCAT(REPEAT('_', 250), "aa")), (1,CONCAT(REPEAT('_', 250), "ff"));
SELECT MAX(b) FROM t1;
MAX(b)
__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________zz
EXPLAIN SELECT MAX(b) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
DROP TABLE t1;
create table t2 (ff double); create table t2 (ff double);
insert into t2 values (2.2); insert into t2 values (2.2);
select cast(sum(distinct ff) as decimal(5,2)) from t2; select cast(sum(distinct ff) as decimal(5,2)) from t2;
......
...@@ -558,6 +558,15 @@ SELECT MAX(b) FROM t1; ...@@ -558,6 +558,15 @@ SELECT MAX(b) FROM t1;
EXPLAIN SELECT MAX(b) FROM t1; EXPLAIN SELECT MAX(b) FROM t1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (id int , b varchar(512), INDEX(b(250))) COLLATE latin1_bin;
INSERT INTO t1 VALUES
(1,CONCAT(REPEAT('_', 250), "qq")), (1,CONCAT(REPEAT('_', 250), "zz")),
(1,CONCAT(REPEAT('_', 250), "aa")), (1,CONCAT(REPEAT('_', 250), "ff"));
SELECT MAX(b) FROM t1;
EXPLAIN SELECT MAX(b) FROM t1;
DROP TABLE t1;
# End of 4.1 tests # End of 4.1 tests
# #
......
...@@ -710,8 +710,10 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, ...@@ -710,8 +710,10 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
if (!(table->file->index_flags(idx, jdx, 0) & HA_READ_ORDER)) if (!(table->file->index_flags(idx, jdx, 0) & HA_READ_ORDER))
return 0; return 0;
/* Check whether the index component is partial */ /* Check whether the index component is partial */
if (part->length < table->field[part->fieldnr-1]->pack_length()) Field *part_field= table->field[part->fieldnr-1];
if ((part_field->flags & BLOB_FLAG) ||
part->length < part_field->key_length())
break; break;
if (field->eq(part->field)) if (field->eq(part->field))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment