pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: chalx.shop@gmail.com
Subject: New vs old values collision in UPDATE RETURNING docs
Date: Fri, 15 Feb 2019 16:16:21 +0000
Message-ID: <155024738129.22709.5993209813359536828@wrigleys.postgresql.org> (raw)

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


Message-ID: <155024738129.22709.5993209813359536828@wrigleys.postgresql.org>
Permalink:  ../155024738129.22709.5993209813359536828@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/155024738129.22709.5993209813359536828@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, chalx.shop@gmail.com
  Subject: Re: New vs old values collision in UPDATE RETURNING docs
  In-Reply-To: <155024738129.22709.5993209813359536828@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox