Re: Nonexistent NEW relation in some places of rules - Mailing list pgsql-sql

From Tom Lane
Subject Re: Nonexistent NEW relation in some places of rules
Date
Msg-id 5035.1059517964@sss.pgh.pa.us
Whole thread Raw
In response to Nonexistent NEW relation in some places of rules  (Denis Zaitsev <zzz@anda.ru>)
List pgsql-sql
Denis Zaitsev <zzz@anda.ru> 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


pgsql-sql by date:

Previous
From: Denis Zaitsev
Date:
Subject: Re: Very strange 'now' behaviour in nested triggers.
Next
From: "Vishal Charan (IT Fiji)"
Date:
Subject: Unsubscribe