Re: Nonexistent NEW relation in some places of rules

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Denis Zaitsev <zzz(at)anda(dot)ru>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Nonexistent NEW relation in some places of rules
Date: 2003-07-29 22:32:44
Message-ID: 5035.1059517964@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Vishal Charan (IT Fiji) 2003-07-29 23:06:16 Unsubscribe
Previous Message Denis Zaitsev 2003-07-29 22:05:14 Re: Very strange 'now' behaviour in nested triggers.