postgresql/src/include/parser
Dean Rasheed 79c65b9d97 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
2026-06-11 12:08:47 +01:00
..
analyze.h Mark JumbleState as a const in the post_parse_analyze hook 2026-04-07 15:22:49 +09:00
kwlist.h Add UPDATE/DELETE FOR PORTION OF 2026-04-01 19:06:03 +02:00
parse_agg.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_clause.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_coerce.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_collate.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_cte.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_enr.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_expr.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_func.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_graphtable.h SQL Property Graph Queries (SQL/PGQ) 2026-03-16 10:14:18 +01:00
parse_merge.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_node.h Add UPDATE/DELETE FOR PORTION OF 2026-04-01 19:06:03 +02:00
parse_oper.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_param.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_relation.h Fix parsing of parenthesised OLD/NEW in RETURNING list. 2026-06-11 12:08:47 +01:00
parse_target.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_type.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_utilcmd.h Don't try to re-order the subcommands of CREATE SCHEMA. 2026-04-06 15:16:25 -04:00
parser.h Force standard_conforming_strings to always be ON. 2026-01-21 15:08:38 -05:00
parsetree.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
scanner.h Force standard_conforming_strings to always be ON. 2026-01-21 15:08:38 -05:00
scansup.h Update copyright for 2026 2026-01-01 13:24:10 -05:00