Track nesting depth correctly when drilling down into RECORD Vars.
authorTom Lane <[email protected]>
Fri, 15 Sep 2023 21:01:26 +0000 (17:01 -0400)
committerTom Lane <[email protected]>
Fri, 15 Sep 2023 21:01:26 +0000 (17:01 -0400)
commita374f6c61681fe072526fc5580df191347bea061
tree5efcf30d3cc08a939cf8e6e9df56f5c59d014a98
parent479b99125dcce0d625846efd333ccc5aa48411bb
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
src/backend/parser/parse_target.c
src/backend/utils/adt/ruleutils.c
src/test/regress/expected/rowtypes.out
src/test/regress/sql/rowtypes.sql