Re: inserting to a multi-table view - Mailing list pgsql-general

From Tom Lane
Subject Re: inserting to a multi-table view
Date
Msg-id 19394.1213900126@sss.pgh.pa.us
Whole thread Raw
In response to Re: inserting to a multi-table view  ("Michael Shulman" <shulman@mathcamp.org>)
List pgsql-general
"Michael Shulman" <shulman@mathcamp.org> writes:
>> http://www.postgresql.org/docs/8.3/static/rules-triggers.html
>> says "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."  So what do I need to do to make an INSERT trigger on a view?

> This quote from the manual implies to me that it is possible to make a
> trigger fire on INSERT on a view.  But postgres won't let me do this,
> and some things I've read elsewhere on the Internet imply that it is
> impossible.  Is the manual wrong?

The manual is wrong.  Although this text is so ancient that it probably
was true when written.  I don't offhand know when the check against
installing triggers on views was put in, but this section of the manual
predates the time when we started to draw a hard distinction between
views and tables.

There's been some recent talk about allowing ON INSERT triggers on
views, which would make this statement correct again, but nothing's
been done about it yet.  It's not entirely clear how useful such a
thing would be if we couldn't support UPDATE/DELETE too, and as stated
here those cases are a lot harder.

            regards, tom lane

pgsql-general by date:

Previous
From: Shane Ambler
Date:
Subject: Re: Losing data
Next
From: "Michael Shulman"
Date:
Subject: Re: inserting to a multi-table view