Thread: man pg-dump + triggers

man pg-dump + triggers

From
Dan Langille
Date:
I found this hard to comprehend upon the first reading:

 When doing a data only dump, pg_dump emits queries to disable triggers on
 user tables before inserting the data and queries to re-enable them after
 the data has been inserted. If the restore is stopped in the middle, the
 system catalogs may be left in the wrong state.

I first thought that pg_dump issues a command to disable triggers.  What
it meant, I think, is that pg_dump includes those commands within the
output.  Those commands are actually processed/issued by pg_restore (or
perhaps psql in a 'psql mydb < mydump.sql' fashion.

If my impressions are correct, then I think the following is more
appropriate:

 When doing a data-only dump, pg_dump will output data insert statements
 that are wrapped with a pair of commands to first disable and then re-enable
 triggers on user tables.  If the restore is stopped in the middle
 of the inserts, the system catalogs may be left in the wrong state.


NOTE: I am not sure that "catalogs may be left in the wrong state" is the
correct phrase to use.

cheers