Thank you for weighing in and reviewing the patch. On 2017/07/28 20:55, Etsuro Fujita wrote: > On 2017/07/26 15:29, Amit Langote wrote: >> On 2017/07/25 9:43, David G. Johnston wrote: >>> On Mon, Jul 24, 2017 at 5:19 PM, Amit Langote wrote: >>> I'm curious what the other limitations are... > > I think COPY has the same limitation as INSERT.
Yes. I updated the patch to mention that as well. >> When I first wrote that documentation line (I am assuming you're asking >> about "although these have some limitations that normal tables do not"), I >> was thinking about the fact that the core system does not enforce >> (locally) any constraints defined on foreign tables. Since we allow >> inserting data into partitions directly, it is imperative that we enforce >> the "partition constraint" along with the traditional constraints such as >> NOT NULL and CHECK constraints, which we can do for local table partitions >> but not for foreign table ones. >> >> Anyway, attached patch documents all these limitations about foreign table >> partitions more prominently. > > Typo: s/the they is/they are/ Fixed in the attached. Thanks, Amit
From 2b9c28808b725ed4551a2876a187531439f13928 Mon Sep 17 00:00:00 2001 From: amit <amitlangot...@gmail.com> Date: Mon, 3 Apr 2017 16:45:15 +0900 Subject: [PATCH] Clarify that partition constraint is not enforced on foreign tables --- doc/src/sgml/ddl.sgml | 16 +++++++++++++--- doc/src/sgml/ref/create_foreign_table.sgml | 17 +++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml index b05a9c2150..a0ab648928 100644 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@ -2988,9 +2988,11 @@ VALUES ('Albany', NULL, NULL, 'NY'); <para> Partitions can also be foreign tables (see <xref linkend="sql-createforeigntable">), - although these have some limitations that normal tables do not. For - example, data inserted into the partitioned table is not routed to - foreign table partitions. + although they have some limitations that normal tables do not. For + example, routing the data inserted (or copied) into the partitioned table + to foreign table partitions is not supported, nor are the partition + constraints enforced when the data is directly inserted (or copied) into + them. </para> <sect3 id="ddl-partitioning-declarative-example"> @@ -3297,6 +3299,14 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02 not the partitioned table. </para> </listitem> + + <listitem> + <para> + Routing tuples to partitions that are foreign tables is not supported. + So, if a tuple inserted (or copied) into the table routes to one of + the foreign partitions, an error will occur. + </para> + </listitem> </itemizedlist> </para> </sect3> diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml index 065c982082..43a6cbcfab 100644 --- a/doc/src/sgml/ref/create_foreign_table.sgml +++ b/doc/src/sgml/ref/create_foreign_table.sgml @@ -79,7 +79,9 @@ CHECK ( <replaceable class="PARAMETER">expression</replaceable> ) [ NO INHERIT ] <para> If <literal>PARTITION OF</literal> clause is specified then the table is created as a partition of <literal>parent_table</literal> with specified - bounds. + bounds. Note that routing tuples to partitions that are foreign tables + is not supported. So, if a tuple inserted (or copied) into the table + routes to one of the foreign partitions, an error will occur. </para> <para> @@ -279,16 +281,19 @@ CHECK ( <replaceable class="PARAMETER">expression</replaceable> ) [ NO INHERIT ] <title>Notes</title> <para> - Constraints on foreign tables (such as <literal>CHECK</> - or <literal>NOT NULL</> clauses) are not enforced by the - core <productname>PostgreSQL</> system, and most foreign data wrappers - do not attempt to enforce them either; that is, the constraint is + Constraints (both the user-defined constraints such as <literal>CHECK</> + or <literal>NOT NULL</> clauses and the partition constraint) are not + enforced by the core <productname>PostgreSQL</> system, and most foreign + data wrappers do not attempt to enforce them either; that is, they are simply assumed to hold true. There would be little point in such enforcement since it would only apply to rows inserted or updated via the foreign table, and not to rows modified by other means, such as directly on the remote server. Instead, a constraint attached to a foreign table should represent a constraint that is being enforced by - the remote server. + the remote server. That becomes especially important if the table is + being used in a partition hierarchy, where it is recommended to add + a constraint matching the partition constraint expression on + the remote table. </para> <para> -- 2.11.0
-- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers