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

Commit61a9b81

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 parent8f11115 commit61a9b81

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
9999
<para>
100100
<command>ALTER TABLE</command> changes the definition of an existing table.
101101
There are several subforms described below. Note that the lock level required
102-
may differ for each subform. An <literal>ACCESS EXCLUSIVE</literal> lock is held
103-
unless explicitly noted. When multiple subcommands arelisted, the lock
104-
heldwill be the strictest one requiredfrom any subcommand.
102+
may differ for each subform. An <literal>ACCESS EXCLUSIVE</literal> lock is
103+
acquiredunless explicitly noted. When multiple subcommands aregiven, the
104+
lock acquiredwill be the strictest one requiredby any subcommand.
105105

106106
<variablelist>
107107
<varlistentry>
@@ -313,8 +313,8 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
313313
<term><literal>ADD <replaceable class="PARAMETER">table_constraint</replaceable> [ NOT VALID ]</literal></term>
314314
<listitem>
315315
<para>
316-
This form adds a new constraint to a table using the samesyntax as
317-
<xref linkend="SQL-CREATETABLE">, plus the option <literal>NOT
316+
This form adds a new constraint to a table using the sameconstraint
317+
syntax as<xref linkend="sql-createtable">, plus the option <literal>NOT
318318
VALID</literal>, which is currently only allowed for foreign key
319319
and CHECK constraints.
320320
</para>
@@ -335,6 +335,17 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
335335
endterm="sql-altertable-notes-title"> below for more information
336336
about using the <literal>NOT VALID</literal> option.
337337
</para>
338+
339+
<para>
340+
Although most forms of <literal>ADD
341+
<replaceable class="parameter">table_constraint</replaceable></literal>
342+
require an <literal>ACCESS EXCLUSIVE</literal> lock, <literal>ADD
343+
FOREIGN KEY</literal> requires only a <literal>SHARE ROW
344+
EXCLUSIVE</literal> lock. Note that <literal>ADD FOREIGN KEY</literal>
345+
also acquires a <literal>SHARE ROW EXCLUSIVE</literal> lock on the
346+
referenced table, in addition to the lock on the table on which the
347+
constraint is declared.
348+
</para>
338349
</listitem>
339350
</varlistentry>
340351

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp