Opened 4 years ago

Closed 4 years ago

#4841 closed enhancement (fixed)

find_topology

Reported by: strk Owned by: strk
Priority: medium Milestone: PostGIS 3.2.0
Component: topology Version: master
Keywords: Cc:

Description

Not sure about which name to give to this function but I feel the need for a function that takes a reference to a Topology layer (table REGCLASS, column NAME) and returns the name of a topology (or a whole record for the topology, could be even better)

Currently proposed name was made after current find_srid function, but suggestions for a better name are welcome.

Change History (7)

comment:1 by strk, 4 years ago

Milestone: PostGIS 3.2.0

I'm thinking we'd want to accept the possible "query types":

  • find_topology(TopoGeometry) -- by TopoGeometry
  • find_topology(text) -- by Name
  • find_topology(integer) -- by ID
  • find_topology(regclass, name) -- by layer reference

Example usage:

  • SELECT srid FROM find_topology('testtopo');
  • SELECT (find_topology('mylayer', 'tg')).name;

comment:2 by robe, 4 years ago

Seems fine and fine to return a topology record.

Only thing that might be an issue is if you delete a column on the topology table (which I assume would be rare), you'd have to drop this function first. I forget if adding a column has similar affect. Like with table types you need to do a CASCADE for dependent objects.

comment:3 by strk, 4 years ago

I did find a problem:

ERROR:  cannot drop table topology because other objects depend on it
DETAIL:  function findtopology(topogeometry) depends on type topology

The uninstall script would need more love if we had to add similar functions

comment:4 by strk, 4 years ago

Merge request https://gitlab.com/postgis/postgis/-/merge_requests/17 tackles the above problem

comment:5 by Sandro Santilli <strk@…>, 4 years ago

In 88b689c/git:

Allows uninstalling when having functions returning table types.

Drops tables at the end, before schemas
Drops table triggers before dropping functions

References #4841

comment:6 by strk, 4 years ago

WIP for FindTopology is in https://gitlab.com/nibioopensource/pgtopo_update_sql/-/merge_requests/54 Waiting for documentation before being merged :)

comment:7 by Sandro Santilli <strk@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 4cc0051/git:

Implement FindTopology()

Closes #4841

Includes testcase and documentation

Note: See TracTickets for help on using tickets.