Thread: Re: Foreign tables don't enforce the partition constraint

Re: Foreign tables don't enforce the partition constraint

From
Robert Haas
Date:
On Fri, Mar 31, 2017 at 5:11 AM, Ashutosh Bapat
<ashutosh.bapat@enterprisedb.com> wrote:
> Per https://www.postgresql.org/docs/devel/static/sql-createforeigntable.html,
> constraints on the foreign table should represent a constraint that is
> being enforced by the remote server.

Right.  This is user error.  Having the *local* server try to enforce
the constraint would slow down the system without guaranteeing
anything, because somebody could modify the table on the remote server
directly.

> Similarly, a partition constraint
> should also be enforced at the foreign server. Probably we should
> update documentation of create foreign table to mention this.

That is a good idea.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: Foreign tables don't enforce the partition constraint

From
Ashutosh Bapat
Date:




> Similarly, a partition constraint
> should also be enforced at the foreign server. Probably we should
> update documentation of create foreign table to mention this.

That is a good idea.

Here's the patch. I am not able to build documents on my laptop because of recent changes in d63762452434a3a046e8c7d130d5a77c594176e4. So, I was not able to check whether the patch builds or not. But I am hoping it builds well.

--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company
Attachment

Re: Foreign tables don't enforce the partition constraint

From
Amit Langote
Date:
Hi Ashutosh,

On 2017/04/03 15:49, Ashutosh Bapat wrote:
>>> Similarly, a partition constraint
>>> should also be enforced at the foreign server. Probably we should
>>> update documentation of create foreign table to mention this.
>>
>> That is a good idea.
>>
>> Here's the patch.

Thanks for creating the patch.

+    Constraints and partition bounds on foreign tables (such as

We use "partition constraint" instead of "partition bounds" to mean the
implicit constraint of a partition (there are a few instances of that in
the documentation).  So, perhaps this could be written as: 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 once we've mentioned that a constraint means one of these things, we
need not repeat "partition bounds/constraints" in the subsequent
paragraphs.  If you agree, attached is the updated patch.

> I am not able to build documents on my laptop because of
> recent changes in d63762452434a3a046e8c7d130d5a77c594176e4. So, I was not
> able to check whether the patch builds or not. But I am hoping it builds
> well.

By the way, docs do build fine despite the error you see.

Thanks,
Amit

Attachment