diff options
author | unknown <cmiller@zippy.(none)> | 2006-07-05 16:16:09 -0400 |
---|---|---|
committer | unknown <cmiller@zippy.(none)> | 2006-07-05 16:16:09 -0400 |
commit | 30de4903ae2b9cd03bd5f853715e7fc7b648c2c7 (patch) | |
tree | a0c67909c6e1a1b67caf4558144a68911d8dfb15 /sql/opt_sum.cc | |
parent | f92fd7c98adad9542e7d8d29ee24db504980541f (diff) | |
parent | 2ef57b836248f945657c7bd0fe02fa7fe3660b54 (diff) | |
download | mariadb-git-30de4903ae2b9cd03bd5f853715e7fc7b648c2c7.tar.gz |
Merge zippy.(none):/home/cmiller/work/mysql/merge/mysql-5.1
into zippy.(none):/home/cmiller/work/mysql/merge/mysql-5.1-new-maint
BUILD/compile-dist:
Auto merged
BitKeeper/deleted/.del-partition_innodb.result:
Auto merged
BitKeeper/deleted/.del-partition_innodb.test:
Auto merged
client/mysqltest.c:
Auto merged
mysql-test/r/create.result:
Auto merged
mysql-test/r/create_not_windows.result:
Auto merged
mysql-test/r/func_group.result:
Auto merged
mysql-test/r/innodb_mysql.result:
Auto merged
mysql-test/r/partition.result:
Auto merged
mysql-test/r/sp.result:
Auto merged
mysql-test/t/innodb_mysql.test:
Auto merged
mysql-test/t/partition.test:
Auto merged
mysql-test/t/ps_1general.test:
Auto merged
mysql-test/t/sp.test:
Auto merged
mysql-test/t/wait_timeout.test:
Auto merged
mysys/my_lib.c:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/unireg.cc:
Auto merged
mysql-test/extra/rpl_tests/rpl_log.test:
manuakl merge
mysql-test/lib/mtr_process.pl:
manuakl merge
mysql-test/mysql-test-run.pl:
manuakl merge
mysql-test/r/type_newdecimal.result:
manuakl merge
mysql-test/t/create.test:
manuakl merge
mysql-test/t/func_group.test:
manuakl merge
mysql-test/t/type_newdecimal.test:
manuakl merge
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r-- | sql/opt_sum.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index ce3f5c5f108..93ec48d69f2 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -651,7 +651,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, } else { - store_val_in_field(part->field, args[between && max_fl ? 2 : 1]); + store_val_in_field(part->field, args[between && max_fl ? 2 : 1], + CHECK_FIELD_IGNORE); if (part->null_bit) *key_ptr++= (byte) test(part->field->is_null()); part->field->get_key_image((char*) key_ptr, part->length, Field::itRAW); @@ -706,6 +707,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, field BETWEEN const1 AND const2 3. all references to the columns from the same table as column field occur only in conjucts mentioned above. + 4. each of k first components the index is not partial, i.e. is not + defined on a fixed length proper prefix of the field. If such an index exists the function through the ref parameter returns the key value to find max/min for the field using the index, @@ -715,8 +718,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, of the whole search key) NOTE - This function may set table->key_read to 1, which must be reset after - index is used! (This can only happen when function returns 1) + This function may set table->key_read to 1, which must be reset after + index is used! (This can only happen when function returns 1) RETURN 0 Index can not be used to optimize MIN(field)/MAX(field) @@ -741,6 +744,12 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, { KEY_PART_INFO *part,*part_end; key_part_map key_part_to_use= 0; + /* + Perform a check if index is not disabled by ALTER TABLE + or IGNORE INDEX. + */ + if (!table->keys_in_use_for_query.is_set(idx)) + continue; uint jdx= 0; *prefix_len= 0; for (part= keyinfo->key_part, part_end= part+keyinfo->key_parts ; @@ -750,6 +759,12 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, if (!(table->file->index_flags(idx, jdx, 0) & HA_READ_ORDER)) return 0; + /* Check whether the index component is partial */ + Field *part_field= table->field[part->fieldnr-1]; + if ((part_field->flags & BLOB_FLAG) || + part->length < part_field->key_length()) + break; + if (field->eq(part->field)) { ref->key= idx; |