Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 26BAF9F9543 for ; Tue, 21 Aug 2007 19:49:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 10730-06 for ; Tue, 21 Aug 2007 19:49:50 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from corp.etelos.com (corp.etelos.com [216.251.101.81]) by postgresql.org (Postfix) with ESMTP id A618C9F9537 for ; Tue, 21 Aug 2007 19:49:54 -0300 (ADT) Received: from [192.168.4.109] (unknown [216.251.108.82]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by corp.etelos.com (Postfix) with ESMTP id 55589FAC9B; Tue, 21 Aug 2007 15:49:53 -0700 (PDT) Message-ID: <46CB6C0E.7070508@etelos.com> Date: Tue, 21 Aug 2007 15:49:50 -0700 From: Jon Collette User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: Scott Marlowe CC: pgsql-sql@postgresql.org Subject: Re: Make a SQL statement not run trigger References: <46CB5876.80003@etelos.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/179 X-Sequence-Number: 29117 I think this will work for what I need. I have been messing around with this using select into /select True as donothing into temporary table table_trigger_name; then run statement that I want to be ignored / The trigger would have a select upon the table_trigger_name to determine if it should run or not. I am having issues catching the exception when the table is not found. This is my test function of my trigger /Create or replace function trigger_test() returns boolean as $$ declare donothing boolean; begin donothing := False; select donothing into donothing from table_trigger_name; return boolean; end; $$ LANGUAGE plpgsql; / Which of course will error when there is no table_trigger_name made for that session. I couldn't find an exception in the exceptions list for table not found errors. Scott Marlowe wrote: > On 8/21/07, Jon Collette wrote: > >> Is it possible to run an insert,update, or delete and have it not launch >> a trigger like it normally would? >> >> For example could I set a value >> DONOTRUN = True; >> insert into contacts .... >> > > The closest thing to a session variable for pgsql is going to likely > be a temp table. you could have a temp table for each session that > stores such things and the trigger looks in the temp table to see what > to do. > > >> Or is there just a global variable I could set to disable triggers and >> then reset it? And would that be a per connection variable? >> > > Yes, but that would open you up to race conditions. If another > session wanted the trigger to fire it would not get it. Using a temp > table would allow you to get around the race condition. > > ---------------------------(end of broadcast)--------------------------- > TIP 7: You can help support the PostgreSQL project by donating at > > http://www.postgresql.org/about/donate >