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

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

2011-01-19 Thread Kevin Grittner
Tom Lane 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 (pgsql-general@postgresql.org) To make chan

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

2011-01-19 Thread Kevin Grittner
"A.M." 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 > distinguish between dep

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

2011-01-19 Thread Tom Lane
"Kevin Grittner" writes: > "A.M." 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 wri

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 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 trig

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." 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 y

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

2011-01-19 Thread Kevin Grittner
"A.M." 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 a PL > which does supp

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

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

2011-01-19 Thread Kevin Grittner
Adrian Klaver 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 something about the cr

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 bigg

[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 call