Re: FK NOT VALID can't be deferrable?

Lists: pgsql-hackers
From: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: FK NOT VALID can't be deferrable?
Date: 2011-06-15 06:56:29
Message-ID: BANLkTi=j2sujcXP0mo8yGG97kbC+L21y1A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Testing the CHECK NOT VALID patch i found $subject... is this intended?

--
Jaime Casanova         www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación


From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 08:21:45
Message-ID: BANLkTi=xV-xitHP5fEv8c0eKK+rh9iYW=w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 15 June 2011 07:56, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
> Hi,
>
> Testing the CHECK NOT VALID patch i found $subject... is this intended?
>

I just noticed that too, and was about to raise it as a bug.

If it is intended, then it's not documented.

I noticed it while browsing gram.y, and thought it looks a bit ugly
having 2 almost identical code blocks, one for the normal case and one
for NOT VALID. The second block doesn't have a
ConstraintAttributeSpec, so won't allow any deferrable options.

Aside from the ugliness of the code, we can't just add a
ConstraintAttributeSpec to the second block, because that would
enforce an order to these options.

OTOH adding NOT VALID to ConstraintAttributeSpec is a bit invasive,
since it's used in quite a few places, including CREATE TABLE, where
NOT VALID is never allowed.

Thoughts?

Regards,
Dean


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Jaime Casanova <jaime(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 15:54:25
Message-ID: 29433.1308153265@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> On 15 June 2011 07:56, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
>> Testing the CHECK NOT VALID patch i found $subject... is this intended?

> Aside from the ugliness of the code, we can't just add a
> ConstraintAttributeSpec to the second block, because that would
> enforce an order to these options.

> OTOH adding NOT VALID to ConstraintAttributeSpec is a bit invasive,
> since it's used in quite a few places, including CREATE TABLE, where
> NOT VALID is never allowed.

> Thoughts?

I think we need to do the second one, ie, add it to
ConstraintAttributeSpec and do what's necessary to filter later.
The reason we have a problem here is exactly that somebody took
shortcuts.

It'd probably be sufficient to have one or two places in
parse_utilcmds.c know which variants of Constraint actually support
NOT VALID, and throw an error for the rest.

regards, tom lane


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 19:08:58
Message-ID: BANLkTimMveWcbo_iMs3N8w27qovJs2zw5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jun 15, 2011 at 4:54 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
>> On 15 June 2011 07:56, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
>>> Testing the CHECK NOT VALID patch i found $subject... is this intended?
>
>> Aside from the ugliness of the code, we can't just add a
>> ConstraintAttributeSpec to the second block, because that would
>> enforce an order to these options.
>
>> OTOH adding NOT VALID to ConstraintAttributeSpec is a bit invasive,
>> since it's used in quite a few places, including CREATE TABLE, where
>> NOT VALID is never allowed.
>
>> Thoughts?
>
> I think we need to do the second one, ie, add it to
> ConstraintAttributeSpec and do what's necessary to filter later.
> The reason we have a problem here is exactly that somebody took
> shortcuts.

There were grammar issues in the NOT VALID patch which I sought to
resolve. Those new suggestions may fall foul of the same issues.

I raised that point and asked for input prior to commit.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 20:14:28
Message-ID: 1308168833-sup-3188@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Tom Lane's message of mié jun 15 11:54:25 -0400 2011:
> Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> > On 15 June 2011 07:56, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
> >> Testing the CHECK NOT VALID patch i found $subject... is this intended?
>
> > Aside from the ugliness of the code, we can't just add a
> > ConstraintAttributeSpec to the second block, because that would
> > enforce an order to these options.
>
> > OTOH adding NOT VALID to ConstraintAttributeSpec is a bit invasive,
> > since it's used in quite a few places, including CREATE TABLE, where
> > NOT VALID is never allowed.
>
> I think we need to do the second one, ie, add it to
> ConstraintAttributeSpec and do what's necessary to filter later.
> The reason we have a problem here is exactly that somebody took
> shortcuts.
>
> It'd probably be sufficient to have one or two places in
> parse_utilcmds.c know which variants of Constraint actually support
> NOT VALID, and throw an error for the rest.

So is somebody from 2nd Quadrant going to supply a patch to fix this?

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 20:20:59
Message-ID: BANLkTi=L74R+NSJBtLTng=Q6S7x9sBMOfA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jun 15, 2011 at 3:14 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
>
> So is somebody from 2nd Quadrant going to supply a patch to fix this?
>

well, i was going to give it a try... but in a couple of hours...

--
Jaime Casanova         www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 20:31:45
Message-ID: BANLkTim1B4nW-PDJwrts-27AUQMOpXFgGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jun 15, 2011 at 9:14 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:

> So is somebody from 2nd Quadrant going to supply a patch to fix this?

My understanding was that your patch had a bug, rather than the
existing code. If I misunderstood, please explain the bug.

In terms of "2ndQuadrant" supplying patches, you may not be aware that
we all work independently on community contributions...

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 20:59:09
Message-ID: 1308171285-sup-5007@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Simon Riggs's message of mié jun 15 16:31:45 -0400 2011:
> On Wed, Jun 15, 2011 at 9:14 PM, Alvaro Herrera
> <alvherre(at)commandprompt(dot)com> wrote:
>
> > So is somebody from 2nd Quadrant going to supply a patch to fix this?
>
> My understanding was that your patch had a bug, rather than the
> existing code. If I misunderstood, please explain the bug.

This is about FOREIGN KEY NOT VALID, which is your patch that's already
in 9.1. My patch doesn't touch foreign keys. CHECK constraints cannot
be deferrable anyway.

> In terms of "2ndQuadrant" supplying patches, you may not be aware that
> we all work independently on community contributions...

I wasn't, but that doesn't change anything -- I mean, you were from 2nd
Quadrant last time I checked. If Jaime is going to submit a patch to
fix the bug, I assume you're fine with that too?

(The other alternative is to leave the bug open until Robert or Tom fix
it, I guess)

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 21:42:33
Message-ID: 27420.1308174153@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> So is somebody from 2nd Quadrant going to supply a patch to fix this?

I'm already on it. The whole patch appears to need some review,
considering this is about the fourth major flaw we've found in it.

regards, tom lane


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 21:46:26
Message-ID: BANLkTiktqimf603Ze4Cd4-jNQcawNQJzbw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jun 15, 2011 at 9:59 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Excerpts from Simon Riggs's message of mié jun 15 16:31:45 -0400 2011:
>> On Wed, Jun 15, 2011 at 9:14 PM, Alvaro Herrera
>> <alvherre(at)commandprompt(dot)com> wrote:
>>
>> > So is somebody from 2nd Quadrant going to supply a patch to fix this?
>>
>> My understanding was that your patch had a bug, rather than the
>> existing code. If I misunderstood, please explain the bug.
>
> This is about FOREIGN KEY NOT VALID, which is your patch that's already
> in 9.1.  My patch doesn't touch foreign keys.  CHECK constraints cannot
> be deferrable anyway.

OK, thanks. My bug, my responsibility to provide a solution.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FK NOT VALID can't be deferrable?
Date: 2011-06-15 21:54:56
Message-ID: BANLkTimXs=cgSHQStKgKnTCtMZmNAaMj6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Jun 15, 2011 at 10:42 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
>> So is somebody from 2nd Quadrant going to supply a patch to fix this?
>
> I'm already on it.  The whole patch appears to need some review,
> considering this is about the fourth major flaw we've found in it.

I'll leave it with you then, but I remain happy to fix.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services