From: Sandro Santilli Date: Fri, 6 May 2011 21:21:55 +0000 (+0000) Subject: topology.ST_ModEdgeHeal: Check for edge existance before TopoGeometry definitions... X-Git-Tag: 2.0.0alpha1~1700 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b0317575394fcd53a13169b68a14c1ab1ad7fef;p=postgis topology.ST_ModEdgeHeal: Check for edge existance before TopoGeometry definitions. Fixes bug #941 and regress-tests it. git-svn-id: http://svn.osgeo.org/postgis/trunk@7108 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/sql/sqlmm.sql b/topology/sql/sqlmm.sql index 925c42f97..28d1b3fc3 100644 --- a/topology/sql/sqlmm.sql +++ b/topology/sql/sqlmm.sql @@ -156,6 +156,30 @@ BEGIN RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name'; END; + BEGIN + EXECUTE 'SELECT * FROM ' || quote_ident(toponame) + || '.edge_data WHERE edge_id = ' || e1id + INTO STRICT e1rec; + EXCEPTION + WHEN NO_DATA_FOUND THEN + RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e1id; + WHEN INVALID_SCHEMA_NAME THEN + RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name'; + WHEN UNDEFINED_TABLE THEN + RAISE EXCEPTION 'corrupted topology "%" (missing edge_data table)', + toponame; + END; + + BEGIN + EXECUTE 'SELECT * FROM ' || quote_ident(toponame) + || '.edge_data WHERE edge_id = ' || e2id + INTO STRICT e2rec; + EXCEPTION + WHEN NO_DATA_FOUND THEN + RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e2id; + -- NOTE: checks for INVALID_SCHEMA_NAME or UNDEFINED_TABLE done before + END; + -- NOT IN THE SPECS: -- check if any topo_geom is defined only by one of the -- input edges. In such case there would be no way to adapt @@ -182,29 +206,6 @@ BEGIN e1id, e2id; END LOOP; - BEGIN - EXECUTE 'SELECT * FROM ' || quote_ident(toponame) - || '.edge_data WHERE edge_id = ' || e1id - INTO STRICT e1rec; - EXCEPTION - WHEN NO_DATA_FOUND THEN - RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e1id; - WHEN INVALID_SCHEMA_NAME THEN - RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name'; - WHEN UNDEFINED_TABLE THEN - RAISE EXCEPTION 'corrupted topology "%" (missing edge_data table)', - toponame; - END; - - BEGIN - EXECUTE 'SELECT * FROM ' || quote_ident(toponame) - || '.edge_data WHERE edge_id = ' || e2id - INTO STRICT e2rec; - EXCEPTION - WHEN NO_DATA_FOUND THEN - RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e2id; - -- NOTE: checks for INVALID_SCHEMA_NAME or UNDEFINED_TABLE done before - END; -- NOT IN THE SPECS: See if any of the two edges are closed. IF e1rec.start_node = e1rec.end_node THEN diff --git a/topology/test/regress/st_modedgeheal.sql b/topology/test/regress/st_modedgeheal.sql index 8c872d613..830a1bbef 100644 --- a/topology/test/regress/st_modedgeheal.sql +++ b/topology/test/regress/st_modedgeheal.sql @@ -73,8 +73,12 @@ INSERT INTO t.f VALUES ('F+E1', -- This should be forbidden, as F+E1 above could not be -- defined w/out one of the edges -SELECT 'MH(1,2)', topology.ST_ModEdgeHeal('t', 1, 2); -SELECT 'MH(2,1)', topology.ST_ModEdgeHeal('t', 2, 1); +SELECT topology.ST_ModEdgeHeal('t', 1, 2); +SELECT topology.ST_ModEdgeHeal('t', 2, 1); + +-- This is for ticket #941 +SELECT topology.ST_ModEdgeHeal('t', 1, 200); +SELECT topology.ST_ModEdgeHeal('t', 100, 2); -- Now see how signed edges are updated diff --git a/topology/test/regress/st_modedgeheal_expected b/topology/test/regress/st_modedgeheal_expected index decb7ce74..547f6dfe2 100644 --- a/topology/test/regress/st_modedgeheal_expected +++ b/topology/test/regress/st_modedgeheal_expected @@ -107,6 +107,8 @@ E1 E2 ERROR: TopoGeom 1 in layer 1 (t.f.g) cannot be represented healing edges 1 and 2 ERROR: TopoGeom 1 in layer 1 (t.f.g) cannot be represented healing edges 2 and 1 +ERROR: SQL/MM Spatial exception – non-existent edge 200 +ERROR: SQL/MM Spatial exception – non-existent edge 100 E3 E4 2|-4