Vick Khera <vivek@xxxxxxxxx> writes: > The code looks basically like this, for each owner_id ($oid) targeted > for the purge: > BEGIN; > SET LOCAL synchronous_commit TO OFF; > SET CONSTRAINTS ALL DEFERRED; > foreach table (owner_log, ... user_list, invoices, ... ) > DELETE FROM $table WHERE owner_id=$oid > UPDATE owner SET status='terminated' WHERE owner_id=$oid > INSERT INTO admin_log (.... record of account being purged ... ); > COMMIT; > This worked just dandy without the two SET commands above I added > yesterday to try to speed things up. (Yes, the constraints are marked > as deferrable...) What happens is now I get the following error: > ERROR: AfterTriggerSaveEvent() called outside of query The code comment associated with that error message says: * Check state. We use normal tests not Asserts because it is possible * to reach here in the wrong state given misconfigured RI triggers, * in particular deferring a cascade action trigger. The system will not normally allow cascade actions to be deferred ... did you manually munge the pg_trigger entries? If you managed to provoke this purely through DDL commands, that would be a bug, and I'd like to see how you did it. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general