Re: Why do OLD and NEW have special internal names?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Wieck <JanWieck(at)Yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why do OLD and NEW have special internal names?
Date: 2009-11-20 21:39:17
Message-ID: 9032.1258753157@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jan Wieck <JanWieck(at)Yahoo(dot)com> writes:
> On 11/20/2009 1:12 AM, Tom Lane wrote:
>> Jan Wieck <JanWieck(at)Yahoo(dot)com> writes:
>>> But this brings up another point about the recent discussion of what
>>> RENAME is good for. Removing RENAME may conflict with using OLD/NEW in
>>> UPDATE ... RETURNING. No?
>>
>> Um ... not sure why. Specific example please?

> Inside a trigger proc, NEW is supposed to mean the new row for the table
> that fired the trigger. However, inside an UPDATE RETURNING for example,
> there is another set of NEW and OLD.

Uh, no there isn't ... and if there were I suppose it'd act much like
a query-local alias.

> Let's call the trigger call's NEW
> NEW_a and the UPDATE RETURNING NEW NEW_b. How would the developer
> specify something like

> INSERT ... RETURNING (NEW_a.value - NEW_b.value)?

They could use ALIAS to rename the trigger's NEW to something else.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-11-20 22:00:05 Re: [COMMITTERS] pgsql: Add a WHEN clause to CREATE TRIGGER, allowing a boolean
Previous Message Tom Lane 2009-11-20 21:25:39 Re: Prettification versus dump safety