1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Reduce lock levels of some trigger DDL and add FKs

Reduce lock levels to ShareRowExclusive for the following SQL
 CREATE TRIGGER (but not DROP or ALTER)
 ALTER TABLE ENABLE TRIGGER
 ALTER TABLE DISABLE TRIGGER
 ALTER TABLE … ADD CONSTRAINT FOREIGN KEY

Original work by Simon Riggs, extracted and refreshed by Andreas Karlsson
New test cases added by Andreas Karlsson
Reviewed by Noah Misch, Andres Freund, Michael Paquier and Simon Riggs
This commit is contained in:
Simon Riggs
2015-04-05 11:37:08 -04:00
parent ca6805338f
commit 0ef0396ae1
7 changed files with 1560 additions and 813 deletions

View File

@ -909,9 +909,9 @@ ERROR: could not serialize access due to read/write dependencies among transact
</para>
<para>
This lock mode is not automatically acquired by any
<productname>PostgreSQL</productname> command.
</para>
Acquired by <command>CREATE TRIGGER</command> and many forms of
<command>ALTER TABLE</command> (see <xref linkend="SQL-ALTERTABLE">).
</para>>
</listitem>
</varlistentry>
@ -958,9 +958,9 @@ ERROR: could not serialize access due to read/write dependencies among transact
<command>TRUNCATE</command>, <command>REINDEX</command>,
<command>CLUSTER</command>, and <command>VACUUM FULL</command>
commands. Many forms of <command>ALTER TABLE</> also acquire
a lock at this level (see <xref linkend="SQL-ALTERTABLE">).
This is also the default lock mode for <command>LOCK TABLE</command>
statements that do not specify a mode explicitly.
a lock at this level. This is also the default lock mode for
<command>LOCK TABLE</command> statements that do not specify
a mode explicitly.
</para>
</listitem>
</varlistentry>

View File

@ -406,6 +406,9 @@ ALTER TABLE ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable>
mode, and triggers configured as <literal>ENABLE ALWAYS</literal> will
fire regardless of the current replication mode.
</para>
<para>
This command acquires a <literal>SHARE ROW EXCLUSIVE</literal> lock.
</para>
</listitem>
</varlistentry>