[MDEV-12078] Using spatial index changes type from point to geometry Created: 2017-02-16  Updated: 2021-01-16  Resolved: 2017-03-14

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Data types
Affects Version/s: 10.2.3, 10.2.4
Fix Version/s: 10.2.5

Type: Bug Priority: Critical
Reporter: Adam Wallner Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: None
Environment:

Tested On Mac OS X compiled from git 10.2 branch, And tested on Alpine Linux Docker container compiled from 10.2.3 release source.


Issue Links:
Relates
relates to MDEV-8986 wrong geometry type Closed
relates to MDEV-12608 Backport MDEV-12078 to 10.0/10.1 Closed
Sprint: 10.2.5-1

 Description   

If we use a geospatial function e.g. ST_Intersects on a field which has spatial index the original POINT type will automatically be changed to GEOMETRY. This could cause problems in applications where this field is expected to be POINT.

We can reproduce the bug with the following script:

DROP TABLE IF EXISTS test;
 
CREATE TABLE test (
  coordinate point NOT NULL,
  SPATIAL KEY coordinate (coordinate)
) ENGINE=Aria DEFAULT CHARSET=ascii PAGE_CHECKSUM=1;
 
SHOW COLUMNS FROM test;
 
INSERT INTO test (coordinate) VALUES(ST_PointFromText("POINT(0 0)"));
INSERT INTO test (coordinate) VALUES(ST_PointFromText("POINT(10 0)"));
INSERT INTO test (coordinate) VALUES(ST_PointFromText("POINT(10 10)"));
INSERT INTO test (coordinate) VALUES(ST_PointFromText("POINT(0 10)"));
INSERT INTO test (coordinate) VALUES(ST_PointFromText("POINT(5 5)"));
 
SELECT * FROM test WHERE ST_Intersects(ST_LineFromText("LINESTRING(0 0, 10 0, 10 10, 0 10)"), coordinate);
 
SHOW COLUMNS FROM test;
 
DROP TABLE test;



 Comments   
Comment by Alexey Botchkov [ 2017-03-14 ]

http://lists.askmonty.org/pipermail/commits/2017-March/010857.html

Generated at Thu Feb 08 07:54:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.