Commit cfb7d5d7 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-7516 Assertion `!cur_p->event' failed in Gcalc_scan_iterator::arrange_event(int, int).

    When the distance in ST_BUFFER is too far negative the coordinates can run out of the operational
    area. We should just return an empty geometry in this case.
parent 552f1b35
...@@ -1607,4 +1607,7 @@ create table t1 (pt point); ...@@ -1607,4 +1607,7 @@ create table t1 (pt point);
insert into t1 values(Geomfromtext('POLYGON((1 1, 2 2, 2 1, 1 1))')); insert into t1 values(Geomfromtext('POLYGON((1 1, 2 2, 2 1, 1 1))'));
ERROR 22007: Incorrect POINT value: 'POLYGON' for column 'pt' at row 1 ERROR 22007: Incorrect POINT value: 'POLYGON' for column 'pt' at row 1
drop table t1; drop table t1;
SELECT st_astext(ST_Buffer(ST_PolygonFromText('POLYGON((3 5, 2 4, 2 5, 3 5))'), -100));
st_astext(ST_Buffer(ST_PolygonFromText('POLYGON((3 5, 2 4, 2 5, 3 5))'), -100))
GEOMETRYCOLLECTION EMPTY
End of 5.5 tests End of 5.5 tests
...@@ -1465,4 +1465,9 @@ create table t1 (pt point); ...@@ -1465,4 +1465,9 @@ create table t1 (pt point);
insert into t1 values(Geomfromtext('POLYGON((1 1, 2 2, 2 1, 1 1))')); insert into t1 values(Geomfromtext('POLYGON((1 1, 2 2, 2 1, 1 1))'));
drop table t1; drop table t1;
#
# MDEV-7516 Assertion `!cur_p->event' failed in Gcalc_scan_iterator::arrange_event(int, int)
#
SELECT st_astext(ST_Buffer(ST_PolygonFromText('POLYGON((3 5, 2 4, 2 5, 3 5))'), -100));
--echo End of 5.5 tests --echo End of 5.5 tests
...@@ -1286,6 +1286,13 @@ String *Item_func_buffer::val_str(String *str_value) ...@@ -1286,6 +1286,13 @@ String *Item_func_buffer::val_str(String *str_value)
if (dist > 0.0) if (dist > 0.0)
mbr.buffer(dist); mbr.buffer(dist);
else
{
/* This happens when dist is too far negative. */
if (mbr.xmax + dist < mbr.xmin || mbr.ymax + dist < mbr.ymin)
goto return_empty_result;
}
collector.set_extent(mbr.xmin, mbr.xmax, mbr.ymin, mbr.ymax); collector.set_extent(mbr.xmin, mbr.xmax, mbr.ymin, mbr.ymax);
/* /*
If the distance given is 0, the Buffer function is in fact NOOP, If the distance given is 0, the Buffer function is in fact NOOP,
...@@ -1313,6 +1320,7 @@ String *Item_func_buffer::val_str(String *str_value) ...@@ -1313,6 +1320,7 @@ String *Item_func_buffer::val_str(String *str_value)
goto mem_error; goto mem_error;
return_empty_result:
str_value->set_charset(&my_charset_bin); str_value->set_charset(&my_charset_bin);
if (str_value->reserve(SRID_SIZE, 512)) if (str_value->reserve(SRID_SIZE, 512))
goto mem_error; goto mem_error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment