diff options
author | timour@mysql.com <> | 2005-01-17 17:19:33 +0200 |
---|---|---|
committer | timour@mysql.com <> | 2005-01-17 17:19:33 +0200 |
commit | bb77b2e55f0f66b6695562aab79657ea950029d3 (patch) | |
tree | 0de8b5fcbd864087ee907f495dc1a6d69a1af34e /sql/sql_select.cc | |
parent | 2933cd3d35e36f8553a69a3cfb908dd46204effa (diff) | |
download | mariadb-git-bb77b2e55f0f66b6695562aab79657ea950029d3.tar.gz |
Fix for BUG#7331 merged manually from 4.1.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0273334eca2..cf02d1c4f6e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10426,13 +10426,22 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, } else { - select->quick->head->file->ha_index_end(); - /* - We have verified above that select->quick is not - index_merge quick select. - */ - select->quick->index= new_ref_key; - select->quick->init(); + /* + The range optimizer constructed QUICK_RANGE for ref_key, and + we want to use instead new_ref_key as the index. We can't + just change the index of the quick select, because this may + result in an incosistent QUICK_SELECT object. Below we + create a new QUICK_SELECT from scratch so that all its + parameres are set correctly by the range optimizer. + */ + key_map new_ref_key_map; + new_ref_key_map.clear_all(); /* Force the creation of quick select */ + new_ref_key_map.set_bit(new_ref_key); /* only for new_ref_key. */ + + if (select->test_quick_select(tab->join->thd, new_ref_key_map, 0, + (tab->join->select_options & OPTION_FOUND_ROWS) ? + HA_POS_ERROR : tab->join->unit->select_limit_cnt) <= 0) + DBUG_RETURN(0); } ref_key= new_ref_key; } |