summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/gis-precise.result3
-rw-r--r--mysql-test/t/gis-precise.test2
-rw-r--r--sql/gcalc_tools.cc9
3 files changed, 14 insertions, 0 deletions
diff --git a/mysql-test/r/gis-precise.result b/mysql-test/r/gis-precise.result
index a3928cd0fb0..a370e117fe0 100644
--- a/mysql-test/r/gis-precise.result
+++ b/mysql-test/r/gis-precise.result
@@ -320,3 +320,6 @@ POLYGON((2 0,2 5,3 3,3 2,7 5,2 0))
SELECT AsText(ST_INTERSECTION(LinestringFromText('LINESTRING(1 1, 2 2)'), GeometryFromText('LINESTRING(3 3, 4 4)')));
AsText(ST_INTERSECTION(LinestringFromText('LINESTRING(1 1, 2 2)'), GeometryFromText('LINESTRING(3 3, 4 4)')))
GEOMETRYCOLLECTION()
+SELECT AsText(ST_UNION(GEOMETRYFROMTEXT('POINT(8 1)') ,MULTILINESTRINGFROMTEXT('MULTILINESTRING((3 5, 2 5, 2 4, 3 4, 3 5))')));
+AsText(ST_UNION(GEOMETRYFROMTEXT('POINT(8 1)') ,MULTILINESTRINGFROMTEXT('MULTILINESTRING((3 5, 2 5, 2 4, 3 4, 3 5))')))
+GEOMETRYCOLLECTION(POINT(8 1),LINESTRING(2 4,2 5,3 5,3 4,2 4))
diff --git a/mysql-test/t/gis-precise.test b/mysql-test/t/gis-precise.test
index d2012ee795d..c2d13cfe5cb 100644
--- a/mysql-test/t/gis-precise.test
+++ b/mysql-test/t/gis-precise.test
@@ -204,3 +204,5 @@ SELECT AsText( ST_UNION(
SELECT AsText(ST_INTERSECTION(LinestringFromText('LINESTRING(1 1, 2 2)'), GeometryFromText('LINESTRING(3 3, 4 4)')));
+#bug 839341 100% CPU usage with ST_UNION in maria-5.3-gis
+SELECT AsText(ST_UNION(GEOMETRYFROMTEXT('POINT(8 1)') ,MULTILINESTRINGFROMTEXT('MULTILINESTRING((3 5, 2 5, 2 4, 3 4, 3 5))')));
diff --git a/sql/gcalc_tools.cc b/sql/gcalc_tools.cc
index 0d5c1c52d61..e502d54a160 100644
--- a/sql/gcalc_tools.cc
+++ b/sql/gcalc_tools.cc
@@ -1158,6 +1158,7 @@ int Gcalc_operation_reducer::get_line_result(res_point *cur,
Gcalc_result_receiver *storage)
{
res_point *next;
+ res_point *cur_orig= cur;
int move_upward= 1;
if (cur->glue)
{
@@ -1171,6 +1172,14 @@ int Gcalc_operation_reducer::get_line_result(res_point *cur,
if (!next)
{
next= cur->glue;
+ if (next == cur_orig)
+ {
+ /* It's the line loop */
+ cur= cur_orig;
+ cur->glue->glue= NULL;
+ move_upward= 1;
+ break;
+ }
move_upward^= 1;
}
}