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

Commit5a8a9be

Browse files
committed
Doc: Clarify lock levels taken during ATTACH PARTITION
It wasn't all that clear which lock levels, if any, would be held on theDEFAULT partition during an ATTACH PARTITION operation.Also, clarify which locks will be taken if the DEFAULT partition or thetable being attached are themselves partitioned tables.Here I'm only backpatching to v12 as before then we obtained an ACCESSEXCLUSIVE lock on the partitioned table. It seems much less relevant tomention which locks are taken on other tables when the partitioned tableitself is locked with an ACCESS EXCLUSIVE lock.Author: Matthias van de Meent, David RowleyDiscussion:https://postgr.es/m/CAEze2WiTB6iwrV8W_J=fnrnZ7fowW3qu-8iQ8zCHP3FiQ6+o-A@mail.gmail.comBackpatch-through: 12
1 parentad3b40e commit5a8a9be

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

‎doc/src/sgml/ddl.sgml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,6 +3970,11 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
39703970
</programlisting>
39713971
</para>
39723972

3973+
<para>
3974+
The <command>ATTACH PARTITION</command> command requires taking a
3975+
<literal>SHARE UPDATE EXCLUSIVE</literal> lock on the partitioned table.
3976+
</para>
3977+
39733978
<para>
39743979
Before running the <command>ATTACH PARTITION</command> command, it is
39753980
recommended to create a <literal>CHECK</literal> constraint on the table to
@@ -3978,10 +3983,27 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
39783983
which is otherwise needed to validate the implicit
39793984
partition constraint. Without the <literal>CHECK</literal> constraint,
39803985
the table will be scanned to validate the partition constraint while
3981-
holding both an <literal>ACCESS EXCLUSIVE</literal> lock on that partition
3982-
and a <literal>SHARE UPDATE EXCLUSIVE</literal> lock on the parent table.
3986+
holding an <literal>ACCESS EXCLUSIVE</literal> lock on that partition.
39833987
It is recommended to drop the now-redundant <literal>CHECK</literal>
3984-
constraint after <command>ATTACH PARTITION</command> is finished.
3988+
constraint after the <command>ATTACH PARTITION</command> is complete. If
3989+
the table being attached is itself a partitioned table then each of its
3990+
sub-partitions will be recursively locked and scanned until either a
3991+
suitable <literal>CHECK</literal> constraint is encountered or the leaf
3992+
partitions are reached.
3993+
</para>
3994+
3995+
<para>
3996+
Similarly, if the partitioned table has a <literal>DEFAULT</literal>
3997+
partition, it is recommended to create a <literal>CHECK</literal>
3998+
constraint which excludes the to-be-attached partition's constraint. If
3999+
this is not done then the <literal>DEFAULT</literal> partition will be
4000+
scanned to verify that it contains no records which should be located in
4001+
the partition being attached. This operation will be performed whilst
4002+
holding an <literal>ACCESS EXCLUSIVE</literal> lock on the <literal>
4003+
DEFAULT</literal> partition. If the <literal>DEFAULT</literal> partition
4004+
is itself a partitioned table then each of its partitions will be
4005+
recursively checked in the same way as the table being attached, as
4006+
mentioned above.
39854007
</para>
39864008

39874009
<para>

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,17 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
965965
<para>
966966
Attaching a partition acquires a
967967
<literal>SHARE UPDATE EXCLUSIVE</literal> lock on the parent table,
968-
in addition to <literal>ACCESS EXCLUSIVE</literal> locks on the table
969-
to be attached and on the default partition (if any).
968+
in addition to the <literal>ACCESS EXCLUSIVE</literal> locks on the table
969+
being attached and on the default partition (if any).
970+
</para>
971+
972+
<para>
973+
Further locks must also be held on all sub-partitions if the table being
974+
attached is itself a partitioned table. Likewise if the default
975+
partition is itself a partitioned table. The locking of the
976+
sub-partitions can be avoided by adding a <literal>CHECK</literal>
977+
constraint as described in
978+
<xref linkend="ddl-partitioning-declarative-maintenance"/>.
970979
</para>
971980
</listitem>
972981
</varlistentry>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp