Re: slightly unexpected result

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: slightly unexpected result
Дата
Msg-id CAKFQuwZgyTQpNWUqGuHNUQmsU2KC2onDZzxEMSpcQFuqmgZ1_A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: slightly unexpected result  (Bruce Momjian <bruce@momjian.us>)
Ответы Re: slightly unexpected result
Список pgsql-general
On Wed, Jan 10, 2024 at 8:46 AM Bruce Momjian <bruce@momjian.us> wrote:
On Wed, Jan 10, 2024 at 12:29:54PM +0100, Torsten Förtsch wrote:

>
> To me that was a bit surprising. I would have expected it to fail with
> something like "can't update the same row twice in the same command".
>
> If I check the table content after the query I see the i=i+1 part was executed.
>
> Is this expected behavior?

Yes, this surprised me too.

It is mostly documented.

"""
Only one of the modifications takes place, but it is not easy (and sometimes not possible) to reliably predict which one.
...
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.
"""

Yes, an error would be nice, but the effort put forth stops at unpredictable, and saying just don't do it.

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: kaido vaikla
Дата:
Сообщение: Re: failed to setup barman backup when Posgres is running in Podman Container
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: slightly unexpected result