Re: [HACKERS] Another oddity in handling of WCO constraints in postgres_fdw

Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>

From: Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
To: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Cc: Stephen Frost <sfrost@snowman.net>, Arthur Zakirov <a.zakirov@postgrespro.ru>, Robert Haas <robertmhaas@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2018-03-09T11:55:46Z
Lists: pgsql-hackers
Hi Ashutosh,

(2018/03/08 14:24), Ashutosh Bapat wrote:
> Etsuro said [2] that WCO constraints can not be implemented on foreign
> server and normal check constraints can be, and for that he provides
> an example in [3]. But I think that example is going the wrong
> direction.

More precisely, what I'm saying there is: for WCO constraints created by 
an auto-updatable view over a foreign table, we cannot always implement 
constraints on the remote side that match with those WCO constraints.

> For local constraints to be enforced, we use remote
> constraints. For local WCO we need to use remote WCO. That means we
> create many foreign tables pointing to same local table on the foreign
> server through many views, but it's not impossible.

Maybe I don't understand this correctly, but I guess that it would be 
the user's responsibility to not create foreign tables in such a way.

Best regards,
Etsuro Fujita


Commits

  1. Fix WITH CHECK OPTION on views referencing postgres_fdw tables.

  2. Allow insert and update tuple routing and COPY for foreign tables.

  3. When WCOs are present, disable direct foreign table modification.