File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -108,15 +108,22 @@ CREATE EVENT TRIGGER <replaceable class="PARAMETER">name</replaceable>
108108 <title>Notes</title>
109109
110110 <para>
111- To create a trigger on a event, the user must be superuser.
111+ Only superusers can create event triggers.
112+ </para>
113+
114+ <para>
115+ Event triggers are disabled in single-user mode (see <xref
116+ linkend="app-postgres">). If an erroneous event trigger disables the
117+ database so much that you can't even drop the trigger, restart in
118+ single-user mode and you'll be able to do that.
112119 </para>
113120 </refsect1>
114121
115122 <refsect1 id="sql-createeventtrigger-examples">
116123 <title>Examples</title>
117124
118125 <para>
119- Forbid the execution of any <link linkend="ddl">ddl </link> command:
126+ Forbid the execution of any <link linkend="ddl">DDL </link> command:
120127
121128<programlisting>
122129CREATE OR REPLACE FUNCTION abort_any_command()
Original file line number Diff line number Diff line change @@ -566,6 +566,25 @@ EventTriggerDDLCommandStart(Node *parsetree)
566566 const char * tag ;
567567 EventTriggerData trigdata ;
568568
569+ /*
570+ * Event Triggers are completely disabled in standalone mode. There are
571+ * (at least) two reasons for this:
572+ *
573+ * 1. A sufficiently broken event trigger might not only render the
574+ * database unusable, but prevent disabling itself to fix the situation.
575+ * In this scenario, restarting in standalone mode provides an escape
576+ * hatch.
577+ *
578+ * 2. BuildEventTriggerCache relies on systable_beginscan_ordered, and
579+ * therefore will malfunction if pg_event_trigger's indexes are damaged.
580+ * To allow recovery from a damaged index, we need some operating mode
581+ * wherein event triggers are disabled. (Or we could implement
582+ * heapscan-and-sort logic for that case, but having disaster recovery
583+ * scenarios depend on code that's otherwise untested isn't appetizing.)
584+ */
585+ if (!IsUnderPostmaster )
586+ return ;
587+
569588 /*
570589 * We want the list of command tags for which this procedure is actually
571590 * invoked to match up exactly with the list that CREATE EVENT TRIGGER
You can’t perform that action at this time.
0 commit comments