From 7ba72f024223cbe1a8e1da1220b8f8efb8e8f215 Mon Sep 17 00:00:00 2001 From: amit 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 | 15 ++++++++++++--- doc/src/sgml/ref/create_foreign_table.sgml | 17 +++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml index b05a9c2150..e7a10e15d3 100644 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@ -2988,9 +2988,10 @@ VALUES ('Albany', NULL, NULL, 'NY'); Partitions can also be foreign tables (see ), - 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 into the partitioned table to foreign + table partitions is not supported, nor are the partition constraints + enforced when the data is directly inserted into them. @@ -3297,6 +3298,14 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02 not the partitioned table. + + + + Routing tuples to partitions that are foreign tables is not supported. + So, if an inserted tuple routes to one of the foreign partitions, an + error will occur. + + diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml index 065c982082..12087ec05c 100644 --- a/doc/src/sgml/ref/create_foreign_table.sgml +++ b/doc/src/sgml/ref/create_foreign_table.sgml @@ -79,7 +79,9 @@ CHECK ( expression ) [ NO INHERIT ] If PARTITION OF clause is specified then the table is created as a partition of parent_table with specified - bounds. + bounds. Note that routing tuples to partitions that are foreign tables + is not supported. So, if an inserted tuple routes to one of foreign + partitions, an error will occur. @@ -279,16 +281,19 @@ CHECK ( expression ) [ NO INHERIT ] Notes - Constraints on foreign tables (such as CHECK - or NOT NULL clauses) are not enforced by the - core 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 CHECK + or NOT NULL clauses and the partition constraint) are not + enforced by the core PostgreSQL system, and most foreign + data wrappers do not attempt to enforce them either; that is, the they is 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. -- 2.11.0