regress/legacy_query.sql regress/addnode.sql \
regress/addedge.sql regress/addface.sql \
regress/addface2.5d.sql \
+ regress/addtopogeometrycolumn.sql \
regress/polygonize.sql \
regress/st_addisoedge.sql \
regress/st_addisonode.sql \
--- /dev/null
+set client_min_messages to WARNING;
+\set VERBOSITY terse
+
+select createtopology('tt') > 0;
+select addtopogeometrycolumn('tt','public','feature','tg','POINT'); -- fail
+create table feature(id integer);
+select addtopogeometrycolumn('tt','public','feature','tg','BOGUS'); -- fail
+
+-- Expect first good call returning 1
+select 'good', addtopogeometrycolumn('tt','public','feature','tg','POINT');
+
+select l.layer_id, l.schema_name, l.table_name, l.feature_column,
+ l.feature_type, l.level, l.child_id
+from topology.layer l, topology.topology t
+where l.topology_id = t.id and t.name = 'tt'
+order by l.layer_id;
+
+drop table feature;
+select droptopology('tt');
--- /dev/null
+t
+ERROR: relation "public.feature" does not exist
+ERROR: Layer type must be one of POINT,LINE,POLYGON,COLLECTION
+good|1
+1|public|feature|tg|1|0|
+Topology 'tt' dropped
RAISE EXCEPTION 'Topology % does not exist', toponame;
END IF;
- --
- -- Get new layer id from sequence
- --
- FOR rec IN EXECUTE 'SELECT nextval(' ||
- quote_literal(
- quote_ident(toponame) || '.layer_id_seq'
- ) || ')'
- LOOP
- layer_id = rec.nextval;
- END LOOP;
-
IF ltype = 'POINT' THEN
intltype = 1;
ELSIF ltype = 'LINE' THEN
RAISE EXCEPTION 'Layer type must be one of POINT,LINE,POLYGON,COLLECTION';
END IF;
+ --
+ -- Add new TopoGeometry column in schema.table
+ --
+ EXECUTE 'ALTER TABLE ' || quote_ident(schema)
+ || '.' || quote_ident(tbl)
+ || ' ADD COLUMN ' || quote_ident(col)
+ || ' topology.TopoGeometry;';
+
+
+ --
+ -- Get new layer id from sequence
+ --
+ EXECUTE 'SELECT nextval(' ||
+ quote_literal(
+ quote_ident(toponame) || '.layer_id_seq'
+ ) || ')' INTO STRICT layer_id;
+
--
-- See if child id exists and extract its level
--
EXECUTE 'CREATE SEQUENCE ' || quote_ident(toponame)
|| '.topogeo_s_' || layer_id;
- --
- -- Add new TopoGeometry column in schema.table
- --
- EXECUTE 'ALTER TABLE ' || quote_ident(schema)
- || '.' || quote_ident(tbl)
- || ' ADD COLUMN ' || quote_ident(col)
- || ' topology.TopoGeometry;';
-
--
-- Add constraints on TopoGeom column
--