Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.6.14
-
None
Description
For GIS/Geometry types, constructor functions are provided. For example, for the LINESTRING data type, the LineString() constructor function can be used to construct a LINESTRING value. Currently, when MariaDB Server tries to cast or convert a value from one geometry type to another (either implicitly or explicitly), different rules appear to be used.
I only tested this on 10.6, but I assume this issue is present on all versions.
Steps to reproduce
Create some objects:
CREATE DATABASE db1; |
|
USE db1; |
|
CREATE TABLE linestring_example ( |
g LINESTRING
|
);
|
Try out some different operations:
-- 1.) explicitly call constructor function
|
INSERT INTO linestring_example VALUES (LineString(Point(1,1))); |
-- 2.) implicit conversion from POINT to LINESTRING
|
INSERT INTO linestring_example VALUES (Point(1,1)); |
-- 3.) explicit cast from POINT to LINESTRING
|
INSERT INTO linestring_example VALUES (CAST(Point(1,1) AS LINESTRING)); |
-- 4.) explicit conversion from POINT to LINESTRING
|
INSERT INTO linestring_example VALUES (CONVERT(Point(1,1), LINESTRING)); |
Actual results
The only statement that works is the one that explicitly calls the constructor function:
MariaDB [db1]> -- 1.) explicitly call constructor function
|
MariaDB [db1]> INSERT INTO linestring_example VALUES (LineString(Point(1,1)));
|
Query OK, 1 row affected (0.009 sec)
|
|
MariaDB [db1]> -- 2.) implicit conversion from POINT to LINESTRING
|
MariaDB [db1]> INSERT INTO linestring_example VALUES (Point(1,1));
|
ERROR 1366 (22007): Incorrect LINESTRING value: 'POINT(1 1)' for column `db1`.`linestring_example`.`g` at row 1
|
MariaDB [db1]> -- 3.) explicit cast from POINT to LINESTRING
|
MariaDB [db1]> INSERT INTO linestring_example VALUES (CAST(Point(1,1) AS LINESTRING));
|
ERROR 4162 (HY000): Operator does not exists: 'CAST(expr AS linestring)'
|
MariaDB [db1]> -- 4.) explicit conversion from POINT to LINESTRING
|
MariaDB [db1]> INSERT INTO linestring_example VALUES (CONVERT(Point(1,1), LINESTRING));
|
ERROR 4162 (HY000): Operator does not exists: 'CAST(expr AS linestring)'
|
Expected results
Should all of these cases use similar conversion rules?