X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 87EA7D1DAA6 for ; Sun, 15 Feb 2004 21:43:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 99780-04 for ; Sun, 15 Feb 2004 17:43:05 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 61DCBD1D8AA for ; Sun, 15 Feb 2004 17:43:03 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1FLh4ci010822; Sun, 15 Feb 2004 16:43:04 -0500 (EST) To: andrew@pillette.com Cc: pgsql-docs@postgresql.org Subject: Re: Doc bug (?) in rules vs triggers In-reply-to: <200402132029.i1DKTWp01272@pillette.com> References: <200402132029.i1DKTWp01272@pillette.com> Comments: In-reply-to andrew@pillette.com message dated "Fri, 13 Feb 2004 12:29:32 -0800" Date: Sun, 15 Feb 2004 16:43:04 -0500 Message-ID: <10821.1076881384@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/16 X-Sequence-Number: 2271 andrew@pillette.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