Opened 12 years ago

Closed 12 years ago

#1371 closed defect (fixed)

postgis_restore.pl: insert or update on table "layer" violates foreign key constraint "layer_topology_id_fkey"

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

Description

Restoring a dump containing topologies using postgis_restore.pl gives the following error: insert or update on table "layer" violates foreign key constraint "layer_topology_id_fkey"

Change History (5)

comment:1 by strk, 12 years ago

The layer table is being populated _before_ the topology table. May be the cause of it:

5170407:COPY layer (topology_id, layer_id, schema_name, table_name, feature_column, feature_type, level, child_id) FROM stdin;
5170438:COPY topology (id, name, srid, "precision", hasz) FROM stdin;

comment:2 by strk, 12 years ago

Ok, here's the thing: the _definition_ of layer and topology tables comes from the topology.sql script, not from the dump. This means it is equipped with constraints.

If we restored the tables from the dump we'd get the constraints added later and so wouldn't break them.

I guess this was a problem with geometry_columns as well before it became a view.

comment:3 by strk, 12 years ago

Tried and works fine. But comparing the tables between 1.5 and 2.0 there's a difference in topology.topology which has an additional field. We would then need a function that adds the field if missing from the table in the dump. But only if the dump does have topology…

comment:4 by strk, 12 years ago

Another alternative could be disabling triggers on the two tables. Will try that as well before committing. This other alternative has the advantage of having no need to convert the table later.

comment:5 by strk, 12 years ago

Resolution: fixed
Status: newclosed

The disabling/enabling revealed successful. Didn't test with a dump from 1.5 with topology, but should work. See r8397

Note: See TracTickets for help on using tickets.