Re: AFTER triggers and constraints

From: David Greco <David_Greco(at)harte-hanks(dot)com>
To: Vick Khera <vivek(at)khera(dot)org>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: AFTER triggers and constraints
Date: 2013-06-28 13:37:45
Message-ID: 187F6C10D2931A4386EE8E58E13857F630438B04@BY2PRD0811MB415.namprd08.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From: Vick Khera [mailto:vivek(at)khera(dot)org]
Sent: Friday, June 28, 2013 9:35 AM
To: David Greco
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] AFTER triggers and constraints

On Fri, Jun 28, 2013 at 8:45 AM, David Greco <David_Greco(at)harte-hanks(dot)com<mailto:David_Greco(at)harte-hanks(dot)com>> wrote:
The last delete statement will throw a referential integrity error. In Oracle, same example, it does not as the trigger deletes the child.

Not sure your real case, but why not just make the FK on delete cascade and get rid of your trigger entirely?

Alternatively, what if you make your constratint initially deferred?

The actual use case is a bit different and complicated. When the constraint is initially deferred, it works as expected, and that is how I will work around the issue. But my point is, is this how it is SUPPOSED to work? It's not clear to me yet that is the case. I would expect the statement to include the after row triggers (but not the after statement triggers).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-06-28 14:10:12 Re: AFTER triggers and constraints
Previous Message Vick Khera 2013-06-28 13:34:55 Re: AFTER triggers and constraints