slightly unexpected result - Mailing list pgsql-general

From Torsten Förtsch
Subject slightly unexpected result
Date
Msg-id CAKkG4_kM1yuqw1oimYM_fAzsSJqQkejWW5yHqw_WfOng+9Y4TQ@mail.gmail.com
Whole thread Raw
Responses Re: slightly unexpected result
List 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

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Unable to install postgresql and pgadmin
Next
From: duc hiep ha
Date:
Subject: failed to setup barman backup when Posgres is running in Podman Container