Re: Disable Trigger for session only

Поиск
Список
Период
Сортировка
От gmb
Тема Re: Disable Trigger for session only
Дата
Msg-id 1435653097868-5855854.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: Disable Trigger for session only  ("Greg Sabino Mullane" <greg@turnstep.com>)
Список pgsql-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.



В списке pgsql-sql по дате отправления:

Предыдущее
От: gmb
Дата:
Сообщение: Re: Disable Trigger for session only
Следующее
От: drunken
Дата:
Сообщение: [C#] File Upload to PostgreSQL