Commit 08b86663 authored by serg@serg.mylan's avatar serg@serg.mylan

removed unnecessary (and incorrect) space trimming/padding in generating ranges

(where e.g. col='aaa  ' was converted to col>='aaa' AND col<='aaa       ')
it was incorrect because ucs2 space is not ' ' (0x20)
it was unnecessary because storage engine pads values with spaces for comparison anyway
parent 9a0dd5c7
...@@ -3607,10 +3607,10 @@ static SEL_ARG * ...@@ -3607,10 +3607,10 @@ static SEL_ARG *
get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
Item_func::Functype type,Item *value) Item_func::Functype type,Item *value)
{ {
uint maybe_null=(uint) field->real_maybe_null(), copies; uint maybe_null=(uint) field->real_maybe_null();
bool optimize_range; bool optimize_range;
SEL_ARG *tree; SEL_ARG *tree;
char *str, *str2; char *str;
DBUG_ENTER("get_mm_leaf"); DBUG_ENTER("get_mm_leaf");
if (!value) // IS NULL or IS NOT NULL if (!value) // IS NULL or IS NOT NULL
...@@ -3745,39 +3745,13 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, ...@@ -3745,39 +3745,13 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
/* This happens when we try to insert a NULL field in a not null column */ /* This happens when we try to insert a NULL field in a not null column */
DBUG_RETURN(&null_element); // cmp with NULL is never TRUE DBUG_RETURN(&null_element); // cmp with NULL is never TRUE
} }
/* Get local copy of key */ str= (char*) alloc_root(param->mem_root, key_part->store_length+1);
copies= 1;
if (field->key_type() == HA_KEYTYPE_VARTEXT1 ||
field->key_type() == HA_KEYTYPE_VARTEXT2)
copies= 2;
str= str2= (char*) alloc_root(param->mem_root,
(key_part->store_length)*copies+1);
if (!str) if (!str)
DBUG_RETURN(0); DBUG_RETURN(0);
if (maybe_null) if (maybe_null)
*str= (char) field->is_real_null(); // Set to 1 if null *str= (char) field->is_real_null(); // Set to 1 if null
field->get_key_image(str+maybe_null, key_part->length, key_part->image_type); field->get_key_image(str+maybe_null, key_part->length, key_part->image_type);
if (copies == 2) if (!(tree=new SEL_ARG(field,str,str)))
{
/*
The key is stored as 2 byte length + key
key doesn't match end space. In other words, a key 'X ' should match
all rows between 'X' and 'X ...'
*/
uint length= uint2korr(str+maybe_null);
str2= str+ key_part->store_length;
/* remove end space */
while (length > 0 && str[length+HA_KEY_BLOB_LENGTH+maybe_null-1] == ' ')
length--;
int2store(str+maybe_null, length);
/* Create key that is space filled */
memcpy(str2, str, length + HA_KEY_BLOB_LENGTH + maybe_null);
my_fill_8bit(field->charset(),
str2+ length+ HA_KEY_BLOB_LENGTH +maybe_null,
key_part->length-length, ' ');
int2store(str2+maybe_null, key_part->length);
}
if (!(tree=new SEL_ARG(field,str,str2)))
DBUG_RETURN(0); // out of memory DBUG_RETURN(0); // out of memory
switch (type) { switch (type) {
......
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