Re: Triggers on system tables

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Triggers on system tables
Date: 2004-02-12 03:45:25
Message-ID: Pine.LNX.4.58.0402121431140.26147@linuxworld.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 11 Feb 2004, Tom Lane wrote:

> Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> writes:
> > There have been a few discussions about triggers on system tables in
> > the past and the problems with such triggers seem to be:
>
> I think the killer problem is that we couldn't allow triggers on system
> tables to do very much. By definition, the database is in an inconsistent
> state if we are in the middle of updating system tables. We can't allow
> arbitrary bits of SQL to run then.
>
> It might be feasible to allow AFTER triggers on system tables, since
> those don't actually fire until end of statement, at which point things
> are hopefully consistent again. I don't even want to think about
> allowing BEFORE triggers.

Actually, all my tests (CREATE TABLE case) have been for
AFTER triggers as I didn't want to look at BEFORE cases either.

If the trigger is executed after all system catalog/index updates, plus
CommandCounterIncrement(), we should be consistent, right?

My idea is to provide a generic interface which is called inside
ProcessUtility() after all other functions are called for the particular
node we're handling. The nodetag itself will be passed to this generic
function, the function will map nodetag to the relevant underlying system
table, get the TriggerDesc for the relation and pass it and the relation
data onto the trigger system. CREATE will call insert triggers, ALTER will
call update triggers, DROP will call delete.

If this sounds good, I think we can deal with AFTER ... STATEMENT
level triggers without having to worry about constructing state.

Thanks,

Gavin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2004-02-12 03:51:15 Re: Triggers on system tables
Previous Message Tom Lane 2004-02-12 03:30:31 Re: Triggers on system tables