Name

Populate_Topology_Layer — Adds missing entries to topology.layer table by reading metadata from topo tables.

Synopsis

setof record Populate_Topology_Layer();

Description

Adds missing entries to the topology.layer table by inspecting topology constraints on tables. This function is useful for fixing up entries in topology catalog after restores of schemas with topo data.

It returns the list of entries created. Returned columns are schema_name, table_name, feature_column.

Availability: 2.3.0

Examples

Code
SELECT CreateTopology('strk_topo');
CREATE SCHEMA strk;
CREATE TABLE strk.parcels(gid serial, parcel_id varchar(20) PRIMARY KEY, address text);
SELECT topology.AddTopoGeometryColumn('strk_topo', 'strk', 'parcels', 'topo', 'POLYGON');
Output
 createtopology
----------------
              1
(1 row)

CREATE SCHEMA
CREATE TABLE
 addtopogeometrycolumn
-----------------------
                     1
(1 row)

This query returns no records because the feature is already registered.

Code
SELECT *
FROM topology.Populate_Topology_Layer();
Output
(0 rows)

Rebuild the topology layer catalog.

Code
TRUNCATE TABLE topology.layer;
Output
TRUNCATE TABLE
Code
SELECT *
FROM topology.Populate_Topology_Layer();
Output
 schema_name | table_name | feature_column
-------------+------------+----------------
 strk        | parcels    | topo
(1 row)
Code
SELECT topology_id, layer_id,
       schema_name AS sn, table_name AS tn, feature_column AS fc
FROM topology.layer;
Output
 topology_id | layer_id |  sn  |   tn    |  fc
-------------+----------+------+---------+------
           1 |        1 | strk | parcels | topo
(1 row)