diff options
author | Georgi Kodinov <joro@sun.com> | 2009-08-27 10:46:35 +0300 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2009-08-27 10:46:35 +0300 |
commit | f10e85f5f29e3f2ddb4654c675c0987f73c135cd (patch) | |
tree | 3559f1d2d0a73c315b2a01931f00882883392385 /sql/opt_range.cc | |
parent | 6c2b32515e1856b65feedec2ebe47843f416b2ad (diff) | |
parent | 7492d622e44d7d3fd424bd24fd53131fe06d1c22 (diff) | |
download | mariadb-git-f10e85f5f29e3f2ddb4654c675c0987f73c135cd.tar.gz |
merged 5.0-bugteam -> 5.1-bugteam
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 47067c03a85..2239aafbeec 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2243,7 +2243,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, KEY *key_info; PARAM param; - if (check_stack_overrun(thd, 2*STACK_MIN_SIZE, buff)) + if (check_stack_overrun(thd, 2*STACK_MIN_SIZE + sizeof(PARAM), buff)) DBUG_RETURN(0); // Fatal error flag is set /* set up parameter that is passed to all functions */ @@ -9795,11 +9795,22 @@ get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree, return FALSE; uint field_length= cur_part->store_length; - if ((cur_range->maybe_null && - cur_range->min_value[0] && cur_range->max_value[0]) || - !memcmp(cur_range->min_value, cur_range->max_value, field_length)) - { - /* cur_range specifies 'IS NULL' or an equality condition. */ + if (cur_range->maybe_null && + cur_range->min_value[0] && cur_range->max_value[0]) + { + /* + cur_range specifies 'IS NULL'. In this case the argument points + to a "null value" (is_null_string) that may not always be long + enough for a direct memcpy to a field. + */ + DBUG_ASSERT (field_length > 0); + *key_ptr= 1; + bzero(key_ptr+1,field_length-1); + key_ptr+= field_length; + *key_infix_len+= field_length; + } + else if (memcmp(cur_range->min_value, cur_range->max_value, field_length) == 0) + { /* cur_range specifies an equality condition. */ memcpy(key_ptr, cur_range->min_value, field_length); key_ptr+= field_length; *key_infix_len+= field_length; |