summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2015-06-23 11:57:05 +0500
committerAlexey Botchkov <holyfoot@askmonty.org>2015-06-23 11:57:05 +0500
commitd3b7eb7b99ef7dae79c20b5beb63acdfdf6d8046 (patch)
treefa8fa9330a7cf5f0a96c90f1f87eb1c46dc8e570 /sql
parent3e4126e9d6b21d2f330a365b0847999346485863 (diff)
downloadmariadb-git-d3b7eb7b99ef7dae79c20b5beb63acdfdf6d8046.tar.gz
MDEV-7528 GIS: Functions return NULL instead of specified -1 for NULL arguments.
The behaviour required by the standard seems too weird to expect.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_geofunc.cc40
1 files changed, 26 insertions, 14 deletions
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 42e7029363c..c4c01667d1b 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -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 ||
- !(g= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
- g->get_mbr(&mbr, &c_end))))
- DBUG_RETURN(0);
+ null_value= 0;
+ if ((args[0]->null_value ||
+ !(g= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
+ 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 ||
- args[0]->null_value ||
- !(geom=
- Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
- geom->is_closed(&isclosed));
+ null_value= 0;
+ if (!swkb ||
+ args[0]->null_value ||
+ !(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 ||
- args[0]->null_value ||
- !(geom=
- Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
- geom->is_closed(&isclosed));
+ null_value= 0;
+ if (!swkb ||
+ args[0]->null_value ||
+ !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
+ geom->is_closed(&isclosed))
+ {
+ /* IsRing(NULL) should return -1 */
+ return -1;
+ }
if (!isclosed)
return 0;