From: Tom Lane Date: Mon, 30 Dec 2013 19:00:05 +0000 (-0500) Subject: Fix broken support for event triggers as extension members. X-Git-Tag: REL9_3_3~87 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a6e2b150fd8e024d638ed4f03d61a3fa26e4165;p=postgresql Fix broken support for event triggers as extension members. CREATE EVENT TRIGGER forgot to mark the event trigger as a member of its extension, and pg_dump didn't pay any attention anyway when deciding whether to dump the event trigger. Per report from Moshe Jacobson. Given the obvious lack of testing here, it's rather astonishing that ALTER EXTENSION ADD/DROP EVENT TRIGGER work, but they seem to. --- diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index 328e2a8952..f0df7301d0 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -344,7 +344,10 @@ insert_event_trigger_tuple(char *trigname, char *eventname, Oid evtOwner, referenced.objectSubId = 0; recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); - /* Post creation hook for new operator family */ + /* Depend on extension, if any. */ + recordDependencyOnCurrentExtension(&myself, false); + + /* Post creation hook for new event trigger */ InvokeObjectPostCreateHook(EventTriggerRelationId, trigoid, 0); /* Close pg_event_trigger. */ diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index f74935e0b9..c12db9943f 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -14125,6 +14125,10 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo) destroyPQExpBuffer(query); } +/* + * dumpTrigger + * write the declaration of one user-defined table trigger + */ static void dumpTrigger(Archive *fout, TriggerInfo *tginfo) { @@ -14137,6 +14141,10 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) const char *p; int findx; + /* + * we needn't check dobj.dump because TriggerInfo wouldn't have been + * created in the first place for non-dumpable triggers + */ if (dataOnly) return; @@ -14327,12 +14335,20 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) destroyPQExpBuffer(labelq); } +/* + * dumpEventTrigger + * write the declaration of one user-defined event trigger + */ static void dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo) { PQExpBuffer query; PQExpBuffer labelq; + /* Skip if not to be dumped */ + if (!evtinfo->dobj.dump || dataOnly) + return; + query = createPQExpBuffer(); labelq = createPQExpBuffer();