Re: NOT Null constraint on foreign table not working

From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Subject: Re: NOT Null constraint on foreign table not working
Date: 2014-01-21 05:06:31
Message-ID: CAGPqQf2adMAj+kxjyYeG7w7E2fd5-M74a9=1d9PHnwD5ipnrOQ@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.
>
> We might change this in response to a well-reasoned argument, but it won't
> happen just because somebody lobs a quick-and-dirty patch over the fence.
>
> If we were going to enforce them locally, I'd opine it should be the FDW's
> task to do it, anyway. It might have more knowledge about the best way
> to do it than nodeModifyTable.c can, and if not it could still call
> ExecConstraints for itself.
>

Submitted patch was never intended to get checked in without the proper
discussion
and decision about what behaviour should be for foreign table constraint.
Sorry if I
passed wrong message but was never intended.

I found constraints on foreign table is very useful for the application
when the multiple
user accessing same remote table using fdw and both user want to enforce
different
constraint on particular table or different user want to enforce different
DEFAULT
expression for the same table column.

I agree with you that if we want to enforce constraint locally then it
should be
FDW's task to do it rather then nodeModifyTable.c.

Regards
Rushabh Lathia

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Harold Giménez 2014-01-21 05:22:15 proposal: hide application_name from other users
Previous Message Laurence Rowe 2014-01-21 04:55:44 Re: [PATCH] Implement json_array_elements_text