Re: Another oddity in handling of WCO constraints in postgres_fdw

From: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Another oddity in handling of WCO constraints in postgres_fdw
Date: 2017-10-04 10:15:26
Message-ID: a3955a1d-ad07-5b0a-7618-b6ef5ff0e1c5@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017/10/03 18:16, Ashutosh Bapat wrote:
> Enforcing WCO constraints imposed by the local server on the row/DML
> being passed to the foreign server is fine, but trying to impose them
> on the row being inserted/updated at the foreign server looks odd. May
> be we should just leave this case as it is. I am comparing this case
> with the way we handle constraints on a foreign table.

Hmm, I think that would be okay in the case where WCO constraints match
constraints on the foreign table, but I'm not sure that would be okay
even in the case where WCO constraints don't match? Consider:

create table bt (a int check (a % 2 = 0));
create foreign table ft (a int check (a % 2 = 0)) server loopback
options (table_name 'bt');
create view rw_view_2 as select * from ft where a % 2 = 0 with check option;

In that case the WCO constraint matches the constraint on the foreign
table, so there would be no need to ensure the WCO constraint locally
(to make the explanation simple, we assume here that we don't have
triggers on the remote end). BUT: for another auto-updatable view
defined using the same foreign table like this:

create view rw_view_4 as select * from ft where a % 4 = 0 with check option;

how is the WCO constraint (ie, a % 4 = 0) ensured remotely, which is
different from the constraint on the foreign table (ie, a % 2 = 0)?
Maybe I'm missing something, though.

Best regards,
Etsuro Fujita

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2017-10-04 10:40:12 Re: Another oddity in handling of WCO constraints in postgres_fdw
Previous Message Michael Meskes 2017-10-04 09:57:58 Re: datetime.h defines like PM conflict with external libraries