Re: BUG #17689: Two UPDATE operators in common table expressions (CTE) perform not as expected

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: eugene(dot)pliskin(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17689: Two UPDATE operators in common table expressions (CTE) perform not as expected
Date: 2022-11-18 13:05:16
Message-ID: CAL9smLDd7kvT9xCpOUFwNcvEaz_zsmua8XpuR5Pd6wBdaP33bA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

.m

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2022-11-18 17:05:57 Re: BUG #17689: Two UPDATE operators in common table expressions (CTE) perform not as expected
Previous Message hubert depesz lubaczewski 2022-11-18 11:27:17 Re: WAL segments removed from primary despite the fact that logical replication slot needs it.