Обсуждение: triggers on views?

Поиск
Список
Период
Сортировка

triggers on views?

От
Robert Treat
Дата:
We had a doc comment come in noting that the second paragraph seems to be
incorrect on
http://www.postgresql.org/docs/8.3/interactive/rules-triggers.html,
specifically the part that says "On the other hand, a trigger that is fired
on INSERT on a view can do the same as a rule".  I'm not sure if this is
supposed to just be taken as a conceptual argument, but it is confusing
because you can't put insert triggers on views... so just what is it getting
at? This exists in several versions back, not sure how folks feel about
updating existing versions, but seems like it could use some rewording...
thoughts?

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL

Re: triggers on views?

От
Tom Lane
Дата:
Robert Treat <xzilla@users.sourceforge.net> writes:
> We had a doc comment come in noting that the second paragraph seems to be
> incorrect on
> http://www.postgresql.org/docs/8.3/interactive/rules-triggers.html,
> specifically the part that says "On the other hand, a trigger that is fired
> on INSERT on a view can do the same as a rule".

This was discussed last month:
http://archives.postgresql.org/pgsql-general/2008-06/msg00669.php

            regards, tom lane

Re: triggers on views?

От
Bruce Momjian
Дата:
Tom Lane wrote:
> Robert Treat <xzilla@users.sourceforge.net> writes:
> > We had a doc comment come in noting that the second paragraph seems to be
> > incorrect on
> > http://www.postgresql.org/docs/8.3/interactive/rules-triggers.html,
> > specifically the part that says "On the other hand, a trigger that is fired
> > on INSERT on a view can do the same as a rule".
>
> This was discussed last month:
> http://archives.postgresql.org/pgsql-general/2008-06/msg00669.php

OK, updated wording applied to CVS HEAD; attached.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/rules.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/rules.sgml,v
retrieving revision 1.51
diff -c -c -r1.51 rules.sgml
*** doc/src/sgml/rules.sgml    1 Feb 2007 19:10:24 -0000    1.51
--- doc/src/sgml/rules.sgml    16 Dec 2008 03:10:55 -0000
***************
*** 1869,1881 ****
  </para>

  <para>
!     On the other hand, a trigger that is fired on
!     <command>INSERT</command> on a view can do the same as a rule: put
!     the data somewhere else and suppress the insert in the view. But
!     it cannot do the same thing on <command>UPDATE</command> or
!     <command>DELETE</command>, because there is no real data in the
!     view relation that could be scanned, and thus the trigger would
!     never get called. Only a rule will help.
  </para>

  <para>
--- 1869,1877 ----
  </para>

  <para>
!     On the other hand, a trigger cannot be created on views because
!     there is no real data in a view relation;  however INSERT, UPDATE,
!     and DELETE rules can be created on views.
  </para>

  <para>