Propagate CTE property flags when copying a CTE list into a rule.
authorTom Lane <[email protected]>
Sun, 7 Feb 2021 00:28:39 +0000 (19:28 -0500)
committerTom Lane <[email protected]>
Sun, 7 Feb 2021 00:28:39 +0000 (19:28 -0500)
commit4384eccb15495960194a4a9dc1e2861f612f3ee5
treea60bef35de0e91fe7de6f0b2d4a3bfb6be7e5a3d
parent5ad03374bfe74ebdea937461170c1567671e11e0
Propagate CTE property flags when copying a CTE list into a rule.

rewriteRuleAction() neglected this step, although it was careful to
propagate other similar flags such as hasSubLinks or hasRowSecurity.
Omitting to transfer hasRecursive is just cosmetic at the moment,
but omitting hasModifyingCTE is a live bug, since the executor
certainly looks at that.

The proposed test case only fails back to v10, but since the executor
examines hasModifyingCTE in 9.x as well, I suspect that a test case
could be devised that fails in older branches.  Given the nearness
of the release deadline, though, I'm not going to spend time looking
for a better test.

Report and patch by Greg Nancarrow, cosmetic changes by me

Discussion: https://postgr.es/m/CAJcOf-fAdj=nDKMsRhQzndm-O13NY4dL6xGcEvdX5Xvbbi0V7g@mail.gmail.com
src/backend/rewrite/rewriteHandler.c