summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 1112e073cb1..5d912b441df 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7188,11 +7188,13 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
for (nr=0; nr < table->keys ; nr++)
{
- uint not_used;
+ uint used_key_parts;
if (keys.is_set(nr))
{
int flag;
- if ((flag=test_if_order_by_key(order, table, nr, &not_used)))
+ if ((flag=test_if_order_by_key(order, table, nr, &used_key_parts)) > 0 ||
+ ((flag < 0) && (table->file->index_flags(nr,used_key_parts-1, 1)
+ & HA_READ_PREV)))
{
if (!no_changes)
{