Fix setrefs.c's failure to do expression processing on prune steps.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 17 Jan 2025 01:40:07 +0000 (20:40 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 17 Jan 2025 01:40:07 +0000 (20:40 -0500)
commit45004f527afaf415f88272710883e9c473b5a2f6
tree41c872504d7458faee9c7b007a7ab8f3cce7b87d
parentc9e50ce2a04483c353bc4def378334cce9443a93
Fix setrefs.c's failure to do expression processing on prune steps.

We should run the expression subtrees of PartitionedRelPruneInfo
structs through fix_scan_expr.  Failure to do so means that
AlternativeSubPlans within those expressions won't be cleaned up
properly, resulting in "unrecognized node type" errors since v14.

It seems fairly likely that at least some of the other steps done
by fix_scan_expr are important here as well, resulting in as-yet-
undetected bugs.  Therefore, I've chosen to back-patch this to
all supported branches including v13, even though the known
symptom doesn't manifest in v13.

Per bug #18778 from Alexander Lakhin.

Discussion: https://postgr.es/m/18778-24cd399df6c806af@postgresql.org
src/backend/optimizer/plan/setrefs.c
src/test/regress/expected/partition_prune.out
src/test/regress/sql/partition_prune.sql