Commit c2ee0218 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-4521 MBRContains, MBRWithin no longer work with geometries of different type.

        get_mm_leaf function can store all sorts of spatial features in
        one type of field it receives from an Item_field.
        So we just allow that by setting the type of this field to GEOMETRY.

per-file comments:
  mysql-test/r/gis-rtree.result
        result updated
  mysql-test/t/gis-rtree.test
        test case added.
  sql/opt_range.cc
        set geom_type=GEOMETRY if we got Field_geom.
parent d0265a63
......@@ -1576,3 +1576,23 @@ a ASTEXT(b)
0 POINT(1 1)
DROP TABLE t1;
End of 5.1 tests
CREATE TABLE t1 (
l LINESTRING NOT NULL,
SPATIAL KEY(l)
) ENGINE = myisam;
INSERT INTO t1 VALUES(GeomFromText('LINESTRING(0 0, 1 1)'));
INSERT INTO t1 VALUES(GeomFromText('LINESTRING(1 1, 2 2)'));
INSERT INTO t1 VALUES(GeomFromText('LINESTRING(2 2, 3 3)'));
SELECT COUNT(*) FROM t1 IGNORE INDEX(l) WHERE MBRContains(l, GEOMFROMTEXT('POINT(0 0)'));
COUNT(*)
1
SELECT COUNT(*) FROM t1 IGNORE INDEX(l) WHERE MBRWithin(GEOMFROMTEXT('POINT(0 0)'), l);
COUNT(*)
1
SELECT COUNT(*) FROM t1 FORCE INDEX(l) WHERE MBRContains(l, GEOMFROMTEXT('POINT(0 0)'));
COUNT(*)
1
SELECT COUNT(*) FROM t1 FORCE INDEX(l) WHERE MBRWithin(GEOMFROMTEXT('POINT(0 0)'), l);
COUNT(*)
1
DROP TABLE t1;
......@@ -956,3 +956,23 @@ SELECT a, ASTEXT(b) FROM t1;
DROP TABLE t1;
--echo End of 5.1 tests
#
# MDEV-4521 MBRContains, MBRWithin no longer work with geometries of different type.
#
CREATE TABLE t1 (
l LINESTRING NOT NULL,
SPATIAL KEY(l)
) ENGINE = myisam;
INSERT INTO t1 VALUES(GeomFromText('LINESTRING(0 0, 1 1)'));
INSERT INTO t1 VALUES(GeomFromText('LINESTRING(1 1, 2 2)'));
INSERT INTO t1 VALUES(GeomFromText('LINESTRING(2 2, 3 3)'));
SELECT COUNT(*) FROM t1 IGNORE INDEX(l) WHERE MBRContains(l, GEOMFROMTEXT('POINT(0 0)'));
SELECT COUNT(*) FROM t1 IGNORE INDEX(l) WHERE MBRWithin(GEOMFROMTEXT('POINT(0 0)'), l);
SELECT COUNT(*) FROM t1 FORCE INDEX(l) WHERE MBRContains(l, GEOMFROMTEXT('POINT(0 0)'));
SELECT COUNT(*) FROM t1 FORCE INDEX(l) WHERE MBRWithin(GEOMFROMTEXT('POINT(0 0)'), l);
DROP TABLE t1;
......@@ -7294,6 +7294,14 @@ static SEL_TREE *get_full_func_mm_tree(RANGE_OPT_PARAM *param,
param->current_table);
DBUG_ENTER("get_full_func_mm_tree");
#ifdef HAVE_SPATIAL
if (field_item->field->type() == MYSQL_TYPE_GEOMETRY)
{
/* We have to be able to store all sorts of spatial features here */
((Field_geom*) field_item->field)->geom_type= Field::GEOM_GEOMETRY;
}
#endif /*HAVE_SPATIAL*/
for (uint i= 0; i < cond_func->arg_count; i++)
{
Item *arg= cond_func->arguments()[i]->real_item();
......
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