Re: no cascade triggers? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: no cascade triggers?
Date
Msg-id 18896.1182869308@sss.pgh.pa.us
Whole thread Raw
In response to no cascade triggers?  (Chris Mair <chris@1006.org>)
Responses R: [postgresql-it] no cascade triggers?  ("Manera, Villiam" <vmanera@manord.com>)
List pgsql-hackers
Chris Mair <chris@1006.org> writes:
> On the italian list we're discussing a case were a user reportedly
> worked around this (i.e. got rid of unwanted cascading calls) by
> writing an on insert trigger procedure something on the lines of:

> ALTER TABLE tab DISABLE TRIGGER USER;
>   -- do more inserts into the same table
> ALTER TABLE tab ENABLE TRIGGER USER;

> While this reporetedly worked well in 8.2.1 it does not in 8.2.4
> resulting in an error:
>    ERROR: relation "distinta_base1" is being used by active queries
>    in this session Stato SQL: 55006

We could possibly re-allow that (see the comments in AlterTable())
but it seems like an ugly and inefficient technique that we shouldn't
be encouraging.  (The implications for system catalog bloat alone
seem enough reason to not recommend this.)  Isn't there a cleaner way
to design his application?  Maybe refactor the schema to avoid the
recursion in the first place?  Or add an "insert origin" column to the
table so that the trigger can easily detect trigger-inserted rows and
do nothing?
        regards, tom lane


pgsql-hackers by date:

Previous
From: "A.M."
Date:
Subject: Re: no cascade triggers?
Next
From: Josh Berkus
Date:
Subject: Re: [PATCHES] New Zealand - TZ change