From: Tom Lane Date: Mon, 30 Dec 2013 19:00:02 +0000 (-0500) Subject: Fix broken support for event triggers as extension members. X-Git-Tag: REL9_4_BETA1~746 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c01bc51f8d596d425d897c833ef11ca3670ea984;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 1d639fbd47..eb9ef7583c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -14332,6 +14332,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) { @@ -14344,6 +14348,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; @@ -14534,12 +14542,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();