summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/pg_dump.c')
-rw-r--r--src/bin/pg_dump/pg_dump.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d1db3702bea..479fd89e17b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -16978,6 +16978,7 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
+ PQExpBuffer delqry;
PQExpBuffer labelq;
/* Skip if not to be dumped */
@@ -16985,6 +16986,7 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
return;
query = createPQExpBuffer();
+ delqry = createPQExpBuffer();
labelq = createPQExpBuffer();
appendPQExpBufferStr(query, "CREATE EVENT TRIGGER ");
@@ -17024,14 +17026,21 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
}
appendPQExpBufferStr(query, ";\n");
}
+
+ appendPQExpBuffer(delqry, "DROP EVENT TRIGGER %s;\n",
+ fmtId(evtinfo->dobj.name));
+
appendPQExpBuffer(labelq, "EVENT TRIGGER %s",
fmtId(evtinfo->dobj.name));
if (evtinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, evtinfo->dobj.catId, evtinfo->dobj.dumpId,
- evtinfo->dobj.name, NULL, NULL, evtinfo->evtowner, false,
+ evtinfo->dobj.name, NULL, NULL,
+ evtinfo->evtowner, false,
"EVENT TRIGGER", SECTION_POST_DATA,
- query->data, "", NULL, NULL, 0, NULL, NULL);
+ query->data, delqry->data, NULL,
+ NULL, 0,
+ NULL, NULL);
if (evtinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
@@ -17039,6 +17048,7 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
destroyPQExpBuffer(query);
+ destroyPQExpBuffer(delqry);
destroyPQExpBuffer(labelq);
}