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

Commitf333d35

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 parent401418c commitf333d35

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
@@ -142,9 +142,9 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
142142
<para>
143143
<command>ALTER TABLE</command> changes the definition of an existing table.
144144
There are several subforms described below. Note that the lock level required
145-
may differ for each subform. An <literal>ACCESS EXCLUSIVE</literal> lock is held
146-
unless explicitly noted. When multiple subcommands arelisted, the lock
147-
heldwill be the strictest one requiredfrom any subcommand.
145+
may differ for each subform. An <literal>ACCESS EXCLUSIVE</literal> lock is
146+
acquiredunless explicitly noted. When multiple subcommands aregiven, the
147+
lock acquiredwill be the strictest one requiredby any subcommand.
148148

149149
<variablelist>
150150
<varlistentry>
@@ -387,8 +387,8 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
387387
<term><literal>ADD <replaceable class="parameter">table_constraint</replaceable> [ NOT VALID ]</literal></term>
388388
<listitem>
389389
<para>
390-
This form adds a new constraint to a table using the samesyntax as
391-
<xref linkend="sql-createtable"/>, plus the option <literal>NOT
390+
This form adds a new constraint to a table using the sameconstraint
391+
syntax as<xref linkend="sql-createtable"/>, plus the option <literal>NOT
392392
VALID</literal>, which is currently only allowed for foreign key
393393
and CHECK constraints.
394394
</para>
@@ -411,9 +411,14 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
411411
</para>
412412

413413
<para>
414-
Addition of a foreign key constraint requires a
415-
<literal>SHARE ROW EXCLUSIVE</literal> lock on the referenced table,
416-
in addition to the lock on the table receiving the constraint.
414+
Although most forms of <literal>ADD
415+
<replaceable class="parameter">table_constraint</replaceable></literal>
416+
require an <literal>ACCESS EXCLUSIVE</literal> lock, <literal>ADD
417+
FOREIGN KEY</literal> requires only a <literal>SHARE ROW
418+
EXCLUSIVE</literal> lock. Note that <literal>ADD FOREIGN KEY</literal>
419+
also acquires a <literal>SHARE ROW EXCLUSIVE</literal> lock on the
420+
referenced table, in addition to the lock on the table on which the
421+
constraint is declared.
417422
</para>
418423

419424
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp