Skip to content

Commit 9419987

Browse files
committed
Doc: be clearer that foreign-table partitions need user-added constraints.
A very well-informed user might deduce this from what we said already, but I'd bet against it. Lay it out explicitly. While here, rewrite the comment about tuple routing to be more intelligible to an average SQL user. Per bug #17395 from Alexander Lakhin. Back-patch to v11. (The text in this area is different in v10 and I'm not sufficiently excited about this point to adapt the patch.) Discussion: https://postgr.es/m/17395-8c326292078d1a57@postgresql.org
1 parent 46bf1f2 commit 9419987

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

doc/src/sgml/ddl.sgml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,9 +3123,12 @@ VALUES ('Albany', NULL, NULL, 'NY');
31233123
</para>
31243124

31253125
<para>
3126-
Partitions can also be foreign tables, although they have some limitations
3127-
that normal tables do not; see <xref linkend="sql-createforeigntable"/> for
3128-
more information.
3126+
Partitions can also be <link linkend="ddl-foreign-data">foreign
3127+
tables</link>, although considerable care is needed because it is then
3128+
the user's responsibility that the contents of the foreign table
3129+
satisfy the partitioning rule. There are some other restrictions as
3130+
well. See <xref linkend="sql-createforeigntable"/> for more
3131+
information.
31293132
</para>
31303133

31313134
<sect3 id="ddl-partitioning-declarative-example">

doc/src/sgml/ref/create_foreign_table.sgml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,31 @@ CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ]
323323
constraints on foreign tables, it does assume that they are correct
324324
for purposes of query optimization. If there are rows visible in the
325325
foreign table that do not satisfy a declared constraint, queries on
326-
the table might produce incorrect answers. It is the user's
326+
the table might produce errors or incorrect answers. It is the user's
327327
responsibility to ensure that the constraint definition matches
328328
reality.
329329
</para>
330330

331+
<caution>
332+
<para>
333+
When a foreign table is used as a partition of a partitioned table,
334+
there is an implicit constraint that its contents must satisfy the
335+
partitioning rule. Again, it is the user's responsibility to ensure
336+
that that is true, which is best done by installing a matching
337+
constraint on the remote server.
338+
</para>
339+
</caution>
340+
331341
<para>
332-
While rows can be moved from local partitions to a foreign-table partition
333-
(provided the foreign data wrapper supports tuple routing), they cannot be
334-
moved from a foreign-table partition to another partition.
342+
Within a partitioned table containing foreign-table partitions,
343+
an <command>UPDATE</command> that changes the partition key value can
344+
cause a row to be moved from a local partition to a foreign-table
345+
partition, provided the foreign data wrapper supports tuple routing.
346+
However it is not currently possible to move a row from a
347+
foreign-table partition to another partition.
348+
An <command>UPDATE</command> that would require doing that will fail
349+
due to the partitioning constraint, assuming that that is properly
350+
enforced by the remote server.
335351
</para>
336352
</refsect1>
337353

0 commit comments

Comments
 (0)