I have db behind ERP.
I have created triggers and a triggerfunction(plperl)
to collect all insert, update and delete-statements into audit table.

All tables have triggers that call storecommand -function.
Same function is used everytime and it dynamically collects data and save
it into the audit table.

when in some reason primarykey columns value is updated on table t1 and table t2 has foreingkey that references to updated column on t1.

After triggerfunction is done with t1's update statement, the referencing data starts to change on t2 and launches triggerfunction. Audit table has primarykey (serverId smallint NOT NULL, timeSt timestamp(3) NOT NULL DEFAULT ('now'::text)) so the primarykey brokes action because cascade update manages to write more rows then in time that primarykey is planned to. Audit table cannot be changed.

How should i avoid cascade transactions not to be stored?

Is there a way to temporally disable references between tables t1 and t2...?
Or way to identify cascade transaction?