pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Marko Tiikkaja <marko@joh.to>
Cc: eugene.pliskin@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17689: Two UPDATE operators in common table expressions (CTE) perform not as expected
Date: Fri, 18 Nov 2022 18:05:57 +0100
Message-ID: <20221118170557.3ndokzwhilygtfq7@alvherre.pgsql> (raw)
In-Reply-To: <CAL9smLDd7kvT9xCpOUFwNcvEaz_zsmua8XpuR5Pd6wBdaP33bA@mail.gmail.com>

On 2022-Nov-18, Marko Tiikkaja wrote:

> This is a documented limitation:
> 
> > Trying to update the same row twice in a single statement is not
> > supported. Only one of the modifications takes place, but it is not
> > easy (and sometimes not possible) to reliably predict which one.
> > This also applies to deleting a row that was already updated in the
> > same statement: only the update is performed. Therefore you should
> > generally avoid trying to modify a single row twice in a single
> > statement. In particular avoid writing WITH sub-statements that
> > could affect the same rows changed by the main statement or a
> > sibling sub-statement. The effects of such a statement will not be
> > predictable.
> 
> https://www.postgresql.org/docs/current/queries-with.html

I wonder if we should try to detect the case, and raise an error instead
of it resulting in undefined behavior.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/





view thread (5+ messages)  latest in thread

Message-ID: <20221118170557.3ndokzwhilygtfq7@alvherre.pgsql>
Permalink:  ../20221118170557.3ndokzwhilygtfq7@alvherre.pgsql/
Also on:    postgresql.org/message-id/20221118170557.3ndokzwhilygtfq7@alvherre.pgsql

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@alvh.no-ip.org, marko@joh.to, eugene.pliskin@gmail.com
  Subject: Re: BUG #17689: Two UPDATE operators in common table expressions (CTE) perform not as expected
  In-Reply-To: <20221118170557.3ndokzwhilygtfq7@alvherre.pgsql>
  References: <CAL9smLDd7kvT9xCpOUFwNcvEaz_zsmua8XpuR5Pd6wBdaP33bA@mail.gmail.com> <20221118170557.3ndokzwhilygtfq7@alvherre.pgsql>

* 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