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
This commit is contained in:
Michael Paquier 2018-09-21 15:09:40 +09:00
parent 84f14fb788
commit 3d4b143dc7
2 changed files with 8 additions and 1 deletions

View File

@ -372,6 +372,11 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
tables may not be declared <literal>NOT VALID</literal> at present. tables may not be declared <literal>NOT VALID</literal> at present.
</para> </para>
<para>
The addition of a foreign key constraint requires a
<literal>SHARE ROW EXCLUSIVE</literal> lock on the referenced table.
</para>
<para> <para>
Additional restrictions apply when unique or primary key constraints Additional restrictions apply when unique or primary key constraints
are added to partitioned tables; see <xref linkend="sql-createtable" />. are added to partitioned tables; see <xref linkend="sql-createtable" />.

View File

@ -934,7 +934,9 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
is used. The referenced columns must be the columns of a non-deferrable is used. The referenced columns must be the columns of a non-deferrable
unique or primary key constraint in the referenced table. The user unique or primary key constraint in the referenced table. The user
must have <literal>REFERENCES</literal> permission on the referenced table must have <literal>REFERENCES</literal> permission on the referenced table
(either the whole table, or the specific referenced columns). (either the whole table, or the specific referenced columns). The
addition of a foreign key constraint requires a
<literal>SHARE ROW EXCLUSIVE</literal> lock on the referenced table.
Note that foreign key constraints cannot be defined between temporary Note that foreign key constraints cannot be defined between temporary
tables and permanent tables. Also note that while it is possible to tables and permanent tables. Also note that while it is possible to
define a foreign key on a partitioned table, it is not possible to define a foreign key on a partitioned table, it is not possible to