]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix parsing of parenthesised OLD/NEW in RETURNING list.
authorDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 11 Jun 2026 11:08:48 +0000 (12:08 +0100)
committerDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 11 Jun 2026 11:08:48 +0000 (12:08 +0100)
commit9108fed3eda97475d5ef2f9060f6bc1f61783346
tree6ebee2c4f8a569c68fb9f483e33369f19fccea04
parent0004cab4dc60577779d97a8f1a175b6dd07dc223
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
src/backend/parser/parse_coerce.c
src/backend/parser/parse_func.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_target.c
src/include/parser/parse_relation.h
src/test/regress/expected/returning.out
src/test/regress/sql/returning.sql