summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorRamil Kalimullin <ramil@mysql.com>2009-10-23 16:26:48 +0500
committerRamil Kalimullin <ramil@mysql.com>2009-10-23 16:26:48 +0500
commitb7ce2a01bc7cdf7984cbd12848f7f61c2f582a89 (patch)
tree619c72abf0ebe7d87fa57fef436aa6cb995425a6 /sql/opt_range.cc
parent17ed6b9abda235daf41eb62512116384c1e06e25 (diff)
downloadmariadb-git-b7ce2a01bc7cdf7984cbd12848f7f61c2f582a89.tar.gz
Fix for bug#48258: Assertion failed when using a spatial index
Problem: involving a spatial index for "non-spatial" queries (that don't containt MBRXXX() functions) may lead to failed assert. Fix: don't use spatial indexes in such cases. mysql-test/r/gis-rtree.result: Fix for bug#48258: Assertion failed when using a spatial index - test result. mysql-test/t/gis-rtree.test: Fix for bug#48258: Assertion failed when using a spatial index - test case. sql/opt_range.cc: Fix for bug#48258: Assertion failed when using a spatial index - allow only spatial functions (MBRXXX) for itMBR keyparts.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 355317fe280..3236ccd2cf4 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -4377,6 +4377,27 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
!(conf_func->compare_collation()->state & MY_CS_BINSORT))
goto end;
+ if (key_part->image_type == Field::itMBR)
+ {
+ switch (type) {
+ case Item_func::SP_EQUALS_FUNC:
+ case Item_func::SP_DISJOINT_FUNC:
+ case Item_func::SP_INTERSECTS_FUNC:
+ case Item_func::SP_TOUCHES_FUNC:
+ case Item_func::SP_CROSSES_FUNC:
+ case Item_func::SP_WITHIN_FUNC:
+ case Item_func::SP_CONTAINS_FUNC:
+ case Item_func::SP_OVERLAPS_FUNC:
+ break;
+ default:
+ /*
+ We cannot involve spatial indexes for queries that
+ don't use MBREQUALS(), MBRDISJOINT(), etc. functions.
+ */
+ goto end;
+ }
+ }
+
optimize_range= field->optimize_range(param->real_keynr[key_part->key],
key_part->part);