summaryrefslogtreecommitdiff
path: root/sql/spatial.cc
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2011-09-04 19:11:04 +0500
committerAlexey Botchkov <holyfoot@askmonty.org>2011-09-04 19:11:04 +0500
commiteefff87652cde1cb0c986fd167ed057e87230250 (patch)
tree610484de1f8231ab6291ebb0678a12927c2d424f /sql/spatial.cc
parentc937b7588f007d24c1cf93ee0b2da9e0e244d711 (diff)
downloadmariadb-git-eefff87652cde1cb0c986fd167ed057e87230250.tar.gz
bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis.
We didn't implement an empty geometry. And returning NULL instead of it is not quite correct. So here is the implementation of the empty value as GEOMETRYCOLLECTION(). per-file comments: mysql-test/r/gis-precise.result bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis. test result updated. mysql-test/r/gis.result bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis. test result updated. mysql-test/t/gis-precise.test bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis. test case added. mysql-test/t/gis.test bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis. test case added. sql/field.cc bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis. store GEOMETRYCOLLECTION() properly. sql/gcalc_tools.cc bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis. create the GEOMETRYCOLLECTION() for the empty result. sql/gstream.h bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis. next_symbol() added. sql/spatial.cc bug 801466 ST_INTERSECTION() returns invalid value on empty intersection in maria-5.3-gis. code modified to handle 0 geometries in the GEOMETRYCOLLECTION properly.
Diffstat (limited to 'sql/spatial.cc')
-rw-r--r--sql/spatial.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 67ece027141..67e36ccb12b 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -2075,19 +2075,22 @@ bool Gis_geometry_collection::init_from_wkt(Gis_read_stream *trs, String *wkb)
return 1;
wkb->length(wkb->length()+4); // Reserve space for points
- for (;;)
+ if (trs->next_symbol() != ')')
{
- if (!(g= create_from_wkt(&buffer, trs, wkb)))
- return 1;
-
- if (g->get_class_info()->m_type_id == wkb_geometrycollection)
+ for (;;)
{
- trs->set_error_msg("Unexpected GEOMETRYCOLLECTION");
- return 1;
+ if (!(g= create_from_wkt(&buffer, trs, wkb)))
+ return 1;
+
+ if (g->get_class_info()->m_type_id == wkb_geometrycollection)
+ {
+ trs->set_error_msg("Unexpected GEOMETRYCOLLECTION");
+ return 1;
+ }
+ n_objects++;
+ if (trs->skip_char(',')) // Didn't find ','
+ break;
}
- n_objects++;
- if (trs->skip_char(',')) // Didn't find ','
- break;
}
wkb->write_at_position(no_pos, n_objects);
@@ -2208,10 +2211,9 @@ bool Gis_geometry_collection::get_data_as_wkt(String *txt,
geom->set_data_ptr(data, (uint) (m_data_end - data));
if (geom->as_wkt(txt, &data))
return 1;
- if (txt->append(STRING_WITH_LEN(","), 512))
+ if (n_objects && txt->append(STRING_WITH_LEN(","), 512))
return 1;
}
- txt->length(txt->length() - 1);
*end= data;
return 0;
}