New vs old values collision in UPDATE RETURNING docs

Поиск
Список
Период
Сортировка
Искать

New vs old values collision in UPDATE RETURNING docs

От:
PG Doc comments form <noreply@postgresql.org>
Дата:
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:

[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
output_expression: An expression to be computed and returned by the UPDATE
command after each row is updated.

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:

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;


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

/Alexey
FAQ