Re: AfterTriggerSaveEvent() called outside of query - Mailing list pgsql-general

From Tom Lane
Subject Re: AfterTriggerSaveEvent() called outside of query
Date
Msg-id 1603.1289929245@sss.pgh.pa.us
Whole thread Raw
In response to AfterTriggerSaveEvent() called outside of query  (Vick Khera <vivek@khera.org>)
Responses Re: AfterTriggerSaveEvent() called outside of query  (Vick Khera <vivek@khera.org>)
List pgsql-general
Vick Khera <vivek@khera.org> 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

pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: median for postgresql 8.3
Next
From: Chris Barnes
Date:
Subject: I want to create a read only database for a specified user.