From 3d4b143dc7fd9d060e9f11ac6c17620f58cfc33d Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Fri, 21 Sep 2018 15:09:40 +0900 Subject: [PATCH] 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 --- doc/src/sgml/ref/alter_table.sgml | 5 +++++ doc/src/sgml/ref/create_table.sgml | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index ec6b4c3311..f13a6cd944 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -372,6 +372,11 @@ WITH ( MODULUS numeric_literal, REM tables may not be declared NOT VALID at present. + + The addition of a foreign key constraint requires a + SHARE ROW EXCLUSIVE lock on the referenced table. + + Additional restrictions apply when unique or primary key constraints are added to partitioned tables; see . diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index a89a7e00ed..86b758ff8e 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -934,7 +934,9 @@ WITH ( MODULUS numeric_literal, REM is used. The referenced columns must be the columns of a non-deferrable unique or primary key constraint in the referenced table. The user must have REFERENCES 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 + SHARE ROW EXCLUSIVE lock on the referenced table. Note that foreign key constraints cannot be defined between temporary 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