pgsql: Track nesting depth correctly when drilling down into RECORD Var

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Track nesting depth correctly when drilling down into RECORD Var
Date: 2023-09-15 21:02:07
Message-ID: E1qhFx0-0042tv-L3@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Track nesting depth correctly when drilling down into RECORD Vars.

expandRecordVariable() failed to adjust the parse nesting structure
correctly when recursing to inspect an outer-level Var. This could
result in assertion failures or core dumps in corner cases.

Likewise, get_name_for_var_field() failed to adjust the deparse
namespace stack correctly when recursing to inspect an outer-level
Var. In this case the likely result was a "bogus varno" error
while deparsing a view.

Per bug #18077 from Jingzhou Fu. Back-patch to all supported
branches.

Richard Guo, with some adjustments by me

Discussion: https://postgr.es/m/18077-b9db97c6e0ab45d8@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d29812c0c6cd58794cb1c0eb1603a17a1ceb0d0b

Modified Files
--------------
src/backend/parser/parse_target.c | 20 ++++++++----
src/backend/utils/adt/ruleutils.c | 37 ++++++++++++---------
src/test/regress/expected/rowtypes.out | 60 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/rowtypes.sql | 25 ++++++++++++++
4 files changed, 120 insertions(+), 22 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2023-09-18 05:30:35 pgsql: Update Unicode data to Unicode 15.1.0
Previous Message Tom Lane 2023-09-15 21:02:06 pgsql: Fix get_expr_result_type() to find field names for RECORD Consts