Skip to content

Commit fc84c05

Browse files
committed
Fix documentation on partitioning vs. foreign tables
1. The PARTITION OF clause of CREATE FOREIGN TABLE was not explained in the CREATE FOREIGN TABLE reference page. Add it. (Postgres 10 onwards) 2. The limitation that tuple routing cannot target partitions that are foreign tables was not documented clearly enough. Improve wording. (Postgres 10 onwards) 3. The UPDATE tuple re-routing concurrency behavior was explained in the DDL chapter, which doesn't seem the right place. Move it to the UPDATE reference page instead. (Postgres 11 onwards). Authors: Amit Langote, David Rowley. Reviewed-by: Etsuro Fujita. Reported-by: Derek Hans Discussion: https://postgr.es/m/CAGrP7a3Xc1Qy_B2WJcgAD8uQTS_NDcJn06O5mtS_Ne1nYhBsyw@mail.gmail.com
1 parent cbccac3 commit fc84c05

File tree

3 files changed

+42
-28
lines changed

3 files changed

+42
-28
lines changed

doc/src/sgml/ddl.sgml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,27 +3856,6 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
38563856
</para>
38573857
</listitem>
38583858

3859-
<listitem>
3860-
<para>
3861-
When an <command>UPDATE</command> causes a row to move from one
3862-
partition to another, there is a chance that another concurrent
3863-
<command>UPDATE</command> or <command>DELETE</command> will get a
3864-
serialization failure error. Suppose session 1 is performing an
3865-
<command>UPDATE</command> on a partition key, and meanwhile a concurrent
3866-
session 2 for which this row is visible performs an
3867-
<command>UPDATE</command> or <command>DELETE</command> operation on this
3868-
row. In such case, session 2's <command>UPDATE</command> or
3869-
<command>DELETE</command>, will detect the row movement and raise a
3870-
serialization failure error (which always returns with an SQLSTATE code
3871-
'40001'). Applications may wish to retry the transaction if this
3872-
occurs. In the usual case where the table is not partitioned, or where
3873-
there is no row movement, session 2 would have identified the newly
3874-
updated row and carried out the
3875-
<command>UPDATE</command>/<command>DELETE</command> on this new row
3876-
version.
3877-
</para>
3878-
</listitem>
3879-
38803859
<listitem>
38813860
<para>
38823861
<literal>BEFORE ROW</literal> triggers, if necessary, must be defined

doc/src/sgml/ref/create_foreign_table.sgml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ]
160160
</listitem>
161161
</varlistentry>
162162

163+
<varlistentry>
164+
<term><literal>PARTITION OF <replaceable>parent_table</replaceable> FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable></literal></term>
165+
<listitem>
166+
<para>
167+
This form can be used to create the foreign table as partition of
168+
the given parent table with specified partition bound values.
169+
See the similar form of
170+
<xref linkend="sql-createtable"/> for more details.
171+
</para>
172+
</listitem>
173+
</varlistentry>
174+
163175
<varlistentry>
164176
<term><literal>CONSTRAINT <replaceable class="parameter">constraint_name</replaceable></literal></term>
165177
<listitem>
@@ -308,6 +320,12 @@ CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ]
308320
responsibility to ensure that the constraint definition matches
309321
reality.
310322
</para>
323+
324+
<para>
325+
While rows can be moved from local partitions to a foreign-table partition
326+
(provided the foreign data wrapper supports tuple routing), they cannot be
327+
moved from a foreign-table partition to another partition.
328+
</para>
311329
</refsect1>
312330

313331
<refsect1 id="sql-createforeigntable-examples">

doc/src/sgml/ref/update.sgml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,30 @@ UPDATE <replaceable class="parameter">count</replaceable>
287287
row satisfies its partition constraint, then the row is moved to that
288288
partition. If there is no such partition, an error will occur. Behind the
289289
scenes, the row movement is actually a <command>DELETE</command> and
290-
<command>INSERT</command> operation. However, there is a possibility that a
291-
concurrent <command>UPDATE</command> or <command>DELETE</command> on the
292-
same row may miss this row. For details see the section
293-
<xref linkend="ddl-partitioning-declarative-limitations"/>.
294-
Currently, rows cannot be moved from a partition that is a
295-
foreign table to some other partition, but they can be moved into a foreign
296-
table if the foreign data wrapper supports it.
290+
<command>INSERT</command> operation.
291+
</para>
292+
293+
<para>
294+
There is a possibility that a concurrent <command>UPDATE</command> or
295+
<command>DELETE</command> on the row being moved will get a serialization
296+
failure error. Suppose session 1 is performing an <command>UPDATE</command>
297+
on a partition key, and meanwhile a concurrent session 2 for which this
298+
row is visible performs an <command>UPDATE</command> or
299+
<command>DELETE</command> operation on this row. In such case,
300+
session 2's <command>UPDATE</command> or <command>DELETE</command> will
301+
detect the row movement and raise a serialization failure error (which
302+
always returns with an SQLSTATE code '40001'). Applications may wish to
303+
retry the transaction if this occurs. In the usual case where the table
304+
is not partitioned, or where there is no row movement, session 2 would
305+
have identified the newly updated row and carried out the
306+
<command>UPDATE</command>/<command>DELETE</command> on this new row
307+
version.
308+
</para>
309+
310+
<para>
311+
Note that while rows can be moved from local partitions to a foreign-table
312+
partition (provided the foreign data wrapper supports tuple routing), they
313+
cannot be moved from a foreign-table partition to another partition.
297314
</para>
298315
</refsect1>
299316

0 commit comments

Comments
 (0)