diff options
author | unknown <igor@rurik.mysql.com> | 2006-06-02 17:06:10 -0700 |
---|---|---|
committer | unknown <igor@rurik.mysql.com> | 2006-06-02 17:06:10 -0700 |
commit | 5fd2a3503203ac8263861f25fa80ac5f538b908d (patch) | |
tree | 15bc7fdfa17f8a8f8f09eda2d7b1452ec5985783 /sql | |
parent | cbbd0fdb2c14984e8abf5f9dc8ee8280eda367a9 (diff) | |
parent | ccad0572f5c7a20d909785732995984de9d76552 (diff) | |
download | mariadb-git-5fd2a3503203ac8263861f25fa80ac5f538b908d.tar.gz |
Merge rurik.mysql.com:/home/igor/mysql-4.1-opt
into rurik.mysql.com:/home/igor/mysql-5.0-opt
sql/opt_sum.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_select.h:
Auto merged
mysql-test/r/func_group.result:
SCCS merged
mysql-test/t/func_group.test:
SCCS merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/opt_sum.cc | 17 | ||||
-rw-r--r-- | sql/sql_select.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.h | 2 |
3 files changed, 18 insertions, 7 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 373753a7b80..4a7ec0c5928 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -569,6 +569,10 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, break; // Found a part od the key for the field } +#if 0 + if (part->length != (((Item_field*) args[0])->field)->field_length) + return 0; +#endif bool is_field_part= part == field_part; if (!(is_field_part || eq_type)) return 0; @@ -608,7 +612,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); @@ -663,6 +668,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, @@ -672,8 +679,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) @@ -707,6 +714,10 @@ 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 */ + if (part->length < table->field[part->fieldnr-1]->pack_length()) + break; + if (field->eq(part->field)) { ref->key= idx; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 505beedac3e..96b196e34b0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4788,7 +4788,7 @@ get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables, */ bool -store_val_in_field(Field *field,Item *item) +store_val_in_field(Field *field, Item *item, enum_check_fields check_flag) { bool error; THD *thd= field->table->in_use; @@ -4799,7 +4799,7 @@ store_val_in_field(Field *field,Item *item) with select_insert, which make count_cuted_fields= 1 */ enum_check_fields old_count_cuted_fields= thd->count_cuted_fields; - thd->count_cuted_fields= CHECK_FIELD_WARN; + thd->count_cuted_fields= check_flag; error= item->save_in_field(field, 1); thd->count_cuted_fields= old_count_cuted_fields; return error || cuted_fields != thd->cuted_fields; @@ -10928,7 +10928,7 @@ static bool test_if_ref(Item_field *left_item,Item *right_item) field->real_type() != MYSQL_TYPE_VARCHAR && (field->type() != FIELD_TYPE_FLOAT || field->decimals() == 0)) { - return !store_val_in_field(field,right_item); + return !store_val_in_field(field, right_item, CHECK_FIELD_WARN); } } } diff --git a/sql/sql_select.h b/sql/sql_select.h index 01ed8048e4a..d5a1bf82bc8 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -404,7 +404,7 @@ extern const char *join_type_str[]; void TEST_join(JOIN *join); /* Extern functions in sql_select.cc */ -bool store_val_in_field(Field *field,Item *val); +bool store_val_in_field(Field *field, Item *val, enum_check_fields check_flag); TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ORDER *group, bool distinct, bool save_sum_fields, ulonglong select_options, ha_rows rows_limit, |