Re: Triggers on system catalog - Mailing list pgsql-hackers

From Christopher Browne
Subject Re: Triggers on system catalog
Date
Msg-id AANLkTin7=5rsnErzGDscRWc1kv_TnLA9PyHo_vBEudGa@mail.gmail.com
Whole thread Raw
In response to Triggers on system catalog  (Shridhar Polas <shridharpolas@gmail.com>)
Responses Re: Triggers on system catalog
List pgsql-hackers
On Mon, Mar 28, 2011 at 10:19 AM, Shridhar Polas
<shridharpolas@gmail.com> wrote:
> Hi,
> Is there a way to create triggers on system catalog tables like
> pg_class, pg_attribute etc...?

No, this isn't supported, and, since the normal alterations of the
schema involve manipulating these tables, such an addition would be
fraught with the risk of breaking system behavior.

- Your trigger function needs to be aware of *ALL* functionalities
that involve those tables. For instance, a trigger on pg_class needs to be able to cope with
changes relating to views, sequences, inherited tables, not just its
use for tables.

- There are liable to be timing issues, as a series of updates to
these tables won't in general be consistent until *all* the updates
are done. E.g. - consider that when a table is created, there'd be an insert
to pg_class, and then, later, inserts to pg_attribute.  A trigger
firing against pg_class would capture a partially-completed table
creation, which mayn't be what you were expecting.

A proposal to adding triggers to system catalog tables won't be
terribly popular.
--
http://linuxfinances.info/info/postgresql.html


pgsql-hackers by date:

Previous
From: Gurjeet Singh
Date:
Subject: Re: Triggers on system catalog
Next
From: Noah Misch
Date:
Subject: Re: deadlock_timeout at < PGC_SIGHUP?