Re: [GENERAL] How to fire triggers just on top level DML

2011-01-20 Thread hubert depesz lubaczewski
Any suggestions? you might find this approach useful: http://www.depesz.com/index.php/2008/01/18/how-to-check-if-given-update-is-from-trigger-or-why-i-hate-orms/ Best regards, depesz -- Linkedin: http://www.linkedin.com/in/depesz / blog: http://www.depesz.com/ jid/gtalk: dep...@depesz.com

[GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread Kevin Grittner
We've been running for about ten years on a framework which fires triggers similar to database triggers in a Java tier close to the database, and we're now trying to convert these to actual PostgreSQL database triggers. Our biggest hitch at the moment is that we defined a class of triggers we

Re: [GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread Adrian Klaver
On Wednesday 19 January 2011 1:59:48 pm Kevin Grittner wrote: We've been running for about ten years on a framework which fires triggers similar to database triggers in a Java tier close to the database, and we're now trying to convert these to actual PostgreSQL database triggers. Our biggest

Re: [GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread Kevin Grittner
Adrian Klaver adrian.kla...@gmail.com wrote: TG_ARGV[] Data type array of text; the arguments from the CREATE TRIGGER statement. Thanks for the suggestion, but I don't think this does what I need. I need to know whether the trigger was *fired* from inside another trigger, not

Re: [GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread A.M.
On Jan 19, 2011, at 4:59 PM, Kevin Grittner wrote: We've been running for about ten years on a framework which fires triggers similar to database triggers in a Java tier close to the database, and we're now trying to convert these to actual PostgreSQL database triggers. Our biggest hitch at

Re: [GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread Kevin Grittner
A.M. age...@themactionfaction.com wrote: Most PLs include some session-specific storage. In PL/Perl, it is %_SHARED. Setting a flag there should do the trick. If you are using a PL which does not have such a notion (like plpgsql), you can add a call in your triggers to a function written in

Re: [GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread A.M.
On Jan 19, 2011, at 5:36 PM, Kevin Grittner wrote: A.M. age...@themactionfaction.com wrote: Most PLs include some session-specific storage. In PL/Perl, it is %_SHARED. Setting a flag there should do the trick. If you are using a PL which does not have such a notion (like plpgsql), you

Re: [GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread Adrian Klaver
On Wednesday 19 January 2011 2:20:35 pm Kevin Grittner wrote: Adrian Klaver adrian.kla...@gmail.com wrote: TG_ARGV[] Data type array of text; the arguments from the CREATE TRIGGER statement. Thanks for the suggestion, but I don't think this does what I need. I need to know

Re: [GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread Tom Lane
Kevin Grittner kevin.gritt...@wicourts.gov writes: A.M. age...@themactionfaction.com wrote: Most PLs include some session-specific storage. In PL/Perl, it is %_SHARED. Setting a flag there should do the trick. If you are using a PL which does not have such a notion (like plpgsql), you can

Re: [GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread Kevin Grittner
A.M. age...@themactionfaction.com wrote: If you do implement TG_DEPTH, I am curious as to what the difference between TG_DEPTH==34 and TG_DEPTH==35 could mean. I think it might cause poor coding practice in making decisions based off assumed trigger order execution. Since you only care to

Re: [GENERAL] How to fire triggers just on top level DML

2011-01-19 Thread Kevin Grittner
Tom Lane t...@sss.pgh.pa.us wrote: Correctly resetting such a value after a transaction/subtransaction abort might be a bit problematic. Good point. Definitely an area to pay particularly close attention. Thanks, -Kevin -- Sent via pgsql-general mailing list