Re: Can a nested function determine it is being called within a trigger?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Basil Bourque <basil(dot)list(at)me(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Can a nested function determine it is being called within a trigger?
Date: 2011-04-15 23:36:29
Message-ID: 14640.1302910589@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Basil Bourque <basil(dot)list(at)me(dot)com> writes:
> When a trigger calls a function, that function can determine if it is being called from within a trigger by testing for a value in the special variable "TG_OP".

Uh, no, not really. TG_OP is a local variable in the trigger function;
it's not visible from elsewhere.

> But what if a trigger calls a function that calls a 2nd function via the "PERFORM" command? Can that 2nd function tell if it is being run in a trigger?

No. Doesn't really matter whether you use PERFORM or not.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2011-04-15 23:42:00 Re: Can a nested function determine it is being called within a trigger?
Previous Message Adrian Klaver 2011-04-15 22:58:40 Re: Help: pg_restore failure