From 4b96edeb54a4a896a29bf3435b13848badbbd6d5 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 6 May 2011 06:46:58 +0000 Subject: [PATCH] Closer-to-iso exceptions from ST_GetFaceEdges/ST_ModEdgeHeal [RT-SIGTA] git-svn-id: http://svn.osgeo.org/postgis/trunk@7105 b70326c6-7e19-0410-871a-916f4a2858ee --- topology/sql/sqlmm.sql | 55 +++++++++++-------- topology/test/regress/st_getfaceedges.sql | 6 ++ .../test/regress/st_getfaceedges_expected | 5 ++ topology/test/regress/st_modedgeheal_expected | 2 +- 4 files changed, 45 insertions(+), 23 deletions(-) diff --git a/topology/sql/sqlmm.sql b/topology/sql/sqlmm.sql index 11b92cebc..925c42f97 100644 --- a/topology/sql/sqlmm.sql +++ b/topology/sql/sqlmm.sql @@ -54,6 +54,10 @@ BEGIN RAISE EXCEPTION 'SQL/MM Spatial exception - null argument'; END IF; + IF toponame = '' THEN + RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name'; + END IF; + n := 1; -- Construct the face geometry, then for each polygon: @@ -149,7 +153,7 @@ BEGIN INTO STRICT topoid WHERE name = toponame; EXCEPTION WHEN NO_DATA_FOUND THEN - RAISE EXCEPTION 'unknown topology "%"', toponame; + RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name'; END; -- NOT IN THE SPECS: @@ -186,7 +190,7 @@ BEGIN WHEN NO_DATA_FOUND THEN RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e1id; WHEN INVALID_SCHEMA_NAME THEN - RAISE EXCEPTION 'non-existent topology schema "%"', toponame; + RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name'; WHEN UNDEFINED_TABLE THEN RAISE EXCEPTION 'corrupted topology "%" (missing edge_data table)', toponame; @@ -349,32 +353,39 @@ LANGUAGE 'plpgsql' VOLATILE; -- -- ST_GetFaceGeometry(atopology, aface) -- -CREATE OR REPLACE FUNCTION topology.ST_GetFaceGeometry(varchar, integer) +CREATE OR REPLACE FUNCTION topology.ST_GetFaceGeometry(toponame varchar, aface integer) RETURNS GEOMETRY AS $$ DECLARE - atopology ALIAS FOR $1; - aface ALIAS FOR $2; rec RECORD; BEGIN - -- - -- Atopology and aface are required - -- - IF atopology IS NULL OR aface IS NULL THEN - RAISE EXCEPTION - 'SQL/MM Spatial exception - null argument'; - END IF; - -- - -- Construct face - -- - FOR rec IN EXECUTE 'SELECT ST_BuildArea(ST_Collect(geom)) FROM ' - || quote_ident(atopology) - || '.edge WHERE left_face = ' || aface || - ' OR right_face = ' || aface - LOOP - RETURN rec.st_buildarea; - END LOOP; + -- + -- toponame and aface are required + -- + IF toponame IS NULL OR aface IS NULL THEN + RAISE EXCEPTION + 'SQL/MM Spatial exception - null argument'; + END IF; + + -- + -- Construct face + -- + BEGIN + FOR rec IN EXECUTE 'SELECT ST_BuildArea(ST_Collect(geom)) FROM ' + || quote_ident(toponame) + || '.edge WHERE left_face = ' || aface || + ' OR right_face = ' || aface + LOOP + RETURN rec.st_buildarea; + END LOOP; + EXCEPTION + 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; -- diff --git a/topology/test/regress/st_getfaceedges.sql b/topology/test/regress/st_getfaceedges.sql index 408eda5be..6398bcd12 100644 --- a/topology/test/regress/st_getfaceedges.sql +++ b/topology/test/regress/st_getfaceedges.sql @@ -2,6 +2,12 @@ set client_min_messages to ERROR; SELECT topology.CreateTopology('tt') > 0; +SELECT topology.ST_GetFaceEdges(null, null); +SELECT topology.ST_GetFaceEdges('tt', null); +SELECT topology.ST_GetFaceEdges(null, 1); +SELECT topology.ST_GetFaceEdges('', 1); +SELECT topology.ST_GetFaceEdges('NonExistent', 1); + SELECT 'E'||topology.AddEdge('tt', 'LINESTRING(2 2, 2 8)'); -- 1 SELECT 'E'||topology.AddEdge('tt', 'LINESTRING(2 8, 8 8)'); -- 2 SELECT 'E'||topology.AddEdge('tt', 'LINESTRING(8 8, 8 2, 2 2)'); -- 3 diff --git a/topology/test/regress/st_getfaceedges_expected b/topology/test/regress/st_getfaceedges_expected index 05a5109eb..f95751d8d 100644 --- a/topology/test/regress/st_getfaceedges_expected +++ b/topology/test/regress/st_getfaceedges_expected @@ -1,4 +1,9 @@ t +ERROR: SQL/MM Spatial exception - null argument +ERROR: SQL/MM Spatial exception - null argument +ERROR: SQL/MM Spatial exception - null argument +ERROR: SQL/MM Spatial exception - invalid topology name +ERROR: SQL/MM Spatial exception - invalid topology name E1 E2 E3 diff --git a/topology/test/regress/st_modedgeheal_expected b/topology/test/regress/st_modedgeheal_expected index dc0072fdd..decb7ce74 100644 --- a/topology/test/regress/st_modedgeheal_expected +++ b/topology/test/regress/st_modedgeheal_expected @@ -7,7 +7,7 @@ COMMIT ERROR: SQL/MM Spatial exception - null argument ERROR: SQL/MM Spatial exception - null argument ERROR: SQL/MM Spatial exception - null argument -ERROR: unknown topology "" +ERROR: SQL/MM Spatial exception - invalid topology name ERROR: SQL/MM Spatial exception – non-connected edges ERROR: SQL/MM Spatial exception – other edges connected (ie: 19) ERROR: Edge 2 is closed, cannot heal to edge 3 -- 2.50.1