From 7e6bec87c18c13f2f3d2d1405828236a728316ce Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 18 Jul 2012 15:03:05 +0400 Subject: MDEV-398: Sergv related to spacial queries - index_merge/intersection is unable to work on GIS indexes, because: 1. index scans have no Rowid-Ordered-Retrieval property 2. When one does an index-only read over a GIS index, they do not get the index tuple, because index only contains bounding box of the geometry. This is why key_copy() call crashed. This patch fixes #1, which makes the problem go away. Theoretically, it would be nice to check #2, too, but SE API semantics is not sufficiently precise to do it. --- storage/maria/ha_maria.cc | 22 ++++++++++++++++++++++ storage/maria/ha_maria.h | 7 +------ storage/myisam/ha_myisam.cc | 22 ++++++++++++++++++++++ storage/myisam/ha_myisam.h | 7 +------ 4 files changed, 46 insertions(+), 12 deletions(-) (limited to 'storage') diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 656f6f43f45..a1d7da269a3 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -914,6 +914,28 @@ const char *ha_maria::index_type(uint key_number) } +ulong ha_maria::index_flags(uint inx, uint part, bool all_parts) const +{ + ulong flags; + if (table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) + flags= 0; + else + if ((table_share->key_info[inx].flags & HA_SPATIAL || + table_share->key_info[inx].algorithm == HA_KEY_ALG_RTREE)) + { + /* All GIS scans are non-ROR scans. We also disable IndexConditionPushdown */ + flags= HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | + HA_READ_ORDER | HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR; + } + else + { + flags= HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | + HA_READ_ORDER | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN; + } + return flags; +} + + double ha_maria::scan_time() { if (file->s->data_file_type == BLOCK_RECORD) diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h index 48ee9a99474..e5c5160e169 100644 --- a/storage/maria/ha_maria.h +++ b/storage/maria/ha_maria.h @@ -64,12 +64,7 @@ public: const char **bas_ext() const; ulonglong table_flags() const { return int_table_flags; } - ulong index_flags(uint inx, uint part, bool all_parts) const - { - return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? - 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | - HA_READ_ORDER | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN); - } + ulong index_flags(uint inx, uint part, bool all_parts) const; uint max_supported_keys() const { return MARIA_MAX_KEY; } uint max_supported_key_length() const; diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index a6ece45734a..0e2b7189952 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -691,6 +691,28 @@ err: #endif /* HAVE_REPLICATION */ +ulong ha_myisam::index_flags(uint inx, uint part, bool all_parts) const +{ + ulong flags; + if (table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) + flags= 0; + else + if ((table_share->key_info[inx].flags & HA_SPATIAL || + table_share->key_info[inx].algorithm == HA_KEY_ALG_RTREE)) + { + /* All GIS scans are non-ROR scans. We also disable IndexConditionPushdown */ + flags= HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | + HA_READ_ORDER | HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR; + } + else + { + flags= HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | + HA_READ_ORDER | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN; + } + return flags; +} + + /* Name is here without an extension */ int ha_myisam::open(const char *name, int mode, uint test_if_locked) { diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 4b600fd61c1..10a9a920b94 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -60,12 +60,7 @@ class ha_myisam: public handler int index_end(); int rnd_end(); - ulong index_flags(uint inx, uint part, bool all_parts) const - { - return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? - 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | - HA_READ_ORDER | HA_KEYREAD_ONLY | HA_DO_INDEX_COND_PUSHDOWN); - } + ulong index_flags(uint inx, uint part, bool all_parts) const; uint max_supported_keys() const { return MI_MAX_KEY; } uint max_supported_key_length() const { return HA_MAX_KEY_LENGTH; } uint max_supported_key_part_length() const { return HA_MAX_KEY_LENGTH; } -- cgit v1.2.1