summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 4b535769d6c..01b836fddf7 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2760,9 +2760,16 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
{
Field *field= *field_ptr;
uint16 store_length;
+ uint16 max_key_part_length= (uint16) table->file->max_key_part_length();
key_part->key= keys;
key_part->part= 0;
- key_part->length= (uint16) field->key_length();
+ if (field->flags & BLOB_FLAG)
+ key_part->length= max_key_part_length;
+ else
+ {
+ key_part->length= (uint16) field->key_length();
+ set_if_smaller(key_part->length, max_key_part_length);
+ }
store_length= key_part->length;
if (field->real_maybe_null())
store_length+= HA_KEY_NULL_LENGTH;
@@ -3108,6 +3115,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
}
free_alloc:
+ thd->no_errors= 0;
thd->mem_root= param.old_root;
free_root(&alloc, MYF(0));