File tree 2 files changed +28
-2
lines changed
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>
108
108
<title>Notes</title>
109
109
110
110
<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.
112
119
</para>
113
120
</refsect1>
114
121
115
122
<refsect1 id="sql-createeventtrigger-examples">
116
123
<title>Examples</title>
117
124
118
125
<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:
120
127
121
128
<programlisting>
122
129
CREATE OR REPLACE FUNCTION abort_any_command()
Original file line number Diff line number Diff line change @@ -566,6 +566,25 @@ EventTriggerDDLCommandStart(Node *parsetree)
566
566
const char * tag ;
567
567
EventTriggerData trigdata ;
568
568
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
+
569
588
/*
570
589
* We want the list of command tags for which this procedure is actually
571
590
* invoked to match up exactly with the list that CREATE EVENT TRIGGER
You can’t perform that action at this time.
0 commit comments