Commit c01bc51f authored by Tom Lane's avatar Tom Lane

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.
parent d7ee4311
...@@ -344,7 +344,10 @@ insert_event_trigger_tuple(char *trigname, char *eventname, Oid evtOwner, ...@@ -344,7 +344,10 @@ insert_event_trigger_tuple(char *trigname, char *eventname, Oid evtOwner,
referenced.objectSubId = 0; referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); 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); InvokeObjectPostCreateHook(EventTriggerRelationId, trigoid, 0);
/* Close pg_event_trigger. */ /* Close pg_event_trigger. */
......
...@@ -14332,6 +14332,10 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo) ...@@ -14332,6 +14332,10 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo)
destroyPQExpBuffer(query); destroyPQExpBuffer(query);
} }
/*
* dumpTrigger
* write the declaration of one user-defined table trigger
*/
static void static void
dumpTrigger(Archive *fout, TriggerInfo *tginfo) dumpTrigger(Archive *fout, TriggerInfo *tginfo)
{ {
...@@ -14344,6 +14348,10 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) ...@@ -14344,6 +14348,10 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
const char *p; const char *p;
int findx; 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) if (dataOnly)
return; return;
...@@ -14534,12 +14542,20 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) ...@@ -14534,12 +14542,20 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
destroyPQExpBuffer(labelq); destroyPQExpBuffer(labelq);
} }
/*
* dumpEventTrigger
* write the declaration of one user-defined event trigger
*/
static void static void
dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo) dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
{ {
PQExpBuffer query; PQExpBuffer query;
PQExpBuffer labelq; PQExpBuffer labelq;
/* Skip if not to be dumped */
if (!evtinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer(); query = createPQExpBuffer();
labelq = createPQExpBuffer(); labelq = createPQExpBuffer();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment