agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: gmb <gmbouwer@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Disable Trigger for session only
Date: Tue, 30 Jun 2015 01:31:37 -0700 (MST)
Message-ID: <1435653097868-5855854.post@n5.nabble.com> (raw)
In-Reply-To: <88967b6b1d22d1cbdace2f0351b4ec6a@biglumber.com>
References: <1435563798887-5855658.post@n5.nabble.com>
	<88967b6b1d22d1cbdace2f0351b4ec6a@biglumber.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

Greg Sabino Mullane wrote
> Presume you meant ENABLE here.

Yup, sorry.



Greg Sabino Mullane wrote
> Thus, you can teach the trigger you want to get disabled 
> to short-circuit if srr is set to local. Inside plpgsql it would look
> something 
> like this:
> 
> ...
> DECLARE
>   myst TEXT;
> BEGIN
>   SELECT INTO myst setting FROM pg_settings WHERE name =
> 'session_replication_role';
>   IF myst = 'local' THEN
>     RETURN;
>   END IF;
> 
> ...normal trigger code here...
> END;
> ...
> 
> Then, just issue a SET session_replication_role = 'local', and the trigger
> will 
> not do anything for that session only:

Thanks Greg, again you assisted with a neat trick.
I've definitely found that making use of session_replication_role instead is
much more efficient 
and have been using it in similar cases. 
Issue here was the one where multiple triggers exist on the table which can
by resolved using your suggestion.



--
View this message in context: http://postgresql.nabble.com/Disable-Trigger-for-session-only-tp5855658p5855854.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (8+ messages)

Message-ID: <1435653097868-5855854.post@n5.nabble.com>
Permalink:  ../1435653097868-5855854.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1435653097868-5855854.post@n5.nabble.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gmbouwer@gmail.com
  Subject: Re: Disable Trigger for session only
  In-Reply-To: <1435653097868-5855854.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox