=== Applying patches on top of PostgreSQL commit ID a16ef313f2c21225e89ddb9168f30601f21c7d07 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sat Jun 21 02:02:22 UTC 2025 On branch cf/5819 nothing to commit, working tree clean === using 'git am' to apply patch ./wip-fix-bug-18953.patch === Patch format detection failed. === using patch(1) to apply patch ./wip-fix-bug-18953.patch === patching file src/backend/optimizer/path/joinrels.c Hunk #1 FAILED at 1308. 1 out of 1 hunk FAILED -- saving rejects to file src/backend/optimizer/path/joinrels.c.rej patching file src/backend/optimizer/plan/createplan.c Hunk #1 FAILED at 4348. Hunk #2 FAILED at 4412. 2 out of 2 hunks FAILED -- saving rejects to file src/backend/optimizer/plan/createplan.c.rej patching file src/backend/optimizer/util/paramassign.c Hunk #1 FAILED at 600. Hunk #2 FAILED at 626. Hunk #3 FAILED at 653. 3 out of 3 hunks FAILED -- saving rejects to file src/backend/optimizer/util/paramassign.c.rej patching file src/include/optimizer/paramassign.h Hunk #1 FAILED at 30. 1 out of 1 hunk FAILED -- saving rejects to file src/include/optimizer/paramassign.h.rej patching file src/test/regress/expected/join.out Hunk #1 FAILED at 4035. 1 out of 1 hunk FAILED -- saving rejects to file src/test/regress/expected/join.out.rej patching file src/test/regress/sql/join.sql Hunk #1 succeeded at 1361 with fuzz 2 (offset 29 lines). Unstaged changes after reset: M src/test/regress/sql/join.sql Removing src/backend/optimizer/path/joinrels.c.rej Removing src/backend/optimizer/plan/createplan.c.rej Removing src/backend/optimizer/util/paramassign.c.rej Removing src/include/optimizer/paramassign.h.rej Removing src/test/regress/expected/join.out.rej === using 'git apply' to apply patch ./wip-fix-bug-18953.patch === Applied patch to 'src/backend/optimizer/path/joinrels.c' with conflicts. Applied patch to 'src/backend/optimizer/plan/createplan.c' cleanly. Applied patch to 'src/backend/optimizer/util/paramassign.c' cleanly. Applied patch to 'src/include/optimizer/paramassign.h' cleanly. Applied patch to 'src/test/regress/expected/join.out' cleanly. Applied patch to 'src/test/regress/sql/join.sql' cleanly. U src/backend/optimizer/path/joinrels.c diff --cc src/backend/optimizer/path/joinrels.c index aad41b94009,d41702cd398..00000000000 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@@ -1270,6 -1279,41 +1270,44 @@@ has_legal_joinclause(PlannerInfo *root /* ++<<<<<<< ours ++======= + * There's a pitfall for creating parameterized nestloops: suppose the inner + * rel (call it A) has a parameter that is a PlaceHolderVar, and that PHV's + * minimum eval_at set includes the outer rel (B) and some third rel (C). + * We might think we could create a B/A nestloop join that's parameterized by + * C. But we would end up with a plan in which the PHV's expression has to be + * evaluated as a nestloop parameter at the B/A join; and the executor is only + * set up to handle simple Vars as NestLoopParams. Rather than add complexity + * and overhead to the executor for such corner cases, it seems better to + * forbid the join. (Note that we can still make use of A's parameterized + * path with pre-joined B+C as the outer rel. have_join_order_restriction() + * ensures that we will consider making such a join even if there are not + * other reasons to do so.) + * + * So we check whether any PHVs used in the query could pose such a hazard. + * We don't have any simple way of checking whether a risky PHV would actually + * be used in the inner plan, and the case is so unusual that it doesn't seem + * worth working very hard on it. + * + * This needs to be checked in two places. If the inner rel's minimum + * parameterization would trigger the restriction, then join_is_legal() should + * reject the join altogether, because there will be no workable paths for it. + * But joinpath.c has to check again for every proposed nestloop path, because + * the inner path might have more than the minimum parameterization, causing + * some PHV to be dangerous for it that otherwise wouldn't be. + */ + bool + have_dangerous_phv(PlannerInfo *root, + Relids outer_relids, Relids inner_params) + { + /* OK to perform the join */ + return false; + } + + + /* ++>>>>>>> theirs * is_dummy_rel --- has relation been proven empty? */ bool