+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
+
+
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 2: you can get off all lists at once with the unregister command
+
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g7D4Sgk27162
+ for
; Tue, 13 Aug 2002 00:28:42 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 94BDB475EFD; Tue, 13 Aug 2002 00:28:37 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id C912A475EDF; Tue, 13 Aug 2002 00:28:36 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 0026B475924
+ for
; Tue, 13 Aug 2002 00:28:30 -0400 (EDT)
+Received: from sss.pgh.pa.us (unknown [192.204.191.242])
+ by postgresql.org (Postfix) with ESMTP id 5263B47582B
+ for
; Tue, 13 Aug 2002 00:28:30 -0400 (EDT)
+Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1])
+ by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g7D4SJVk022192;
+ Tue, 13 Aug 2002 00:28:19 -0400 (EDT)
+To: Gavin Sherry
+Subject: Re: [PATCHES] Fix disabled triggers with deferred constraints
+Comments: In-reply-to Gavin Sherry
+ message dated "Tue, 13 Aug 2002 14:12:15 +1000"
+Date: Tue, 13 Aug 2002 00:28:19 -0400
+From: Tom Lane
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Gavin Sherry writes:
+> ...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.
+
+Thanks for the dig. I was hoping we could get some guidance from the
+spec, but it looks like not. How about other implementations --- does
+Oracle support disabled triggers? DB2? etc?
+
+> 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;
+
+So check the state at execution, not when the triggering event occurs.
+I don't have any strong reason to object to that, but I have a gut
+feeling that it still needs to be thought about...
+
+Let's see, I guess there are several possible changes of state for a
+deferred trigger between the triggering event and the end of
+transaction:
+
+* Trigger deleted. Surely the trigger shouldn't be executed, but should
+we raise an error or just silently ignore it? (I suspect right now we
+crash :-()
+
+* Trigger created. In some ideal world we might think that such a
+trigger should be fired, but in reality that ain't gonna happen; we're
+not going to record every possible event on the speculation that some
+trigger for it might be created later in the transaction.
+
+* Trigger disabled. Your proposal is to not fire it. Okay, comports
+with the deleted case, if we make that behavior be silently-ignore.
+
+* Trigger enabled. Your proposal is to fire it. Seems not to comport
+with the creation case --- does that bother anyone?
+
+* Trigger changed from not-deferred to deferred. If we already fired it
+for the event, we surely shouldn't fire it again. I believe the code
+gets this case right.
+
+* Trigger changed from deferred to not-deferred. As Neil was pointing
+out recently, this really should cause the trigger to be fired for the
+pending event immediately, but we don't get that right at the moment.
+(I suppose a stricter interpretation would be to raise an error because
+we can't do anything that really comports with the intended behavior
+of either case.)
+
+How do these various cases relate? Can we come up with a unified
+rationale?
+
+ regards, tom lane
+
+---------------------------(end of broadcast)---------------------------
+TIP 6: Have you searched our list archives?
+
+http://archives.postgresql.org
+
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g7D4usk27855
+ for
; Tue, 13 Aug 2002 00:56:54 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id F09AE475EFD; Tue, 13 Aug 2002 00:56:49 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 94E4B475DC0; Tue, 13 Aug 2002 00:56:47 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 4EB5D475751
+ for
; Tue, 13 Aug 2002 00:56:42 -0400 (EDT)
+Received: from joeconway.com (unknown [63.210.180.150])
+ by postgresql.org (Postfix) with ESMTP id A5F35475531
+ for
; Tue, 13 Aug 2002 00:56:41 -0400 (EDT)
+Received: from [192.168.5.2] (account jconway HELO joeconway.com)
+ by joeconway.com (CommuniGate Pro SMTP 3.5.9)
+ with ESMTP-TLS id 1246425; Mon, 12 Aug 2002 21:46:29 -0700
+Date: Mon, 12 Aug 2002 21:56:01 -0700
+From: Joe Conway
+User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0) Gecko/20020530
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Tom Lane
+cc: Gavin Sherry ,
+Subject: Re: [PATCHES] Fix disabled triggers with deferred constraints
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Tom Lane wrote:
+> Gavin Sherry writes:
+>>...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.
+>
+> Thanks for the dig. I was hoping we could get some guidance from the
+> spec, but it looks like not. How about other implementations --- does
+> Oracle support disabled triggers? DB2? etc?
+
+Oracle does for sure. With a complex app (i.e. Oracle Applications)
+being able to disable triggers from time-to-time is *indispensable*. Not
+sure about DB2. My knowledge of MSSQL is getting dated, but as of MSSQL7
+I don't *think* you can disable a trigger.
+
+Joe
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 6: Have you searched our list archives?
+
+http://archives.postgresql.org
+
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g7D5afk29468
+ for
; Tue, 13 Aug 2002 01:36:41 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id C40B3476088; Tue, 13 Aug 2002 01:36:42 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id AAB02476037; Tue, 13 Aug 2002 01:36:41 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 15911475751
+ for
; Tue, 13 Aug 2002 01:36:37 -0400 (EDT)
+Received: from linuxworld.com.au (www.linuxworld.com.au [203.34.46.50])
+ by postgresql.org (Postfix) with ESMTP id BC813475531
+ for
; Tue, 13 Aug 2002 01:36:35 -0400 (EDT)
+Received: from localhost (swm@localhost)
+ by linuxworld.com.au (8.11.4/8.11.4) with ESMTP id g7D5coN26796;
+ Tue, 13 Aug 2002 15:38:50 +1000
+Date: Tue, 13 Aug 2002 15:38:50 +1000 (EST)
+From: Gavin Sherry
+To: Tom Lane
+Subject: Re: [PATCHES] Fix disabled triggers with deferred constraints
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+X-Virus-Scanned: by AMaViS new-20020517
+Status: ORr
+
+On Tue, 13 Aug 2002, Tom Lane wrote:
+
+> Gavin Sherry writes:
+> > ...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.
+>
+> Thanks for the dig. I was hoping we could get some guidance from the
+> spec, but it looks like not. How about other implementations --- does
+> Oracle support disabled triggers? DB2? etc?
+
+Oracle 8 (and I presume 9) allows you to disable/enable triggers through
+alter table and alter trigger. My 8.1.7 documentation is silent on the
+cases you mention below and I do not have an oracle installation handy to
+test. Anyone?
+
+>
+> > 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;
+>
+> So check the state at execution, not when the triggering event occurs.
+> I don't have any strong reason to object to that, but I have a gut
+> feeling that it still needs to be thought about...
+>
+> Let's see, I guess there are several possible changes of state for a
+> deferred trigger between the triggering event and the end of
+> transaction:
+>
+> * Trigger deleted. Surely the trigger shouldn't be executed, but should
+> we raise an error or just silently ignore it? (I suspect right now we
+> crash :-()
+>
+> * Trigger created. In some ideal world we might think that such a
+> trigger should be fired, but in reality that ain't gonna happen; we're
+> not going to record every possible event on the speculation that some
+> trigger for it might be created later in the transaction.
+
+It doesn't need to be an ideal world. We're only talking about deferred
+triggers after all. Why couldn't CreateTrgger() just have a look through
+deftrig_events, check for its relid and if its in there, call
+deferredTriggerAddEvent().
+
+> * Trigger disabled. Your proposal is to not fire it. Okay, comports
+> with the deleted case, if we make that behavior be silently-ignore.
+>
+> * Trigger enabled. Your proposal is to fire it. Seems not to comport
+> with the creation case --- does that bother anyone?
+>
+> * Trigger changed from not-deferred to deferred. If we already fired it
+> for the event, we surely shouldn't fire it again. I believe the code
+> gets this case right.
+
+Agreed.
+
+> * Trigger changed from deferred to not-deferred. As Neil was pointing
+> out recently, this really should cause the trigger to be fired for the
+> pending event immediately, but we don't get that right at the moment.
+> (I suppose a stricter interpretation would be to raise an error because
+> we can't do anything that really comports with the intended behavior
+> of either case.)
+
+I think this should generate an error as it doesn't sit well with the
+spec IMHO.
+
+Gavin
+
+
+---------------------------(end of broadcast)---------------------------
+