From c2959178ca9c3eacbd59d854899ecdcdb7ff72de Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Thu, 21 Apr 2005 01:55:33 +0400 Subject: [PATCH] Fix for BUG#10037 * Add 0.01 to cost of 'range'+'using index' scan to avoid optimizer choice races with 'index' scan. --- mysql-test/r/range.result | 4 ++-- sql/opt_range.cc | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 256c4ee6431..fea5754d704 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -256,12 +256,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); explain select * from t1, t2 where (t1.key1 table->file->ref_length) + 1); read_time=((double) (records+keys_per_block-1)/ (double) keys_per_block); - return read_time; + /* Add 0.01 to avoid cost races between 'range' and 'index' */ + return read_time + 0.01; } @@ -7912,6 +7913,8 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void) 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) DBUG_RETURN(result); if (quick_prefix_select && quick_prefix_select->reset())