summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2020-04-08 15:23:39 +0000
committerTom Lane2020-04-08 15:23:39 +0000
commitd050c611373182ec87afd4912a330c4dac8684cc (patch)
tree4d2819a40c811815b7a8f1d96d67032172f67341
parent5fae6641015578538111c8c0515fa62c4b68f1ae (diff)
Fix pg_dump/pg_restore to restore event trigger comments later.
Repair an oversight in commit 8728b2c70: if we're postponing restore of event triggers to the end, we must also postpone restoring any comments on them, since of course we cannot create the comments first. (This opens yet another opportunity for an event trigger to bollix the restore, but there's no help for that.) Per bug #16346 from Alexander Lakhin. Like the previous commit, back-patch to all supported branches. Hamid Akhtar and Tom Lane Discussion: https://postgr.es/m/16346-6210ad7a0ea81be1@postgresql.org
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index f0deda7a352..eab2f9e253f 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -3092,6 +3092,18 @@ _tocEntryRestorePass(TocEntry *te)
if (strcmp(te->desc, "EVENT TRIGGER") == 0 ||
strcmp(te->desc, "MATERIALIZED VIEW DATA") == 0)
return RESTORE_PASS_POST_ACL;
+
+ /*
+ * Comments need to be emitted in the same pass as their parent objects.
+ * ACLs haven't got comments, and neither do matview data objects, but
+ * event triggers do. (Fortunately, event triggers haven't got ACLs, or
+ * we'd need yet another weird special case.)
+ */
+ if (strcmp(te->desc, "COMMENT") == 0 &&
+ strncmp(te->tag, "EVENT TRIGGER ", 14) == 0)
+ return RESTORE_PASS_POST_ACL;
+
+ /* All else can be handled in the main pass. */
return RESTORE_PASS_MAIN;
}