Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z9qzj-0001yp-7t for pgsql-sql@arkaria.postgresql.org; Tue, 30 Jun 2015 08:34:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Z9qzh-0004Hh-Gm for pgsql-sql@arkaria.postgresql.org; Tue, 30 Jun 2015 08:34:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z9qxC-0001ZN-Qs for pgsql-sql@postgresql.org; Tue, 30 Jun 2015 08:31:42 +0000 Received: from mbob.nabble.com ([162.253.133.15]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Z9qx9-0006Xr-Gx for pgsql-sql@postgresql.org; Tue, 30 Jun 2015 08:31:42 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mbob.nabble.com (Postfix) with ESMTP id 7AD29100CFA0 for ; Tue, 30 Jun 2015 01:32:27 -0700 (PDT) Date: Tue, 30 Jun 2015 01:31:37 -0700 (MST) From: gmb To: pgsql-sql@postgresql.org Message-ID: <1435653097868-5855854.post@n5.nabble.com> In-Reply-To: <88967b6b1d22d1cbdace2f0351b4ec6a@biglumber.com> References: <1435563798887-5855658.post@n5.nabble.com> <88967b6b1d22d1cbdace2f0351b4ec6a@biglumber.com> Subject: Re: Disable Trigger for session only MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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