postgresql/src/bin
Tom Lane fab5456356 Fix pg_dump/pg_restore to restore event triggers later.
Previously, event triggers were restored just after regular triggers
(and FK constraints, which are basically triggers).  This is risky
since an event trigger, once installed, could interfere with subsequent
restore commands.  Worse, because event triggers don't have any
particular dependencies on any post-data objects, a parallel restore
would consider them eligible to be restored the moment the post-data
phase starts, allowing them to also interfere with restoration of a
whole bunch of objects that would have been restored before them in
a serial restore.  There's no way to completely remove the risk of a
misguided event trigger breaking the restore, since if nothing else
it could break other event triggers.  But we can certainly push them
to later in the process to minimize the hazard.

To fix, tweak the RestorePass mechanism introduced by commit 3eb9a5e7c
so that event triggers are handled as part of the post-ACL processing
pass (renaming the "REFRESH" pass to "POST_ACL" to reflect its more
general use).  This will cause them to restore after everything except
matview refreshes, which seems OK since matview refreshes really ought
to run in the post-restore state of the database.  In a parallel
restore, event triggers and matview refreshes might be intermixed,
but that seems all right as well.

Also update the code and comments in pg_dump_sort.c so that its idea
of how things are sorted agrees with what actually happens due to
the RestorePass mechanism.  This is mostly cosmetic: it'll affect the
order of objects in a dump's TOC, but not the actual restore order.
But not changing that would be quite confusing to somebody reading
the code.

Back-patch to all supported branches.

Fabrízio de Royes Mello, tweaked a bit by me

Discussion: https://postgr.es/m/CAFcNs+ow1hmFox8P--3GSdtwz-S3Binb6ZmoP6Vk+Xg=K6eZNA@mail.gmail.com
2020-03-09 14:58:11 -04:00
..
initdb Translation updates 2019-11-11 10:27:46 +01:00
pg_archivecleanup Fix new warnings from GCC 7 2017-05-16 08:52:39 -04:00
pg_basebackup Translation updates 2019-11-11 10:27:46 +01:00
pg_config Translation updates 2019-11-11 10:27:46 +01:00
pg_controldata Translation updates 2019-11-11 10:27:46 +01:00
pg_ctl Translation updates 2020-02-10 12:57:12 +01:00
pg_dump Fix pg_dump/pg_restore to restore event triggers later. 2020-03-09 14:58:11 -04:00
pg_resetxlog Translation updates 2019-11-11 10:27:46 +01:00
pg_rewind Translation updates 2019-11-11 10:27:46 +01:00
pg_test_fsync Avoid depending on non-POSIX behavior of fcntl(2). 2017-04-21 15:55:56 -04:00
pg_test_timing Move pg_test_timing from contrib/ to src/bin/ 2015-04-20 21:30:12 -04:00
pg_upgrade Document the pg_upgrade -j/--jobs option as taking an argument 2020-02-11 23:58:16 +01:00
pg_xlogdump pg_waldump: Fix --bkp-details to not issue spurious newlines for FPWs. 2019-10-29 22:54:36 -07:00
pgbench Fix integer-overflow edge case detection in interval_mul and pgbench. 2019-11-07 11:23:03 -05:00
pgevent Update copyright for 2016 2016-01-02 13:33:40 -05:00
psql Translation updates 2019-11-11 10:27:46 +01:00
scripts createdb: Fix quoting of --encoding, --lc-ctype and --lc-collate 2020-02-27 11:21:23 +09:00
Makefile Update copyright for 2016 2016-01-02 13:33:40 -05:00