Re: no cascade triggers?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Mair <chris(at)1006(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org, postgresql-it(at)lists(dot)psql(dot)it
Subject: Re: no cascade triggers?
Date: 2007-06-26 14:48:28
Message-ID: 18896.1182869308@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chris Mair <chris(at)1006(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2007-06-26 14:59:25 Re: [PATCHES] New Zealand - TZ change
Previous Message Andrew Dunstan 2007-06-26 14:45:05 Re: [COMMITTERS] pgsql: Arrange for quote_identifier() and pg_dump to not quote keywords