Re: Disable Trigger for session only

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: gmb <gmbouwer(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Disable Trigger for session only
Date: 2015-06-29 13:06:29
Message-ID: 559142D5.2080608@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 06/29/2015 12:43 AM, gmb wrote:
> Hi
>
> I' pretty sure I know the answer, but trying my luck.
>
> I'm in a position where the most logical/effective way of doing an update
> (data fix) is this:
> ALTER TABLE temp DISABLE TRIGGER trigname;
> UPDATE temp ..... DO SOME STUFF....
> ALTER TABLE temp DISABLE TRIGGER trigname;
>
> Some notes:
> It cannot be guaranteed that the above happens as a single transaction.
> It is possible that this occurs at the same time as other session posting
> inserts/updates to table TEMP.

It can if wrapped in BEGIN/COMMIT or is there reason that is not being done?

>
> I'm seeing data which suggests that trigger trigname did not occur when in
> fact it should have ( i.e. the above update procedure is not relevant ).
> Does this make sense taking into account that multiple sessions posts to the
> table at once ?

Not without knowing what the trigger procedure does?

>
> I'm aware that session_replication_role can be used as alternative to
> disable triggers, and have been using it in other scenarios. But in this
> case i'd like to choose which trigger to disable (I want other triggers on
> table temp to still occur).
>
> Is there any other alternatives to this ?
>
> Will appreciate any input
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message gmb 2015-06-29 14:13:05 Re: Disable Trigger for session only
Previous Message gmb 2015-06-29 07:43:18 Disable Trigger for session only