If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Disabling triggers' firing

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Feb 2013
Posts: 1
Disabling triggers' firing

Hi,
we do get input to database both from UI and custom made sql-string-replication. (i.e it feeds tables with statements).
Due this replication we have implemented triggers.
Everything is fine, but now we should find a smart way NOT to fire trigger when input comes from replication.
Anyone with good ideas ??
Cheesrs,
timo

Last edited by talja; 02-12-13 at 07:49.
Reply With Quote
  #2 (permalink)  
Old
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,839
Disabling or enabling the trigger may impact UI (non-replication) table updates.

Why not
  1. Add a table to hold the replication update user's logon name for the replication updates.
  2. Change your trigger function to first check for the user name presence in the above table. If there is no user in the table, it's a standard table update taking place, so the trigger function continues normally. If there IS a record of this user's name in the above table, replication is taking place; do not perform the code in the function.
  3. Finally, alter the replication script, so that it writes the current user name to the table above before writing replication records into the main table, and removes the current user name at the end of the script.

This way, while user Bob starts the replication script, if user Fred then used the UI while the replication update was taking place, Fred's updates would be handled normally, even while Bob's replication updates would cause the trigger function to 'short circuit' its normal operation.

The only time this would 'bite you' would be if Bob tried to use the UI at the same time he's running the replication script...
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On