summaryrefslogtreecommitdiff
path: root/myisammrg/myrg_queue.c
diff options
context:
space:
mode:
Diffstat (limited to 'myisammrg/myrg_queue.c')
-rw-r--r--myisammrg/myrg_queue.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/myisammrg/myrg_queue.c b/myisammrg/myrg_queue.c
index 7172b9f0e2a..2e600a526c0 100644
--- a/myisammrg/myrg_queue.c
+++ b/myisammrg/myrg_queue.c
@@ -18,12 +18,26 @@
static int queue_key_cmp(void *keyseg, byte *a, byte *b)
{
- MI_INFO *aa=((MYRG_TABLE *)a)->table;
- MI_INFO *bb=((MYRG_TABLE *)b)->table;
+ MYRG_TABLE *ma= (MYRG_TABLE *)a;
+ MYRG_TABLE *mb= (MYRG_TABLE *)b;
+ MI_INFO *aa= ma->table;
+ MI_INFO *bb= mb->table;
uint not_used[2];
int ret= ha_key_cmp((HA_KEYSEG *)keyseg, aa->lastkey, bb->lastkey,
USE_WHOLE_KEY, SEARCH_FIND, not_used);
- return ret < 0 ? -1 : ret > 0 ? 1 : 0;
+ if (ret < 0)
+ return -1;
+ if (ret > 0)
+ return 1;
+
+ /*
+ If index tuples have the same values, let the record with least rowid
+ value be "smaller", so index scans return records ordered by (keytuple,
+ rowid). This is used by index_merge access method, grep for ROR in
+ sql/opt_range.cc for details.
+ */
+ return (ma->file_offset < mb->file_offset)? -1 : (ma->file_offset >
+ mb->file_offset) ? 1 : 0;
} /* queue_key_cmp */