Re: Fix disabled triggers with deferred constraints

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Fix disabled triggers with deferred constraints
Date: 2002-08-13 04:12:15
Message-ID: Pine.LNX.4.21.0208131342460.22771-100000@linuxworld.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On 7 Aug 2002, Neil Conway wrote:

> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> > Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> > > Elliot Lee <sopwith(at)redhat(dot)com> writes:
> > > I remember looking at this issue and not doing anything because I
> > > couldn't decide whether the test for enabled status should occur when
> > > the trigger is queued or when it is executed --- or, perhaps, both?
> > > Is there anything in the standard about it?
>
> [...]
>
> > I think we're still waiting for someone to figure out what the behavior
> > should be per spec.
>
> I took a brief look at SQL99, but I couldn't find anything regarding
> this issue (AFAICS it doesn't mention "disabled triggers" at all). But
> given my prior track record for divining information from the
> standards, perhaps someone should double-check :-)

I had a pretty hard look around SQL99. It does not appear to say anything
explicit about disabling triggers. This should be clear from page 90: 4.35
Triggers. This specifies the trigger descriptor. Those familiar with SQL99
know that it just about mandates that all state information about any
object in the system is recorded in its descriptor. The fact that
enabled/disabled state information is not recorded in the trigger
descriptor suggests that it is only ever enabled.

More over there is no case when a trigger is not executed, according to
10.12 'Execution of triggers'.

I dug deeper, wondering if it may be implicitly disabled given the
disabling of its 'dependencies', shall we call them. Namely: the base
table or the procedure used in the trigger action. Tables cannot be
disabled or made in active. As for the procedure, <SQL procedure
statement>, this expands to SQL which, itself, cannot be 'disabled'.

The spec is a large one and I didn't look at all references to triggers --
since there are hundreds -- but I don't believe that there is any
precedent for an implementation of DISABLE TRIGGER.

FWIW, i think that in the case of deferred triggers they should all be
added to the queue and whether they are executed or not should be
evaluated inside DeferredTriggerExecute() with:

if(LocTriggerData.tg_trigger->tgenabled == false)
return;

Gavin

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2002-08-13 04:28:19 Re: Fix disabled triggers with deferred constraints
Previous Message Tom Lane 2002-08-13 03:35:17 Re: connect_timeout parameter in libpq