Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa4416d

Browse files
committed
Doc: clarify locking requirements for ALTER TABLE ADD FOREIGN KEY.
The docs explained that a SHARE ROW EXCLUSIVE lock is needed on thereferenced table, but failed to say the same about the table beingaltered. Since the page says that ACCESS EXCLUSIVE lock is takenunless otherwise stated, this left readers with the wrong conclusion.Discussion:https://postgr.es/m/834603375.3470346.1586482852542@mail.yahoo.com
1 parentb75aa49 commitaa4416d

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

‎doc/src/sgml/ref/alter_table.sgml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
141141
<para>
142142
<command>ALTER TABLE</command> changes the definition of an existing table.
143143
There are several subforms described below. Note that the lock level required
144-
may differ for each subform. An <literal>ACCESS EXCLUSIVE</literal> lock is held
145-
unless explicitly noted. When multiple subcommands arelisted, the lock
146-
heldwill be the strictest one requiredfrom any subcommand.
144+
may differ for each subform. An <literal>ACCESS EXCLUSIVE</literal> lock is
145+
acquiredunless explicitly noted. When multiple subcommands aregiven, the
146+
lock acquiredwill be the strictest one requiredby any subcommand.
147147

148148
<variablelist>
149149
<varlistentry>
@@ -355,8 +355,8 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
355355
<term><literal>ADD <replaceable class="parameter">table_constraint</replaceable> [ NOT VALID ]</literal></term>
356356
<listitem>
357357
<para>
358-
This form adds a new constraint to a table using the samesyntax as
359-
<xref linkend="sql-createtable"/>, plus the option <literal>NOT
358+
This form adds a new constraint to a table using the sameconstraint
359+
syntax as<xref linkend="sql-createtable"/>, plus the option <literal>NOT
360360
VALID</literal>, which is currently only allowed for foreign key
361361
and CHECK constraints.
362362
</para>
@@ -379,9 +379,14 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
379379
</para>
380380

381381
<para>
382-
Addition of a foreign key constraint requires a
383-
<literal>SHARE ROW EXCLUSIVE</literal> lock on the referenced table,
384-
in addition to the lock on the table receiving the constraint.
382+
Although most forms of <literal>ADD
383+
<replaceable class="parameter">table_constraint</replaceable></literal>
384+
require an <literal>ACCESS EXCLUSIVE</literal> lock, <literal>ADD
385+
FOREIGN KEY</literal> requires only a <literal>SHARE ROW
386+
EXCLUSIVE</literal> lock. Note that <literal>ADD FOREIGN KEY</literal>
387+
also acquires a <literal>SHARE ROW EXCLUSIVE</literal> lock on the
388+
referenced table, in addition to the lock on the table on which the
389+
constraint is declared.
385390
</para>
386391

387392
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp