postgresql/src/bin
Tom Lane 3d76328298 Fix pg_dump/pg_restore to emit REFRESH MATERIALIZED VIEW commands last.
Because we push all ACL (i.e. GRANT/REVOKE) restore steps to the end,
materialized view refreshes were occurring while the permissions on
referenced objects were still at defaults.  This led to failures if,
say, an MV owned by user A reads from a table owned by user B, even
if B had granted the necessary privileges to A.  We've had multiple
complaints about that type of restore failure, most recently from
Jordan Gigov.

The ideal fix for this would be to start treating ACLs as dependency-
sortable objects, rather than hard-wiring anything about their dump order
(the existing approach is a messy kluge dating to commit dc0e76ca3).
But that's going to be a rather major change, and it certainly wouldn't
lead to a back-patchable fix.  As a short-term solution, convert the
existing two-pass hack (ie, normal objects then ACLs) to a three-pass hack,
ie, normal objects then ACLs then matview refreshes.  Because this happens
in RestoreArchive(), it will also fix the problem when restoring from an
existing archive-format dump.

(Note this means that if a matview refresh would have failed under the
permissions prevailing at dump time, it'll fail during restore as well.
We'll define that as user error rather than something we should try
to work around.)

To avoid performance loss in parallel restore, we need the matview
refreshes to still be parallelizable.  Hence, clean things up enough
so that both ACLs and matviews are handled by the parallel restore
infrastructure, instead of reverting back to serial restore for ACLs.
There is still a final serial step, but it shouldn't normally have to
do anything; it's only there to try to recover if we get stuck due to
some problem like unresolved circular dependencies.

Patch by me, but it owes something to an earlier attempt by Kevin Grittner.
Back-patch to 9.3 where materialized views were introduced.

Discussion: https://postgr.es/m/28572.1500912583@sss.pgh.pa.us
2017-08-03 17:36:41 -04:00
..
initdb Fix new warnings from GCC 7 2017-05-16 08:52:39 -04:00
pg_archivecleanup Fix new warnings from GCC 7 2017-05-16 08:52:39 -04:00
pg_basebackup Fix pg_basebackup output to stdout on Windows. 2017-07-14 16:03:05 +03:00
pg_config Translation updates 2017-05-08 10:10:54 -04:00
pg_controldata Translation updates 2017-05-08 10:10:54 -04:00
pg_ctl Translation updates 2017-05-08 10:10:54 -04:00
pg_dump Fix pg_dump/pg_restore to emit REFRESH MATERIALIZED VIEW commands last. 2017-08-03 17:36:41 -04:00
pg_resetxlog Prevent running pg_resetwal/pg_resetxlog against wrong-version data dirs. 2017-05-29 17:08:16 -04:00
pg_rewind pg_rewind: Fix some problems when copying files >2GB. 2017-07-21 22:04:55 -04: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 Fix broken link-command-line ordering for libpgfeutils. 2017-07-14 12:26:53 -04:00
pg_xlogdump Fix record length computation in pg_waldump/xlogdump. 2017-06-05 16:10:07 -07:00
pgbench Fix broken link-command-line ordering for libpgfeutils. 2017-07-14 12:26:53 -04:00
pgevent Update copyright for 2016 2016-01-02 13:33:40 -05:00
psql Fix psql tab completion for CREATE USER MAPPING. 2017-07-27 14:13:15 -04:00
scripts Fix broken link-command-line ordering for libpgfeutils. 2017-07-14 12:26:53 -04:00
Makefile Update copyright for 2016 2016-01-02 13:33:40 -05:00