Skip to content

Commit 983ed99

Browse files
committed
Fix pg_dump/pg_restore to restore event trigger comments later.
Repair an oversight in commit 8728b2c: 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
1 parent 0a9ae18 commit 983ed99

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,6 +3091,18 @@ _tocEntryRestorePass(TocEntry *te)
30913091
if (strcmp(te->desc, "EVENT TRIGGER") == 0 ||
30923092
strcmp(te->desc, "MATERIALIZED VIEW DATA") == 0)
30933093
return RESTORE_PASS_POST_ACL;
3094+
3095+
/*
3096+
* Comments need to be emitted in the same pass as their parent objects.
3097+
* ACLs haven't got comments, and neither do matview data objects, but
3098+
* event triggers do. (Fortunately, event triggers haven't got ACLs, or
3099+
* we'd need yet another weird special case.)
3100+
*/
3101+
if (strcmp(te->desc, "COMMENT") == 0 &&
3102+
strncmp(te->tag, "EVENT TRIGGER ", 14) == 0)
3103+
return RESTORE_PASS_POST_ACL;
3104+
3105+
/* All else can be handled in the main pass. */
30943106
return RESTORE_PASS_MAIN;
30953107
}
30963108

0 commit comments

Comments
 (0)