1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-35117 Improve error message on unexpected geometries for st_distance_sphere

When invoking st_distance_sphere with unexpected geometries, the error
message now given is:
  ERROR HY000: Internal error: Point or multipoint geometries expected
This commit fixes a few formatting issues in the affected function.
This commit is contained in:
Dave Gosselin
2024-12-18 12:02:10 -05:00
committed by Daniel Black
parent 3a1f9dfda9
commit fbb6b50499
5 changed files with 28 additions and 16 deletions

View File

@@ -776,7 +776,7 @@ SELECT ST_DISTANCE_SPHERE(1, 1, NULL);
ST_DISTANCE_SPHERE(1, 1, NULL)
NULL
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 0)'), ST_GEOMFROMTEXT('LINESTRING(0 0, 1 1)')) as result;
ERROR HY000: Internal error: st_distance_sphere
ERROR HY000: Calling geometry function st_distance_sphere with unsupported types of arguments.
# Test Points and radius
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 1)')) as result;
result
@@ -788,9 +788,9 @@ SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(
result
0.024682056391766436
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 1)'), 0) as result;
ERROR HY000: Internal error: Radius must be greater than zero.
ERROR HY000: Calling geometry function st_distance_sphere with unsupported types of arguments.
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 1)'), -1) as result;
ERROR HY000: Internal error: Radius must be greater than zero.
ERROR HY000: Calling geometry function st_distance_sphere with unsupported types of arguments.
# Test longitude/lattitude
SELECT TRUNCATE(ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 1)'), ST_GEOMFROMTEXT('POINT(1 2)')), 10) as result;
result
@@ -843,7 +843,7 @@ SELECT TRUNCATE(ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(1 2,1 1 )'), ST_G
result
0.04933028646581131
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(1 2,1 1 )'), ST_GEOMFROMTEXT('MULTIPOINT(8 9,3 4 )'),0) as result;
ERROR HY000: Internal error: Radius must be greater than zero.
ERROR HY000: Calling geometry function st_distance_sphere with unsupported types of arguments.
set @pt1 = ST_GeomFromText('POINT(190 -30)');
set @pt2 = ST_GeomFromText('POINT(-30 50)');
SELECT ST_Distance_Sphere(@pt1, @pt2);