summaryrefslogtreecommitdiff
path: root/myisammrg
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2006-02-11 21:51:43 +0300
committerunknown <sergefp@mysql.com>2006-02-11 21:51:43 +0300
commit4b0cce48737bf90eb33e389706df824cc00d7e5c (patch)
treed894a207a1c4fad592a93902aac288cb1c465a91 /myisammrg
parent96268d4a9a375fdd6e7effe530f26261bbd01d55 (diff)
downloadmariadb-git-4b0cce48737bf90eb33e389706df824cc00d7e5c.tar.gz
BUG#17314: Can't use index_merge/intersection for MERGE tables
1. Fix index access costs for MERGE tables, set block_size=myisam_block_size/#underlying_tables instead of 0 which it was before. 2. Make index scans on MERGE table to return records in (key_tuple, merge_table_rowid) order, instead of just (key_tuple) order. This makes an index scan on MERGE table to be truly a ROR-scan which is a requirement for index_merge union/intersection. myisammrg/myrg_queue.c: BUG#17314: Make index scans on MERGE table return records ordered by (keytuple, merge_table_rowid). mysql-test/r/index_merge.result: Testcase for BUG#17314 mysql-test/r/merge.result: BUG#17314: update testcase result mysql-test/t/index_merge.test: Testcase for BUG#17314 sql/ha_myisammrg.cc: BUG#17314: For MERGE tables, set handler::block_size to myisam_block_size/#underlying_tables, and not to 0.
Diffstat (limited to 'myisammrg')
-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 */