=== Applying patches on top of PostgreSQL commit ID 317c117d6d23cff98c1259701495422bc952a7dd === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sun Aug 31 10:09:19 UTC 2025 On branch cf/5991 nothing to commit, working tree clean === using 'git am' to apply patch ./v5-fix-variable-not-found-in-subplan-target-lists-master.patch === Patch format detection failed. === using patch(1) to apply patch ./v5-fix-variable-not-found-in-subplan-target-lists-master.patch === patching file src/backend/optimizer/plan/planner.c Hunk #1 FAILED at 8284. Hunk #2 FAILED at 8375. Hunk #3 FAILED at 8386. Hunk #4 FAILED at 8398. Hunk #5 FAILED at 8430. Hunk #6 FAILED at 8460. 6 out of 6 hunks FAILED -- saving rejects to file src/backend/optimizer/plan/planner.c.rej patching file src/test/regress/expected/aggregates.out Hunk #1 FAILED at 3398. 1 out of 1 hunk FAILED -- saving rejects to file src/test/regress/expected/aggregates.out.rej patching file src/test/regress/expected/join.out Hunk #1 succeeded at 3255 with fuzz 2 (offset 33 lines). Hunk #2 succeeded at 6536 with fuzz 2 (offset 18 lines). patching file src/test/regress/sql/aggregates.sql Hunk #1 FAILED at 1510. 1 out of 1 hunk FAILED -- saving rejects to file src/test/regress/sql/aggregates.sql.rej patching file src/test/regress/sql/join.sql Hunk #1 succeeded at 846 with fuzz 2 (offset 7 lines). Hunk #2 succeeded at 2497 (offset 70 lines). Unstaged changes after reset: M src/test/regress/expected/join.out M src/test/regress/sql/join.sql Removing src/backend/optimizer/plan/planner.c.rej Removing src/test/regress/expected/aggregates.out.rej Removing src/test/regress/sql/aggregates.sql.rej === using 'git apply' to apply patch ./v5-fix-variable-not-found-in-subplan-target-lists-master.patch === Applied patch to 'src/backend/optimizer/plan/planner.c' cleanly. Applied patch to 'src/test/regress/expected/aggregates.out' cleanly. Applied patch to 'src/test/regress/expected/join.out' with conflicts. Applied patch to 'src/test/regress/sql/aggregates.sql' cleanly. Applied patch to 'src/test/regress/sql/join.sql' with conflicts. U src/test/regress/expected/join.out U src/test/regress/sql/join.sql diff --cc src/test/regress/expected/join.out index 04079268b98,b26b8c5bdbe..00000000000 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@@ -6581,66 -6581,6 +6581,69 @@@ where exists (select 1 from t t (1 row) rollback; ++<<<<<<< ours +-- check handling of semijoins if all RHS columns are equated to constants: we +-- should suppress unique-ification in this case. +begin; +create temp table t (a int, b int); +insert into t values (1, 2); +explain (costs off) +select * from t t1, t t2 where exists + (select 1 from t t3 where t1.a = t3.a and t2.b = t3.b and t3.a = 1 and t3.b = 2); + QUERY PLAN +--------------------------------------------- + Nested Loop Semi Join + -> Nested Loop + -> Seq Scan on t t1 + Filter: (a = 1) + -> Materialize + -> Seq Scan on t t2 + Filter: (b = 2) + -> Materialize + -> Seq Scan on t t3 + Filter: ((a = 1) AND (b = 2)) +(10 rows) + +select * from t t1, t t2 where exists + (select 1 from t t3 where t1.a = t3.a and t2.b = t3.b and t3.a = 1 and t3.b = 2); + a | b | a | b +---+---+---+--- + 1 | 2 | 1 | 2 +(1 row) + +rollback; +-- check handling of semijoin unique-ification for child relations if all RHS +-- columns are equated to constants. +begin; +create temp table p (a int, b int) partition by range (a); +create temp table p1 partition of p for values from (0) to (10); +create temp table p2 partition of p for values from (10) to (20); +insert into p values (1, 2); +insert into p values (10, 20); +set enable_partitionwise_join to on; +explain (costs off) +select * from p t1 where exists + (select 1 from p t2 where t1.a = t2.a and t1.a = 1); + QUERY PLAN +------------------------------- + Nested Loop Semi Join + -> Seq Scan on p1 t1 + Filter: (a = 1) + -> Materialize + -> Seq Scan on p1 t2 + Filter: (a = 1) +(6 rows) + +select * from p t1 where exists + (select 1 from p t2 where t1.a = t2.a and t1.a = 1); + a | b +---+--- + 1 | 2 +(1 row) + +rollback; ++======= ++>>>>>>> theirs -- test cases where we can remove a join, but not a PHV computed at it begin; create temp table t (a int unique, b int); diff --cc src/test/regress/sql/join.sql index b1732453e8d,bccd171afb6..00000000000 --- a/src/test/regress/sql/join.sql +++ b/src/test/regress/sql/join.sql @@@ -2453,43 -2453,6 +2453,46 @@@ where exists (select 1 from t t rollback; ++<<<<<<< ours +-- check handling of semijoins if all RHS columns are equated to constants: we +-- should suppress unique-ification in this case. +begin; + +create temp table t (a int, b int); +insert into t values (1, 2); + +explain (costs off) +select * from t t1, t t2 where exists + (select 1 from t t3 where t1.a = t3.a and t2.b = t3.b and t3.a = 1 and t3.b = 2); + +select * from t t1, t t2 where exists + (select 1 from t t3 where t1.a = t3.a and t2.b = t3.b and t3.a = 1 and t3.b = 2); + +rollback; + +-- check handling of semijoin unique-ification for child relations if all RHS +-- columns are equated to constants. +begin; + +create temp table p (a int, b int) partition by range (a); +create temp table p1 partition of p for values from (0) to (10); +create temp table p2 partition of p for values from (10) to (20); +insert into p values (1, 2); +insert into p values (10, 20); + +set enable_partitionwise_join to on; + +explain (costs off) +select * from p t1 where exists + (select 1 from p t2 where t1.a = t2.a and t1.a = 1); + +select * from p t1 where exists + (select 1 from p t2 where t1.a = t2.a and t1.a = 1); + +rollback; + ++======= ++>>>>>>> theirs -- test cases where we can remove a join, but not a PHV computed at it begin;