diff options
author | unknown <serg@serg.mylan> | 2005-03-23 19:31:29 +0100 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2005-03-23 19:31:29 +0100 |
commit | c5b5385c655932c30f9cb87a7b85d826e2dfac4e (patch) | |
tree | 8e51388c971bd5dddda6fc27b2aa65dc24bc57ad /sql/opt_range.cc | |
parent | c9659f0e6ddad0f9d550d5d871f5288f00f000da (diff) | |
download | mariadb-git-c5b5385c655932c30f9cb87a7b85d826e2dfac4e.tar.gz |
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
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 85cd35a5673..44e2f5ee9f2 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3607,10 +3607,10 @@ static SEL_ARG * get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, 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; SEL_ARG *tree; - char *str, *str2; + char *str; DBUG_ENTER("get_mm_leaf"); 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, /* 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 } - /* Get local copy of key */ - 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); + str= (char*) alloc_root(param->mem_root, key_part->store_length+1); if (!str) DBUG_RETURN(0); if (maybe_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); - if (copies == 2) - { - /* - 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))) + if (!(tree=new SEL_ARG(field,str,str))) DBUG_RETURN(0); // out of memory switch (type) { |