X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A93A6D1C97F for ; Tue, 29 Jul 2003 22:32:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 01511-08 for ; Tue, 29 Jul 2003 19:31:54 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 86C35D1C7F5 for ; Tue, 29 Jul 2003 19:32:50 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h6TMWiQ3005036; Tue, 29 Jul 2003 18:32:44 -0400 (EDT) To: Denis Zaitsev Cc: pgsql-sql@postgresql.org Subject: Re: Nonexistent NEW relation in some places of rules In-reply-to: <20030730033328.B4870@natasha.ward.six> References: <20030730033328.B4870@natasha.ward.six> Comments: In-reply-to Denis Zaitsev message dated "Wed, 30 Jul 2003 03:33:28 +0600" Date: Tue, 29 Jul 2003 18:32:44 -0400 Message-ID: <5035.1059517964@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/437 X-Sequence-Number: 14551 Denis Zaitsev writes: > create rule b as > on insert to b do instead > insert into a > select * from produce (new.b); > ERROR: Relation "*NEW*" does not exist > So, what is wrong in using NEW right from the FROM? CVS tip gives a possibly more helpful error message: ERROR: function expression in FROM may not refer to other relations of same query level The problem is that the rule gets expanded into something rather like insert into a select ... from new, produce(new.b); and we can't support that. If we ever add support for SQL99's LATERAL(), it might help improve matters. regards, tom lane