BUG #19516: Mixup of OLD/NEW with RETURNING when parenthesized

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: markoog(at)gmail(dot)com
Subject: BUG #19516: Mixup of OLD/NEW with RETURNING when parenthesized
Date: 2026-06-10 10:09:51
Message-ID: 19516-97e045ee5e78c98d@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19516
Logged by: Marko Grujic
Email address: markoog(at)gmail(dot)com
PostgreSQL version: 18.4
Operating system: MacOS, Debian
Description:

Hi, reporting a basic bug which involves a RETURNING clause on DML with
parenthesized OLD/NEW.

Effectively, the (parenthesized) row reference isn't being honored, and
instead the default behavior is applied.

Seeing this on tip of master as well (19beta1).

postgres=# create table t(a int, b text);
CREATE TABLE
postgres=# insert into t values (1, 'one') returning (old).b, old.b,
(new).b, new.b;
b | b | b | b
-----+---+-----+-----
one | | one | one
(1 row)

INSERT 0 1
postgres=# update t set b = '1' where a = 1 returning (old).b, old.b,
(new).b, new.b;
b | b | b | b
---+-----+---+---
1 | one | 1 | 1
(1 row)

UPDATE 1
postgres=# delete from t where a = 1 returning (old).b, old.b, (new).b,
new.b;
b | b | b | b
---+---+---+---
1 | 1 | 1 |
(1 row)

DELETE 1
postgres=# select version();
version
--------------------------------------------------------------------------------------------------------------------
PostgreSQL 18.4 (Debian 18.4-1.pgdg13+1) on x86_64-pc-linux-gnu, compiled
by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
(1 row)

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Marko Grujic 2026-06-10 10:50:39 Re: BUG #19516: Mixup of OLD/NEW with RETURNING when parenthesized
Previous Message Amit Langote 2026-06-10 09:40:52 Re: BUG #19470: PostgreSQL backend aborts (assert failure) when a prepared statement returns a composite type cast t