Within a trigger is there a way to tell if an update or insert triggering the trigger came from a trigger or not?
In PostgreSQL 9.3.5, I'm trying to prevent a trigger from executing again due to an update or insert within the current trigger or another trigger that executes upon update or insert. So I want to know what the source of the update is so I can prevent recursive triggering.
Unless I missed it, I looked here and didn't read anything about this in the manual:
https://www.postgresql.org/docs/9.2/static/plpgsql-trigger.htmlhttps://www.postgresql.org/docs/9.3/static/plpgsql-trigger.html
I don't think this would work because I am thinking it will always return the trigger I am currently in, not the source (trigger or not) of the udpate or insert:
TG_NAME
"Data type name; variable that contains the name of the trigger actually fired"
PostgreSQL 9.3.5
Data type name; variable that contains the name of the trigger actually fired
EDIT: Currently I am doing a lot of old.col_nm <> new.col_nm
etc. to try and determine via the values that change if it was one of my triggers or not. It would be nice if I could just say "if an update or insert came from a trigger return new;
""if an update or insert came from a trigger return new;
" and skip the bulk of the trigger.