AfterTriggerSaveEvent() called outside of query

From: Vick Khera <vivek(at)khera(dot)org>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: AfterTriggerSaveEvent() called outside of query
Date: 2010-11-16 17:09:46
Message-ID: AANLkTikC6-uLcaQr0qwEuJaUc4ZJxa0u1-4P80y0q5f6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm running a script I have for cleaning out some old data. It
iterates over a handful of tables and deletes any data referencing a
row in an "owners" table. Basically, it enforces the equivalent of
the cascade delete of the data without actually deleting the master
row.

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
CONTEXT: SQL statement "DELETE FROM ONLY "public"."user_event_log"
WHERE $1 OPERATOR(pg_catalog.=) "user_id"" at ./purgeoldownerinfo line
77.

The context is showing a row being deleted via FK reference to the
user_list table user_id primary key field, which had an explicit
delete done by the loop.

I'm running this via Perl DBD::Pg connecting to a postgres 8.3.11
server on FreeBSD 8.1. The tables in this database are replicated
using slony1.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2010-11-16 17:37:00 Re: median for postgresql 8.3
Previous Message André Fernandes 2010-11-16 17:09:34 Re: Counting boolean values (how many true, how many false)