Re: NOT Null constraint on foreign table not working - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: NOT Null constraint on foreign table not working
Date
Msg-id CAA4eK1KaQ7wu4FL_TAu2L5K-mvaweeRVc-uOUUfnO2n491zYiQ@mail.gmail.com
Whole thread Raw
In response to Re: NOT Null constraint on foreign table not working  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: NOT Null constraint on foreign table not working
List pgsql-hackers
On Mon, Jan 20, 2014 at 8:52 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Rushabh Lathia <rushabh.lathia@gmail.com> writes:
>> As per the PG documentation it says that foreign table do support the
>> NOT NULL, NULL and DEFAULT.
>
> There has been a great deal of debate about what constraints on foreign
> tables ought to mean.  Right now, at least for postgres_fdw, they're just
> taken as documentation of constraints that are supposed to exist on the
> far side.  It's not clear what's the point of trying to enforce them
> against insertions done locally if the remote table lacks them --- any
> table update done on the far side could still violate the constraint.

What is the reason for keeping DEFAULT behaviour different than
constraints. Right now the behaviour for DEFAULT is if it is
defined on foreign table, then it will use that even if original table has
different or no default value?

Create Database foo;
\c foo
create table tbl(c1 int Default 20);

\c postgres
create foreign table tbl(c1 int Default 10) server pgdbfdw; --here
pgdbfdw is server for postgres_fdw
insert into tbl values(Default);
select * from tbl;c1
----10
(1 row)

\c foo
insert into tbl values(Default);
select * from tbl;c1
----1020
(2 rows)


With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: [PATCH] Implement json_array_elements_text
Next
From: Craig Ringer
Date:
Subject: Re: WIP patch (v2) for updatable security barrier views