Skip site navigation (1) Skip section navigation (2)

Re: Fixing handling of constraint triggers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)googlemail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fixing handling of constraint triggers
Date: 2010-01-18 15:14:29
Message-ID: 5693.1263827669@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Dean Rasheed <dean(dot)a(dot)rasheed(at)googlemail(dot)com> writes:
> Agreed. That's much neater. However, it does introduce a change in
> behaviour - if you have 2 constraints with the same name in different
> schemas, one deferrable, and one not, and the non-deferrable one is
> first on the search path, then you'll get an error if you try to defer
> the other one, referring to it with an unqualified name. This used to
> work, when it was searching for the trigger first.

> So perhaps the code should continue searching after finding a
> non-deferrable constraint, remembering the fact that it found one, and
> only report the error at the end if it didn't also find a deferrable
> one.

I went around on that a few times before committing.  It's not really
true that it used to work, at least not for cases where the
nondeferrable constraint was also an FK constraint; that threw an error
just as now.  What we've done is opened up the search so that it will
find nondeferrable index constraints, which is more or less the whole
point of Hubert's request.

The part that I actually think is weird is that the search stops after
the first schema in which it finds any matches.  If we removed that then
we could just document the behavior as "sets the constraint mode for all
matching constraint names", full stop.  Which definitely seems easier
to understand than what we have now.  (The SQL spec is no big help here
btw, it just says "if a <constraint name> is specified, then it shall
identify a deferrable constraint".  No clarity about what "identify"
means.)

The other point you bring up is whether to silently skip matching
constraints that aren't deferrable, rather than throwing error.
I'm not real excited about that --- it seems likely to mask problems,
and to the extent that you want to put faith in the wording of the SQL
spec here, it seems clear that an error is what they want.

These are certainly easy enough changes from a code standpoint.
The question is what behavior makes the most sense.  Comments anyone?

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Dimitri FontaineDate: 2010-01-18 15:19:36
Subject: Re: mailing list archiver chewing patches
Previous:From: Magnus HaganderDate: 2010-01-18 14:55:00
Subject: Re: mailing list archiver chewing patches

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group