I have a DB (mydb) where one table (mytbl) contains a large object
column. The contents are managed by contrib/lo. This breaks when I
want to copy the DB to another host where the schema is already
present with some old contents: when I do
pg_dump -c mydb | psql -q -h otherhost mydb -f -
pg_dump emits a "DROP TABLE mytbl" which leaves the old lo contents on
otherhost orphaned and, even worse, raises an exception if pg_dump
wants to create a large object with an id already present. I thought
about a TRUNCATE TRIGGER which could make the appropriate lo_unlink
calls, but this trigger won't be called by DROP TABLE.
Any ideas?