From e0d8e8fd09f46b9ccda0b39e5483bca4d3d672de Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Feb 2007 15:22:10 -0800 Subject: Fix bug #24035. This performance degradation for UPDATEs could be observed in the update statements for which the search key cannot be converted to any valid value of the type of the search column, like for a the condition int_fld=99999999999999999999999999, though it can be guaranteed here that there is no row with such a key value. mysql-test/r/update.result: Added a test case for bug #24035. mysql-test/t/update.test: Added a test case for bug #24035. sql/opt_range.cc: Fix bug #24035. This performance degradation for could be observed in the update statements for which the search key cannot be converted to any valid value of the type of the search column, like for a the condition int_fld=99999999999999999999999999, though it can be guaranteed here that there is no row with such a key value. Now the function get_mm_leaf creates trees of the type SEL_ARG::IMPOSSIBLE for such conditions that tells the range scan not to perform any search at all. --- sql/opt_range.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sql/opt_range.cc') diff --git a/sql/opt_range.cc b/sql/opt_range.cc index f0af4b7db2a..744d222b833 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -4296,7 +4296,22 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, err= value->save_in_field_no_warnings(field, 1); if (err > 0 && field->cmp_type() != value->result_type()) { - tree= 0; + if ((type == Item_func::EQ_FUNC || type == Item_func::EQUAL_FUNC) && + value->result_type() == item_cmp_type(field->result_type(), + value->result_type())) + + { + tree= new (alloc) SEL_ARG(field, 0, 0); + tree->type= SEL_ARG::IMPOSSIBLE; + } + else + { + /* + TODO: We should return trees of the type SEL_ARG::IMPOSSIBLE + for the cases like int_field > 999999999999999999999999 as well. + */ + tree= 0; + } goto end; } if (err < 0) -- cgit v1.2.1 From 3e4f834dfbe4b7be9a53f8207bab7b9e59496ba1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Feb 2007 23:55:56 -0800 Subject: Fixed bug #26159. A wrong order of statements in QUICK_GROUP_MIN_MAX_SELECT::reset caused a crash when a query with DISTINCT was executed by a loose scan for an InnoDB table that had been emptied. mysql-test/r/innodb_mysql.result: Added a test case for bug #26159. mysql-test/t/innodb_mysql.test: Added a test case for bug #26159. sql/opt_range.cc: Fixed bug #26159. A wrong order of statements in QUICK_GROUP_MIN_MAX_SELECT::reset caused a crash when a query with DISTINCT was executed by a loose scan for an InnoDB table that had been emptied. For an empty table quick_prefix_select->reset() was not called at all and thus some important initialization steps were missing. --- sql/opt_range.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sql/opt_range.cc') diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 744d222b833..32cf6860d5c 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8765,14 +8765,13 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void) DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::reset"); file->extra(HA_EXTRA_KEYREAD); /* We need only the key attributes */ - result= file->ha_index_init(index); - result= file->index_last(record); - if (result == HA_ERR_END_OF_FILE) - DBUG_RETURN(0); - if (result) + if ((result= file->ha_index_init(index))) DBUG_RETURN(result); if (quick_prefix_select && quick_prefix_select->reset()) DBUG_RETURN(1); + result= file->index_last(record); + if (result == HA_ERR_END_OF_FILE) + DBUG_RETURN(0); /* Save the prefix of the last group. */ key_copy(last_prefix, record, index_info, group_prefix_len); -- cgit v1.2.1 From 7ca34a798fd31b01d50c17adacc869e1e54e97b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Feb 2007 19:28:49 +0400 Subject: valgrind error fix --- sql/opt_range.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'sql/opt_range.cc') diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 32cf6860d5c..4838e690dd7 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8820,7 +8820,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next() #else int result; #endif - int is_last_prefix; + int is_last_prefix= 0; DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::get_next"); @@ -8835,13 +8835,18 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next() Check if this is the last group prefix. Notice that at this point this->record contains the current prefix in record format. */ - is_last_prefix= key_cmp(index_info->key_part, last_prefix, - group_prefix_len); - DBUG_ASSERT(is_last_prefix <= 0); - if (result == HA_ERR_KEY_NOT_FOUND) - continue; - else if (result) + if (!result) + { + is_last_prefix= key_cmp(index_info->key_part, last_prefix, + group_prefix_len); + DBUG_ASSERT(is_last_prefix <= 0); + } + else + { + if (result == HA_ERR_KEY_NOT_FOUND) + continue; break; + } if (have_min) { -- cgit v1.2.1