From: | PG Doc comments form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-docs(at)lists(dot)postgresql(dot)org |
Cc: | chalx(dot)shop(at)gmail(dot)com |
Subject: | New vs old values collision in UPDATE RETURNING docs |
Date: | 2019-02-15 16:16:21 |
Message-ID: | 155024738129.22709.5993209813359536828@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | PG Doc comments form | 2019-02-15 19:51:31 | Typo in documentation - runtime-config-wal |
Previous Message | Jürgen Purtz | 2019-02-15 10:58:46 | Re: First SVG graphic |