mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-7528 GIS: Functions return NULL instead of specified -1 for NULL arguments.
The behaviour required by the standard seems too weird to expect.
This commit is contained in:
@ -1111,7 +1111,7 @@ DROP TABLE t0, t1, t2;
|
||||
#
|
||||
SELECT ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)));
|
||||
ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)))
|
||||
NULL
|
||||
-1
|
||||
#
|
||||
# BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN
|
||||
# GEOMETRY FUNCTION ARGUMENTS
|
||||
@ -1810,3 +1810,9 @@ disjoint
|
||||
select ST_Relate(ST_PointFromText('POINT(0 0)'),ST_PointFromText('POINT(0 0)'),'FF*FF****') as disjoint;
|
||||
disjoint
|
||||
0
|
||||
#
|
||||
# MDEV-7528 GIS: Functions return NULL instead of specified -1 for NULL arguments.
|
||||
#
|
||||
select ST_IsRing(NULL);
|
||||
ST_IsRing(NULL)
|
||||
-1
|
||||
|
@ -1511,3 +1511,10 @@ select ST_Relate(ST_PointFromText('POINT(0 0)'),ST_PointFromText('POINT(0 0)'),'
|
||||
select ST_Relate(ST_PointFromText('POINT(0 0)'),ST_PointFromText('POINT(1 1)'),'FF*FF****') as disjoint;
|
||||
select ST_Relate(ST_PointFromText('POINT(0 0)'),ST_PointFromText('POINT(0 0)'),'FF*FF****') as disjoint;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-7528 GIS: Functions return NULL instead of specified -1 for NULL arguments.
|
||||
--echo #
|
||||
|
||||
select ST_IsRing(NULL);
|
||||
|
||||
|
@ -1860,10 +1860,14 @@ longlong Item_func_issimple::val_int()
|
||||
DBUG_ENTER("Item_func_issimple::val_int");
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
|
||||
if ((null_value= (args[0]->null_value ||
|
||||
null_value= 0;
|
||||
if ((args[0]->null_value ||
|
||||
!(g= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
|
||||
g->get_mbr(&mbr, &c_end))))
|
||||
DBUG_RETURN(0);
|
||||
g->get_mbr(&mbr, &c_end)))
|
||||
{
|
||||
/* We got NULL as an argument. Have to return -1 */
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
collector.set_extent(mbr.xmin, mbr.xmax, mbr.ymin, mbr.ymax);
|
||||
|
||||
@ -1924,11 +1928,15 @@ longlong Item_func_isclosed::val_int()
|
||||
Geometry *geom;
|
||||
int isclosed= 0; // In case of error
|
||||
|
||||
null_value= (!swkb ||
|
||||
null_value= 0;
|
||||
if (!swkb ||
|
||||
args[0]->null_value ||
|
||||
!(geom=
|
||||
Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
|
||||
geom->is_closed(&isclosed));
|
||||
!(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
|
||||
geom->is_closed(&isclosed))
|
||||
{
|
||||
/* IsClosed(NULL) should return -1 */
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (longlong) isclosed;
|
||||
}
|
||||
@ -1944,11 +1952,15 @@ longlong Item_func_isring::val_int()
|
||||
Geometry *geom;
|
||||
int isclosed= 0; // In case of error
|
||||
|
||||
null_value= (!swkb ||
|
||||
null_value= 0;
|
||||
if (!swkb ||
|
||||
args[0]->null_value ||
|
||||
!(geom=
|
||||
Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
|
||||
geom->is_closed(&isclosed));
|
||||
!(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
|
||||
geom->is_closed(&isclosed))
|
||||
{
|
||||
/* IsRing(NULL) should return -1 */
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!isclosed)
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user