mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fix for bug#5782: Don't choose the plan that accesses table with index_prev if the handler doesn't support it (see also ChangeSet@1.2039)
This commit is contained in:
@@ -6923,7 +6923,10 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
|
|||||||
reverse=flag; // Remember if reverse
|
reverse=flag; // Remember if reverse
|
||||||
key_part++;
|
key_part++;
|
||||||
}
|
}
|
||||||
*used_key_parts= (uint) (key_part - table->key_info[idx].key_part);
|
uint tmp= (uint) (key_part - table->key_info[idx].key_part);
|
||||||
|
if (reverse == -1 && !(table->file->index_flags(idx,tmp-1, 1) & HA_READ_PREV))
|
||||||
|
DBUG_RETURN(0);
|
||||||
|
*used_key_parts= tmp;
|
||||||
DBUG_RETURN(reverse);
|
DBUG_RETURN(reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7120,10 +7123,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
|||||||
*/
|
*/
|
||||||
if (!select->quick->reverse_sorted())
|
if (!select->quick->reverse_sorted())
|
||||||
{
|
{
|
||||||
// here used_key_parts >0
|
|
||||||
if (!(table->file->index_flags(ref_key,used_key_parts-1, 1)
|
|
||||||
& HA_READ_PREV))
|
|
||||||
DBUG_RETURN(0); // Use filesort
|
|
||||||
// ORDER BY range_key DESC
|
// ORDER BY range_key DESC
|
||||||
QUICK_SELECT_DESC *tmp=new QUICK_SELECT_DESC(select->quick,
|
QUICK_SELECT_DESC *tmp=new QUICK_SELECT_DESC(select->quick,
|
||||||
used_key_parts);
|
used_key_parts);
|
||||||
@@ -7144,9 +7143,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
|||||||
Use a traversal function that starts by reading the last row
|
Use a traversal function that starts by reading the last row
|
||||||
with key part (A) and then traverse the index backwards.
|
with key part (A) and then traverse the index backwards.
|
||||||
*/
|
*/
|
||||||
if (!(table->file->index_flags(ref_key,used_key_parts-1, 1)
|
|
||||||
& HA_READ_PREV))
|
|
||||||
DBUG_RETURN(0); // Use filesort
|
|
||||||
tab->read_first_record= join_read_last_key;
|
tab->read_first_record= join_read_last_key;
|
||||||
tab->read_record.read_record= join_read_prev_same;
|
tab->read_record.read_record= join_read_prev_same;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
@@ -7188,13 +7184,11 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
|||||||
|
|
||||||
for (nr=0; nr < table->keys ; nr++)
|
for (nr=0; nr < table->keys ; nr++)
|
||||||
{
|
{
|
||||||
uint used_key_parts;
|
uint not_used;
|
||||||
if (keys.is_set(nr))
|
if (keys.is_set(nr))
|
||||||
{
|
{
|
||||||
int flag;
|
int flag;
|
||||||
if ((flag=test_if_order_by_key(order, table, nr, &used_key_parts)) > 0 ||
|
if (flag=test_if_order_by_key(order, table, nr, ¬_used))
|
||||||
((flag < 0) && (table->file->index_flags(nr,used_key_parts-1, 1)
|
|
||||||
& HA_READ_PREV)))
|
|
||||||
{
|
{
|
||||||
if (!no_changes)
|
if (!no_changes)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user