Commit 2b89b0a2 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-4310 geometry function equals hangs forever.

        The Geometry::get_mbr() function can return an error on
        a bad data. We have to check for that and act respectively.
parent 4d49175f
...@@ -406,20 +406,20 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second ...@@ -406,20 +406,20 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second
first second w c o e d t i r first second w c o e d t i r
120 120 1 1 0 1 0 1 1 0 120 120 1 1 0 1 0 1 1 0
120 121 0 0 1 0 0 0 1 0 120 121 0 0 1 0 0 0 1 0
120 122 0 1 NULL 0 NULL 0 NULL 0 120 122 NULL NULL NULL NULL NULL NULL NULL NULL
120 123 0 1 NULL 0 NULL 0 NULL 0 120 123 NULL NULL NULL NULL NULL NULL NULL NULL
121 120 0 0 1 0 0 0 1 0 121 120 0 0 1 0 0 0 1 0
121 121 1 1 0 1 0 1 1 0 121 121 1 1 0 1 0 1 1 0
121 122 0 1 NULL 0 NULL 0 NULL 0 121 122 NULL NULL NULL NULL NULL NULL NULL NULL
121 123 0 1 NULL 0 NULL 0 NULL 0 121 123 NULL NULL NULL NULL NULL NULL NULL NULL
122 120 1 0 NULL 0 NULL 0 NULL 0 122 120 NULL NULL NULL NULL NULL NULL NULL NULL
122 121 1 0 NULL 0 NULL 0 NULL 0 122 121 NULL NULL NULL NULL NULL NULL NULL NULL
122 122 1 1 NULL 1 NULL 0 NULL 0 122 122 NULL NULL NULL NULL NULL NULL NULL NULL
122 123 1 1 NULL 1 NULL 0 NULL 0 122 123 NULL NULL NULL NULL NULL NULL NULL NULL
123 120 1 0 NULL 0 NULL 0 NULL 0 123 120 NULL NULL NULL NULL NULL NULL NULL NULL
123 121 1 0 NULL 0 NULL 0 NULL 0 123 121 NULL NULL NULL NULL NULL NULL NULL NULL
123 122 1 1 NULL 1 NULL 0 NULL 0 123 122 NULL NULL NULL NULL NULL NULL NULL NULL
123 123 1 1 NULL 1 NULL 0 NULL 0 123 123 NULL NULL NULL NULL NULL NULL NULL NULL
explain extended SELECT g1.fid as first, g2.fid as second, explain extended SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o, Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t, Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
...@@ -1473,6 +1473,7 @@ WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1; ...@@ -1473,6 +1473,7 @@ WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
count(*) count(*)
1 1
DROP DATABASE gis_ogs; DROP DATABASE gis_ogs;
USE test;
# #
# BUG #1043845 st_distance() results are incorrect depending on variable order # BUG #1043845 st_distance() results are incorrect depending on variable order
# #
...@@ -1496,3 +1497,19 @@ geomfromtext('LINESTRING(-95.9673005697771 36.13509598461, ...@@ -1496,3 +1497,19 @@ geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
-95.9673057475387 36.1344478941074, -95.9673057475387 36.1344478941074,
-95.9673063519371 36. -95.9673063519371 36.
0.008148695928138 0.008148695928138
#
# MDEV-4310 geometry function equals hangs forever.
#
create table t1(a geometry not null)engine=myisam;
insert into t1 values(geomfromtext("POINT(0 0)"));
insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
select equals(`a`,convert(`a` using utf8)) from `t1`;
equals(`a`,convert(`a` using utf8))
1
NULL
NULL
Warnings:
Warning 1300 Invalid utf8 character string: 'E043'
Warning 1300 Invalid utf8 character string: 'E043'
drop table t1;
...@@ -1355,6 +1355,7 @@ WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1; ...@@ -1355,6 +1355,7 @@ WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
#WHERE lakes.name = 'Blue Lake'; #WHERE lakes.name = 'Blue Lake';
DROP DATABASE gis_ogs; DROP DATABASE gis_ogs;
USE test;
--echo # --echo #
--echo # BUG #1043845 st_distance() results are incorrect depending on variable order --echo # BUG #1043845 st_distance() results are incorrect depending on variable order
...@@ -1371,3 +1372,12 @@ select st_distance(geomfromtext('point(-95.96269500000000000000 36.1418183333333 ...@@ -1371,3 +1372,12 @@ select st_distance(geomfromtext('point(-95.96269500000000000000 36.1418183333333
-95.9673063519371 36.134484524621, -95.9673063519371 36.134484524621,
-95.9673049102515 36.1343976584193) ')) ; -95.9673049102515 36.1343976584193) ')) ;
--echo #
--echo # MDEV-4310 geometry function equals hangs forever.
--echo #
create table t1(a geometry not null)engine=myisam;
insert into t1 values(geomfromtext("POINT(0 0)"));
insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
insert into t1 values(geomfromtext("POINT(0 9.2233720368548e18)"));
select equals(`a`,convert(`a` using utf8)) from `t1`;
drop table t1;
...@@ -685,12 +685,11 @@ longlong Item_func_spatial_rel::val_int() ...@@ -685,12 +685,11 @@ longlong Item_func_spatial_rel::val_int()
if ((null_value= if ((null_value=
(args[0]->null_value || args[1]->null_value || (args[0]->null_value || args[1]->null_value ||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) || !(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length()))))) !(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
g1->get_mbr(&mbr1, &c_end) ||
g2->get_mbr(&mbr2, &c_end))))
goto exit; goto exit;
g1->get_mbr(&mbr1, &c_end);
g2->get_mbr(&mbr2, &c_end);
umbr= mbr1; umbr= mbr1;
umbr.add_mbr(&mbr2); umbr.add_mbr(&mbr2);
collector.set_extent(umbr.xmin, umbr.xmax, umbr.ymin, umbr.ymax); collector.set_extent(umbr.xmin, umbr.xmax, umbr.ymin, umbr.ymax);
...@@ -824,14 +823,14 @@ String *Item_func_spatial_operation::val_str(String *str_value) ...@@ -824,14 +823,14 @@ String *Item_func_spatial_operation::val_str(String *str_value)
if ((null_value= if ((null_value=
(args[0]->null_value || args[1]->null_value || (args[0]->null_value || args[1]->null_value ||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) || !(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length()))))) !(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
g1->get_mbr(&mbr1, &c_end) ||
g2->get_mbr(&mbr2, &c_end))))
{ {
str_value= 0; str_value= 0;
goto exit; goto exit;
} }
g1->get_mbr(&mbr1, &c_end);
g2->get_mbr(&mbr2, &c_end);
mbr1.add_mbr(&mbr2); mbr1.add_mbr(&mbr2);
collector.set_extent(mbr1.xmin, mbr1.xmax, mbr1.ymin, mbr1.ymax); collector.set_extent(mbr1.xmin, mbr1.xmax, mbr1.ymin, mbr1.ymax);
...@@ -1356,11 +1355,11 @@ longlong Item_func_issimple::val_int() ...@@ -1356,11 +1355,11 @@ longlong Item_func_issimple::val_int()
DBUG_ENTER("Item_func_issimple::val_int"); DBUG_ENTER("Item_func_issimple::val_int");
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
if ((null_value= args[0]->null_value) || if ((null_value= (args[0]->null_value ||
!(g= Geometry::construct(&buffer, swkb->ptr(), swkb->length()))) !(g= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
g->get_mbr(&mbr, &c_end))))
DBUG_RETURN(0); DBUG_RETURN(0);
g->get_mbr(&mbr, &c_end);
collector.set_extent(mbr.xmin, mbr.xmax, mbr.ymin, mbr.ymax); collector.set_extent(mbr.xmin, mbr.xmax, mbr.ymin, mbr.ymax);
if (g->get_class_info()->m_type_id == Geometry::wkb_point) if (g->get_class_info()->m_type_id == Geometry::wkb_point)
...@@ -1596,11 +1595,11 @@ double Item_func_distance::val_real() ...@@ -1596,11 +1595,11 @@ double Item_func_distance::val_real()
if ((null_value= (args[0]->null_value || args[1]->null_value || if ((null_value= (args[0]->null_value || args[1]->null_value ||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) || !(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length()))))) !(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
g1->get_mbr(&mbr1, &c_end) ||
g2->get_mbr(&mbr2, &c_end))))
goto mem_error; goto mem_error;
g1->get_mbr(&mbr1, &c_end);
g2->get_mbr(&mbr2, &c_end);
mbr1.add_mbr(&mbr2); mbr1.add_mbr(&mbr2);
collector.set_extent(mbr1.xmin, mbr1.xmax, mbr1.ymin, mbr1.ymax); collector.set_extent(mbr1.xmin, mbr1.xmax, mbr1.ymin, mbr1.ymax);
......
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