Commit 007d353e authored by monty@mysql.com's avatar monty@mysql.com

Proper fix for bug with BLOB in MIN/MAX

parent 63499f3d
...@@ -182,9 +182,9 @@ int key_cmp(TABLE *table,const byte *key,uint idx,uint key_length) ...@@ -182,9 +182,9 @@ int key_cmp(TABLE *table,const byte *key,uint idx,uint key_length)
} }
if (key_part->key_part_flag & (HA_BLOB_PART | HA_VAR_LENGTH)) if (key_part->key_part_flag & (HA_BLOB_PART | HA_VAR_LENGTH))
{ {
if (key_part->field->key_cmp(key, key_part->length+2)) if (key_part->field->key_cmp(key, key_part->length+ HA_KEY_BLOB_LENGTH))
return 1; return 1;
length=key_part->length+2; length=key_part->length+HA_KEY_BLOB_LENGTH;
} }
else else
{ {
......
...@@ -440,14 +440,16 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond) ...@@ -440,14 +440,16 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond)
left_length < part->store_length || left_length < part->store_length ||
(table->file->index_flags(idx) & HA_WRONG_ASCII_ORDER)) (table->file->index_flags(idx) & HA_WRONG_ASCII_ORDER))
break; break;
uint store_length= part->store_length;
// Save found constant // Save found constant
if (part->null_bit) if (part->null_bit)
{
*key_ptr++= (byte) test(part->field->is_null()); *key_ptr++= (byte) test(part->field->is_null());
part->field->get_key_image((char*) key_ptr, store_length--;
(part->field->type() == FIELD_TYPE_BLOB) ? }
part->length + HA_KEY_BLOB_LENGTH : part->length); part->field->get_key_image((char*) key_ptr, store_length);
key_ptr+=part->store_length - test(part->null_bit); key_ptr+= store_length;
left_length-=part->store_length; left_length-= part->store_length;
} }
if (part == part_end && part->field == field) if (part == part_end && part->field == 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