Trace triggers

Started by Marek Lewczukabout 21 years ago3 messagesgeneral
Jump to latest
#1Marek Lewczuk
newsy@lewczuk.com

Hi,
I have a table with many triggers. Now, it can happen that in middle of
execution one of table's triggers there will be unknown error (like
"NEW" is not assigned yet) - is there a way to trace which trigger fired
this error ?

Thanks in advance.

ML

#2Terry Lee Tucker
terry@esc1.com
In reply to: Marek Lewczuk (#1)
Re: Trace triggers

I don't know if there is some built in way of doing it, but we have
implemented the following in all our trigger code:

DECLARE
....
....
dbg BOOLEAN DEFAULT False; -- debug messages flag
BEGIN
IF dbg THEN
RAISE NOTICE ''% (%)'', TG_NAME, TG_OP;
END IF;

While developing triggers or a series of triggers, we turn that dbg flag on.
Then we can see what is happening.

On Thursday 13 January 2005 09:14 am, Marek Lewczuk saith:

Hi,
I have a table with many triggers. Now, it can happen that in middle of
execution one of table's triggers there will be unknown error (like
"NEW" is not assigned yet) - is there a way to trace which trigger fired
this error ?

Thanks in advance.

ML

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

__
Work: 1-336-372-6812
Cell: 1-336-363-4719
email: terry@esc1.com

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marek Lewczuk (#1)
Re: Trace triggers

Marek Lewczuk <newsy@lewczuk.com> writes:

I have a table with many triggers. Now, it can happen that in middle of
execution one of table's triggers there will be unknown error (like
"NEW" is not assigned yet) - is there a way to trace which trigger fired
this error ?

Use PG 7.4 or later, and look at the CONTEXT part of the error message.

regards, tom lane