Fix parsing of parenthesised OLD/NEW in RETURNING list.
Dean Rasheed <dean.a.rasheed@gmail.com>
Author:
Dean Rasheed <dean.a.rasheed@gmail.com>
Date: 2026-06-11T11:08:47Z
Releases:
19 (unreleased)
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@gmail.com> Author: Marko Grujic <markoog@gmail.com> Suggested-by: Dean Rasheed <dean.a.rasheed@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/CAOvwyF2cO_5mAt=w=y-dFnaG5UkZ+3H8nSDoKF_iuWZHsU2ARg@mail.gmail.com Backpatch-through: 18
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/parser/parse_coerce.c | modified | +4 −5 |
| src/backend/parser/parse_func.c | modified | +1 −3 |
| src/backend/parser/parse_relation.c | modified | +32 −0 |
| src/backend/parser/parse_target.c | modified | +1 −1 |
| src/include/parser/parse_relation.h | modified | +1 −0 |
| src/test/regress/expected/returning.out | modified | +25 −0 |
| src/test/regress/sql/returning.sql | modified | +11 −0 |
Discussion
- [PATCH v1] [BUG #19516] Skip whole-row projection shortcut for OLD/NEW returning type 7 messages · 2026-06-10 → 2026-06-11