Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group