mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01: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:
parent
a226f12675
commit
4d3b00c14d
5 changed files with 28 additions and 16 deletions
|
@ -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);
|
||||
|
|
|
@ -422,7 +422,7 @@ SELECT ST_DISTANCE_SPHERE(1, 1, 3);
|
|||
# Return NULL if radius is NULL
|
||||
SELECT ST_DISTANCE_SPHERE(1, 1, NULL);
|
||||
# Wrong geometry
|
||||
--error ER_INTERNAL_ERROR
|
||||
--error ER_GIS_UNSUPPORTED_ARGUMENT
|
||||
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(1 0)'), ST_GEOMFROMTEXT('LINESTRING(0 0, 1 1)')) as result;
|
||||
|
||||
--echo # Test Points and radius
|
||||
|
@ -430,9 +430,9 @@ SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(
|
|||
# make bb x86 happy
|
||||
SELECT TRUNCATE(ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(-1 -1)'), ST_GEOMFROMTEXT('POINT(-2 -2)')), 10) as result;
|
||||
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 1)'), 1) as result;
|
||||
--error ER_INTERNAL_ERROR
|
||||
--error ER_GIS_UNSUPPORTED_ARGUMENT
|
||||
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 1)'), 0) as result;
|
||||
--error ER_INTERNAL_ERROR
|
||||
--error ER_GIS_UNSUPPORTED_ARGUMENT
|
||||
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('POINT(0 0)'), ST_GEOMFROMTEXT('POINT(1 1)'), -1) as result;
|
||||
--echo # Test longitude/lattitude
|
||||
# make bb x86 happy
|
||||
|
@ -456,7 +456,7 @@ SELECT TRUNCATE(ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(1 2,1 1 )'), ST_G
|
|||
SELECT TRUNCATE(ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(1 2,1 1 )'), ST_GEOMFROMTEXT('MULTIPOINT(8 9,3 4 )')), 10) as result;
|
||||
# make bb x86 happy
|
||||
SELECT TRUNCATE(ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(1 2,1 1 )'), ST_GEOMFROMTEXT('MULTIPOINT(8 9,3 4 )'),1), 17) as result;
|
||||
--error ER_INTERNAL_ERROR
|
||||
--error ER_GIS_UNSUPPORTED_ARGUMENT
|
||||
SELECT ST_DISTANCE_SPHERE(ST_GEOMFROMTEXT('MULTIPOINT(1 2,1 1 )'), ST_GEOMFROMTEXT('MULTIPOINT(8 9,3 4 )'),0) as result;
|
||||
|
||||
# Longitude out of range [-180,180]
|
||||
|
|
|
@ -5474,4 +5474,9 @@ INSERT INTO t VALUES (1,POINT(0,0)),(2,POINT(0,0));
|
|||
SELECT NTH_VALUE(a,b) OVER () FROM t;
|
||||
ERROR HY000: Illegal parameter data types point and bigint for operation '-'
|
||||
DROP TABLE t;
|
||||
#
|
||||
# MDEV-35117 Error message "ERROR 1815 (HY000): Internal error: st_distance_sphere' could be improved
|
||||
#
|
||||
SELECT ST_DISTANCE_SPHERE(st_geomfromtext('linestring( 2 2, 2 8) '), ST_GeomFromText('POINT(18.413076 43.856258)')) ;
|
||||
ERROR HY000: Calling geometry function st_distance_sphere with unsupported types of arguments.
|
||||
# End of 10.5 tests
|
||||
|
|
|
@ -3482,4 +3482,10 @@ INSERT INTO t VALUES (1,POINT(0,0)),(2,POINT(0,0));
|
|||
SELECT NTH_VALUE(a,b) OVER () FROM t;
|
||||
DROP TABLE t;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-35117 Error message "ERROR 1815 (HY000): Internal error: st_distance_sphere' could be improved
|
||||
--echo #
|
||||
--error ER_GIS_UNSUPPORTED_ARGUMENT
|
||||
SELECT ST_DISTANCE_SPHERE(st_geomfromtext('linestring( 2 2, 2 8) '), ST_GeomFromText('POINT(18.413076 43.856258)')) ;
|
||||
|
||||
--echo # End of 10.5 tests
|
||||
|
|
|
@ -2526,7 +2526,7 @@ double Item_func_sphere_distance::val_real()
|
|||
String *arg2= args[1]->val_str(&bak2);
|
||||
double distance= 0.0;
|
||||
double sphere_radius= 6370986.0; // Default radius equals Earth radius
|
||||
|
||||
|
||||
null_value= (args[0]->null_value || args[1]->null_value);
|
||||
if (null_value)
|
||||
{
|
||||
|
@ -2544,7 +2544,7 @@ double Item_func_sphere_distance::val_real()
|
|||
}
|
||||
if (sphere_radius <= 0)
|
||||
{
|
||||
my_error(ER_INTERNAL_ERROR, MYF(0), "Radius must be greater than zero.");
|
||||
my_error(ER_GIS_UNSUPPORTED_ARGUMENT, MYF(0), func_name());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -2556,26 +2556,27 @@ double Item_func_sphere_distance::val_real()
|
|||
my_error(ER_GIS_INVALID_DATA, MYF(0), "ST_Distance_Sphere");
|
||||
goto handle_errors;
|
||||
}
|
||||
// Method allowed for points and multipoints
|
||||
// Method allowed for points and multipoints
|
||||
if (!(g1->get_class_info()->m_type_id == Geometry::wkb_point ||
|
||||
g1->get_class_info()->m_type_id == Geometry::wkb_multipoint) ||
|
||||
!(g2->get_class_info()->m_type_id == Geometry::wkb_point ||
|
||||
g2->get_class_info()->m_type_id == Geometry::wkb_multipoint))
|
||||
{
|
||||
// Generate error message in case different geometry is used?
|
||||
my_error(ER_INTERNAL_ERROR, MYF(0), func_name());
|
||||
// Generate error message in case of unexpected geometry.
|
||||
my_error(ER_GIS_UNSUPPORTED_ARGUMENT, MYF(0), func_name());
|
||||
return 0;
|
||||
}
|
||||
distance= spherical_distance_points(g1, g2, sphere_radius);
|
||||
if (distance < 0)
|
||||
{
|
||||
my_error(ER_INTERNAL_ERROR, MYF(0), "Returned distance cannot be negative.");
|
||||
my_error(ER_INTERNAL_ERROR, MYF(0),
|
||||
"Returned distance cannot be negative.");
|
||||
return 1;
|
||||
}
|
||||
return distance;
|
||||
|
||||
handle_errors:
|
||||
return 0;
|
||||
handle_errors:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue