Received: from candle.pha.pa.us (candle.navpoint.com [162.33.245.46]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f153c7x45960 for ; Sun, 4 Feb 2001 22:38:07 -0500 (EST) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id WAA26367; Sun, 4 Feb 2001 22:37:45 -0500 (EST) From: Bruce Momjian Message-Id: <200102050337.WAA26367@candle.pha.pa.us> Subject: Re: Bug with rules in 7.0.3? In-Reply-To: "from Tod McQuillin at Feb 4, 2001 01:59:03 am" To: Tod McQuillin Date: Sun, 4 Feb 2001 22:37:45 -0500 (EST) CC: Tom Lane , pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL77 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200102/36 X-Sequence-Number: 1204 > On Sat, 3 Feb 2001, Tom Lane wrote: > > > I get > > > > regression=# SELECT * FROM orders; > > order_id | menu_id | price > > ----------+---------+------- > > 1 | 2 | -1 > > (1 row) > > > > which is the correct result given that rules are executed before the > > original query. (Which is why you need a trigger for this...) > > OK. > > I think that Bruce's book is inaccurate then. In section D.19 (p. 299), > also reproduced on the web at > http://www.postgresql.org/docs/aw_pgsql_book/node490.html, this example is > given: > > All new employees must make 5,000 or less: > > CREATE RULE example_5 AS > ON INSERT TO emp > WHERE new.salary > 5000 DO > UPDATE emp SET salary = 5000 > WHERE emp.oid = new.oid; I checked the current create_rule.sgml file, and this example query is no longer in the file. Not sure why it was removed, but it will not appear in 7.1. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026