Commit 492d53fa authored by unknown's avatar unknown

Fix some ORDER BY ... DESC problems with InnoDB


sql/ha_heap.h:
  Move HA_NOT_READ_PREFIX_LAST to index_flags()
sql/ha_isammrg.h:
  Move HA_NOT_READ_PREFIX_LAST to index_flags()
sql/handler.h:
  Added comment
sql/sql_select.cc:
  Test HA_NOT_READ_PREFIX_LAST from index_flags() instead of table_flags().
  Should fix some ORDER BY ... DESC problems with InnoDB
parent f78951aa
......@@ -41,13 +41,14 @@ class ha_heap: public handler
{
return (HA_READ_RND_SAME | HA_NO_INDEX | HA_KEYPOS_TO_RNDPOS |
HA_NO_BLOBS | HA_NULL_KEY | HA_REC_NOT_IN_SEQ |
HA_NOT_READ_PREFIX_LAST | HA_NO_AUTO_INCREMENT);
HA_NO_AUTO_INCREMENT);
}
ulong index_flags(uint inx) const
{
return ((table->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
(HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER) :
(HA_ONLY_WHOLE_INDEX | HA_WRONG_ASCII_ORDER));
(HA_ONLY_WHOLE_INDEX | HA_WRONG_ASCII_ORDER |
HA_NOT_READ_PREFIX_LAST));
}
uint max_record_length() const { return HA_MAX_REC_LENGTH; }
uint max_keys() const { return MAX_KEY; }
......
......@@ -33,9 +33,9 @@ class ha_isammrg: public handler
const char *table_type() const { return "MRG_ISAM"; }
const char **bas_ext() const;
ulong table_flags() const { return (HA_READ_RND_SAME | HA_KEYPOS_TO_RNDPOS |
HA_NOT_READ_PREFIX_LAST |
HA_REC_NOT_IN_SEQ); }
ulong index_flags(uint idx) const { return 0; }
ulong index_flags(uint idx) const { return HA_NOT_READ_PREFIX_LAST; }
uint max_record_length() const { return HA_MAX_REC_LENGTH; }
uint max_keys() const { return 0; }
uint max_key_parts() const { return 0; }
......
......@@ -81,7 +81,7 @@
#define HA_READ_PREV 4 /* Read prev. record with same key */
#define HA_READ_ORDER 8 /* Read through record-keys in order */
#define HA_ONLY_WHOLE_INDEX 16 /* Can't use part key searches */
#define HA_NOT_READ_PREFIX_LAST 32
#define HA_NOT_READ_PREFIX_LAST 32 /* No support for index_read_last() */
#define HA_KEY_READ_ONLY 64 /* Support HA_EXTRA_KEYREAD */
/*
......
......@@ -5576,7 +5576,7 @@ 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
with key part (A) and then traverse the index backwards.
*/
if (table->file->table_flags() & HA_NOT_READ_PREFIX_LAST)
if (table->file->index_flags(ref_key) & HA_NOT_READ_PREFIX_LAST)
DBUG_RETURN(0); // Use filesort
tab->read_first_record= join_read_last_key;
tab->read_record.read_record= join_read_prev_same;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment