Denis Zaitsev <zzz(at)anda(dot)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