summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSinisa@sinisa.nasamreza.org <>2004-03-26 17:01:55 +0200
committerSinisa@sinisa.nasamreza.org <>2004-03-26 17:01:55 +0200
commite2b48a2232d1b7b1da6bc1be5aa58058fb9e47d0 (patch)
tree41634d91bd72010922b7ab01ad4265c46c248f91 /sql
parent9ed179ee8ea1504b710fb34f1f5f75e4db63ebbd (diff)
parent09d26f0ff650cdf656aab66aba0695f6b776fedc (diff)
downloadmariadb-git-e2b48a2232d1b7b1da6bc1be5aa58058fb9e47d0.tar.gz
Merge sinisa@bk-internal.mysql.com:/home/bk/mysql-4.0
into sinisa.nasamreza.org:/mnt/work/mysql-4.0
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 87812414881..057f0bd9483 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6021,7 +6021,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
/* check if we can use a key to resolve the group */
/* Tables using JT_NEXT are handled here */
uint nr;
- key_map keys=usable_keys;
+ key_map keys_to_use=~0,keys=usable_keys;
/*
If not used with LIMIT, only use keys if the whole query can be
@@ -6029,7 +6029,17 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
retrieving all rows through an index.
*/
if (select_limit >= table->file->records)
- keys&= (table->used_keys | table->file->keys_to_use_for_scanning());
+ keys_to_use= (table->used_keys |table->file->keys_to_use_for_scanning());
+
+ /*
+ We are adding here also the index speified in FORCE INDEX clause,
+ if any.
+ This is to allow users to use index in ORDER BY.
+ */
+
+ if (table->force_index)
+ keys_to_use|= table->keys_in_use_for_query;
+ keys&= keys_to_use;
for (nr=0; keys ; keys>>=1, nr++)
{