PG Bug reporting form <noreply@postgresql.org> writes: > My fuzzer finds a bug in Postgres 17devel, which triggers an unexpected > error "ERROR: WindowFunc not found in subplan target lists".
Thanks for the report! Bisecting says this broke at
2489d76c4906f4461a364ca8ad7e0751ead8aa0d is the first bad commit commit 2489d76c4906f4461a364ca8ad7e0751ead8aa0d Author: Tom Lane <tgl@sss.pgh.pa.us> Date: Mon Jan 30 13:16:20 2023 -0500
Make Vars be outer-join-aware.
I think this is caused by that query_tree_mutator fails to mutate runCondition for WindowClause. So when we've reduced the ref_0/ref_1 left join to inner join, we fail to remove references to this join as nulling rels in the run condition '1 >= ntile(ref_1.vkey) OVER (?)'.
I think we should also consider WindowClause->runCondition in query_tree_walker, expression_tree_mutator and expression_tree_walker. Hence, proposed the attached patch.