postgresql/src/bin/pg_dump
Tom Lane 0b02476442 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
..
po Translation updates 2020-02-10 12:55:41 +01:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
common.c Handle extension members when first setting object dump flags in pg_dump. 2016-01-13 18:55:27 -05:00
compress_io.c Fix pg_dump's errno checking for zlib I/O 2017-08-02 18:26:58 -04:00
compress_io.h Fix pg_dump's errno checking for zlib I/O 2017-08-02 18:26:58 -04:00
dumputils.c Further fixes for quoted-list GUC values in pg_dump and ruleutils.c. 2018-07-31 13:00:08 -04:00
dumputils.h Further fixes for quoted-list GUC values in pg_dump and ruleutils.c. 2018-07-31 13:00:08 -04:00
keywords.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
Makefile Update copyright for 2015 2015-01-06 11:43:47 -05:00
nls.mk Translation updates 2016-02-08 14:21:00 -05:00
parallel.c Fix parallel pg_dump/pg_restore for failure to create worker processes. 2020-01-31 14:41:49 -05:00
parallel.h Fix parallel pg_dump/pg_restore for failure to create worker processes. 2020-01-31 14:41:49 -05:00
pg_backup.h Avoid using unsafe search_path settings during dump and restore. 2018-02-26 10:18:22 -05:00
pg_backup_archiver.c Fix pg_dump/pg_restore to restore event triggers later. 2020-03-09 14:58:11 -04:00
pg_backup_archiver.h Fix pg_dump/pg_restore to restore event triggers later. 2020-03-09 14:58:11 -04:00
pg_backup_custom.c Fix typos in comments. 2017-02-06 11:34:18 +02:00
pg_backup_db.c Empty search_path in Autovacuum and non-psql/pgbench clients. 2018-02-26 07:39:48 -08:00
pg_backup_db.h Make pg_dump error cleanly with -j against hot standby 2016-05-26 22:18:04 +02:00
pg_backup_directory.c Fix pg_dump's errno checking for zlib I/O 2017-08-02 18:26:58 -04:00
pg_backup_null.c Access pg_dump's options structs through Archive struct, not directly. 2016-01-13 17:48:33 -05:00
pg_backup_tar.c Fix build on zlib-less environments 2017-08-03 14:55:17 -04:00
pg_backup_tar.h Fix tar files emitted by pg_dump and pg_basebackup to be POSIX conformant. 2012-09-28 15:19:15 -04:00
pg_backup_utils.c Clean up thread management in parallel pg_dump for Windows. 2016-05-27 12:02:09 -04:00
pg_backup_utils.h Tweak __attribute__-wrapping macros for better pgindent results. 2015-03-26 14:03:25 -04:00
pg_dump.c Teach pg_dump to dump comments on RLS policy objects. 2020-02-17 18:40:02 -05:00
pg_dump.h Fix pg_dump's handling of circular dependencies in views. 2019-10-26 17:37:19 -04:00
pg_dump_sort.c Fix pg_dump/pg_restore to restore event triggers later. 2020-03-09 14:58:11 -04:00
pg_dumpall.c Further fixes for quoted-list GUC values in pg_dump and ruleutils.c. 2018-07-31 13:00:08 -04:00
pg_restore.c Change pg_restore -f- to dump to stdout instead of to ./- 2019-11-05 09:57:36 -03:00