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

Re: Doc bug (?) in rules vs triggers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: andrew(at)pillette(dot)com
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: Doc bug (?) in rules vs triggers
Date: 2004-02-15 21:43:04
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-docs
andrew(at)pillette(dot)com writes:
> Chapter 13 of the documentation on Rules versus Triggers says in part
> "On the other hand a trigger that is fired on INSERT on a view can do
> the same as a rule, put the data somewhere else and suppress the
> insert in the view."

> However, it does not appear to be possible to set a trigger on a view,
> so this means something else.

I think it means "this documentation is out of date" :-(.

Once long ago a view was a regular table with an ON SELECT rule, and so
you could in fact put triggers to catch attempted inserts rather than
relying on an ON INSERT rule.  This was removed because it was too
failure-prone --- people who had misdefined their triggers kept
wondering where their data went, when it in fact went into the view
table and could never be seen again because of the ON SELECT rule.
By requiring an ON INSERT rule, we can mechanically check for failure
to redirect the insert.  I think there were some implementation
considerations motivating that change, as well.

			regards, tom lane

In response to

pgsql-docs by date

Next:From: ljbDate: 2004-02-20 01:01:20
Subject: Request temporary freeze of libpgtcl chapter in manual
Previous:From: andrewDate: 2004-02-13 20:29:32
Subject: Doc bug (?) in rules vs triggers

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