| From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix parsing of parenthesised OLD/NEW in RETURNING list. |
| Date: | 2026-06-11 11:10:54 |
| Message-ID: | E1wXdJG-001znS-1U@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix parsing of parenthesised OLD/NEW in RETURNING list.
When parsing expressions like (old).colname and (old).* in a RETURNING
list, the parser would lose track of the intended varreturningtype,
and therefore return incorrect results.
The root cause was code using GetNSItemByRangeTablePosn() to find a
namespace item from its rtindex and levelsup, without taking into
account returningtype, which would return the wrong namespace item.
Fix by adding a new function GetNSItemByVar() that does take
returningtype into account.
Backpatch to v18, where support for RETURNING OLD/NEW was added.
Bug: #19516
Reported-by: Marko Grujic <markoog(at)gmail(dot)com>
Author: Marko Grujic <markoog(at)gmail(dot)com>
Suggested-by: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Reviewed-by: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAOvwyF2cO_5mAt=w=y-dFnaG5UkZ+3H8nSDoKF_iuWZHsU2ARg@mail.gmail.com
Backpatch-through: 18
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/79c65b9d97fe92ea2792be09479cf4bbea7cefe1
Modified Files
--------------
src/backend/parser/parse_coerce.c | 9 ++++-----
src/backend/parser/parse_func.c | 4 +---
src/backend/parser/parse_relation.c | 32 ++++++++++++++++++++++++++++++++
src/backend/parser/parse_target.c | 2 +-
src/include/parser/parse_relation.h | 1 +
src/test/regress/expected/returning.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/returning.sql | 11 +++++++++++
7 files changed, 75 insertions(+), 9 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2026-06-11 14:19:48 | pgsql: IS JSON/JSON(): Protect against expressions uncoercible to text |
| Previous Message | Michael Paquier | 2026-06-11 10:01:43 | pgsql: Remove TAP test for timeline lookup race with logical decoding o |