Skip to content

Commit ce9cf8e

Browse files
committed
Document lock taken on referenced table when adding a foreign key
This can happen for CREATE TABLE and ALTER TABLE, so a mention is added to both of them in the concerned subsections. Author: Adrien Nayrat Discussion: https://postgr.es/m/c4e8af11-1dfc-766a-c953-76979b9fcdaa@anayrat.info
1 parent bd1463e commit ce9cf8e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

doc/src/sgml/ref/alter_table.sgml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
372372
tables may not be declared <literal>NOT VALID</literal> at present.
373373
</para>
374374

375+
<para>
376+
The addition of a foreign key constraint requires a
377+
<literal>SHARE ROW EXCLUSIVE</literal> lock on the referenced table.
378+
</para>
379+
375380
<para>
376381
Additional restrictions apply when unique or primary key constraints
377382
are added to partitioned tables; see <xref linkend="sql-createtable" />.

doc/src/sgml/ref/create_table.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,9 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
992992
is used. The referenced columns must be the columns of a non-deferrable
993993
unique or primary key constraint in the referenced table. The user
994994
must have <literal>REFERENCES</literal> permission on the referenced table
995-
(either the whole table, or the specific referenced columns).
995+
(either the whole table, or the specific referenced columns). The
996+
addition of a foreign key constraint requires a
997+
<literal>SHARE ROW EXCLUSIVE</literal> lock on the referenced table.
996998
Note that foreign key constraints cannot be defined between temporary
997999
tables and permanent tables. Also note that while it is possible to
9981000
define a foreign key on a partitioned table, it is not possible to

0 commit comments

Comments
 (0)