Re: NOT Null constraint on foreign table not working

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>
Subject: Re: NOT Null constraint on foreign table not working
Date: 2014-01-21 03:41:26
Message-ID: CAA4eK1KaQ7wu4FL_TAu2L5K-mvaweeRVc-uOUUfnO2n491zYiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 20, 2014 at 8:52 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)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
----
10
20
(2 rows)

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2014-01-21 03:58:24 Re: WIP patch (v2) for updatable security barrier views
Previous Message Andrew Dunstan 2014-01-21 03:34:40 Re: [PATCH] Implement json_array_elements_text