Commits

Tom Lane  committed c01bc51

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.

  • Participants
  • Parent commits d7ee431
  • Branches jsonbuild, master

Comments (0)

Files changed (2)

File src/backend/commands/event_trigger.c

 	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. */

File src/bin/pg_dump/pg_dump.c

 	destroyPQExpBuffer(query);
 }
 
+/*
+ * dumpTrigger
+ *	  write the declaration of one user-defined table trigger
+ */
 static void
 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;
 
 	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();