slightly unexpected result

From: Torsten Förtsch <tfoertsch123(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: slightly unexpected result
Date: 2024-01-10 11:29:54
Message-ID: CAKkG4_kM1yuqw1oimYM_fAzsSJqQkejWW5yHqw_WfOng+9Y4TQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

imagine a simple table with 1 row

=# table tf;
i | x
---+----
1 | xx
(1 row)

And this query:

with x as (update tf set i=i+1 returning *)
, y as (update tf set x=x||'yy' returning *)
select * from x,y;

My PG14 gives this result

i | x | i | x
---+---+---+---
(0 rows)

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?

Thanks,
Torsten

Responses

Browse pgsql-general by date

  From Date Subject
Next Message duc hiep ha 2024-01-10 13:58:24 failed to setup barman backup when Posgres is running in Podman Container
Previous Message Adrian Klaver 2024-01-09 16:00:09 Re: Unable to install postgresql and pgadmin