Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#5298 closed defect (fixed)

CopyTopology: ERROR: TopoGeometry 14678 does not exist in the child layer 1

Reported by: strk Owned by: strk
Priority: high Milestone: PostGIS 3.3.3
Component: topology Version: 3.3.x
Keywords: Cc:

Description (last modified by strk)

When trying to copy a topology I get this error:

CopyTopology: ERROR: TopoGeometry 14678 does not exist in the child layer 1

Context:

PL/pgSQL relationtrigger() riga 59 a RAISE
istruzione SQL "
      INSERT INTO topo_italia_20221207.relation
      SELECT * FROM topo_italia.relation
    "
funzione PL/pgSQL copytopology(character varying,character varying) riga 83 a EXECUTE 

PostGIS version is 3.3.1

Change History (8)

comment:1 by strk, 2 years ago

Cc: pigreco removed
Description: modified (diff)

comment:2 by strk, 2 years ago

It would be useful for the message (at the bare minimum) to report the ID of the topogeometry

comment:3 by strk, 2 years ago

Interesting enough, the topogeometry DOES exist in the relation table for layer_id=1:

=# Select * from topo_italia.relation where topogeo_id = 14678;
 topogeo_id | layer_id | element_id | element_type
------------+----------+------------+--------------
      14678 |        1 |       1769 |            3 

comment:4 by strk, 2 years ago

I could reproduce the problem locally by running an UPDATE of relation records associated with primitive layers, so that they would be processed LAST in the INSERT query shown as context:

=# update topo_italia.relation set layer_id = 1 where layer_id = 1;
UPDATE 8756
toto=# select copytopology('topo_italia', 'topo_italia20221207');
ERROR:  TopoGeometry 7590 does not exist in the child layer 1
CONTEXT:  PL/pgSQL function relationtrigger() line 59 at RAISE
SQL statement "
      INSERT INTO topo_italia20221207.relation
      SELECT * FROM topo_italia.relation
    "
PL/pgSQL function copytopology(character varying,character varying) line 83 at EXECUTE

Basically the relationtrigger seems to be running for each row instead of for each statement and it does not allow insertint a record of a hierarchical topogeometry BEFORE the underlying topogeometry.

One solution should be to disable the trigger during the copy and re-enable it afterwards.

comment:5 by strk, 2 years ago

Testcase pushed in https://git.osgeo.org/gitea/postgis/postgis/pulls/117 —- fix yet to be implemented

comment:6 by Sandro Santilli <strk@…>, 2 years ago

In 68f392d/git:

Ensure CopyTopology does not violate layer triggers

Makes sure hierarchical TopoGeometry definitions are always
loaded AFTER the primitives defining them.

References #5298 in master branch (3.4.0dev)

Includes regression test

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

Resolution: fixed
Status: newclosed

In dbb8913/git:

Ensure CopyTopology does not violate layer triggers

Makes sure hierarchical TopoGeometry definitions are always
loaded AFTER the primitives defining them.

Closes #5298 in 3.3 branch (3.3.3dev)

Includes regression test

comment:8 by strk, 2 years ago

Although 3.2 and earlier are also affected the patch doesn't apply cleanly and I don't think it's worth spending the time on backporting further anyway, given the many topology improvements in 3.3

Note: See TracTickets for help on using tickets.