data modifying WITH seems to drop rows in cascading updates -- bug?

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: data modifying WITH seems to drop rows in cascading updates -- bug?
Date: 2019-08-23 15:36:01
Message-ID: CAHyXU0xibzCj+zOGF87-mcpTpD=tBYoHFyKZimRio3pM8YZsuw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hackers,

Trying to figure out if this is undefined behavior of a bug. It's
confusing, and I'm aware of certain oddities in the fringes of the
data modifying with queries where the query dependencies are not
really clear. Why does the query only return one row?

postgres=# create table foo(id int);
CREATE TABLE
postgres=# insert into foo values(1);
INSERT 0 1
postgres=# with a as (update foo set id = id + 1 returning *), b
as(update foo set id = id + 1 returning * ) select * from a union all
select id from b;
id
────
2
(1 row)

postgres=# select version();
version
─────────────────────────────────────────────────────────────────────────────────────────────────────────
PostgreSQL 11.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5
20150623 (Red Hat 4.8.5-28), 64-bit
(1 row)

merlin

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-08-23 17:54:18 Re: data modifying WITH seems to drop rows in cascading updates -- bug?
Previous Message Tom Lane 2019-08-23 14:58:14 Re: BUG #15964: vacuumdb.c:187:10: error: use of undeclared identifier 'FD_SETSIZE'