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

Re: Triggers on system catalog

From: Christopher Browne <cbbrowne(at)gmail(dot)com>
To: Shridhar Polas <shridharpolas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Triggers on system catalog
Date: 2011-03-29 18:17:36
Message-ID: AANLkTin7=5rsnErzGDscRWc1kv_TnLA9PyHo_vBEudGa@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Mon, Mar 28, 2011 at 10:19 AM, Shridhar Polas
<shridharpolas(at)gmail(dot)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

In response to

Responses

pgsql-hackers by date

Next:From: Noah MischDate: 2011-03-29 18:29:33
Subject: Re: deadlock_timeout at < PGC_SIGHUP?
Previous:From: Gurjeet SinghDate: 2011-03-29 17:41:41
Subject: Re: Triggers on system catalog

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