New vs old values collision in UPDATE RETURNING docs - Mailing list pgsql-docs

From PG Doc comments form
Subject New vs old values collision in UPDATE RETURNING docs
Date
Msg-id 155024738129.22709.5993209813359536828@wrigleys.postgresql.org
Whole thread Raw
List pgsql-docs
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/11/sql-update.html
Description:

What we have in doc:
<q>
[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
output_expression: An expression to be computed and returned by the UPDATE
command after each row is updated.
</q>
What we have in the wild (Pg8..11):
* when using field names, expression represents NEW values after update;
* when using sub-selects or joined table references, expression represents
OLD values before update.

POC code:
<code>
create temporary table test(id int primary key, status text not null);

insert into test(id, status) values(1, 'initial');

update test t set status='new'
where id=1
returning id,
    status as new_status,
    (select status from test where id=t.id) as old_status;
</code>

Thus that "after each row is updated" sentence is rather confusing.

/Alexey

pgsql-docs by date:

Previous
From: Jürgen Purtz
Date:
Subject: Re: First SVG graphic
Next
From: PG Doc comments form
Date:
Subject: Typo in documentation - runtime-config-wal