]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Correctly update hasSubLinks while mutating a rule action.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 13 Jun 2023 19:58:37 +0000 (15:58 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 13 Jun 2023 19:58:37 +0000 (15:58 -0400)
commitcc6974df16e0dfb106c4caefd9d42d332a04247d
tree4dedc6caf27d59cd05c42483863f5a3238e77a2e
parentbd590d1fea1ba9245c791d589eea94d2dbad5a2b
Correctly update hasSubLinks while mutating a rule action.

rewriteRuleAction neglected to check for SubLink nodes in the
securityQuals of range table entries.  This could lead to failing
to convert such a SubLink to a SubPlan, resulting in assertion
crashes or weird errors later in planning.

In passing, fix some poor coding in rewriteTargetView:
we should not pass the source parsetree's hasSubLinks
field to ReplaceVarsFromTargetList's outer_hasSubLinks.
ReplaceVarsFromTargetList knows enough to ignore that
when a Query node is passed, but it's still confusing
and bad precedent: if we did try to update that flag
we'd be updating a stale copy of the parsetree.

Per bug #17972 from Alexander Lakhin.  This has been broken since
we added RangeTblEntry.securityQuals (although the presented test
case only fails back to 215b43cdc), so back-patch all the way.

Discussion: https://postgr.es/m/17972-f422c094237847d0@postgresql.org
src/backend/rewrite/rewriteHandler.c
src/test/regress/expected/updatable_views.out
src/test/regress/sql/updatable_views.sql