=== Applying patches on top of PostgreSQL commit ID 81b2179b492e3af891544813b7e22a42386b34d0 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sat Nov 14 23:00:28 UTC 2026 On branch cf/6285 nothing to commit, working tree clean === using 'git am' to apply patch ./v8-0001-postgres_fdw-show-remote-EXPLAIN-plans-via-REMOTE.patch === Applying: postgres_fdw: show remote EXPLAIN plans via REMOTE_PLANS option Using index info to reconstruct a base tree... M contrib/postgres_fdw/expected/postgres_fdw.out M contrib/postgres_fdw/option.c M contrib/postgres_fdw/postgres_fdw.c M contrib/postgres_fdw/sql/postgres_fdw.sql M doc/src/sgml/postgres-fdw.sgml M src/tools/pgindent/typedefs.list Falling back to patching base and 3-way merge... Auto-merging src/tools/pgindent/typedefs.list Auto-merging doc/src/sgml/postgres-fdw.sgml Auto-merging contrib/postgres_fdw/sql/postgres_fdw.sql CONFLICT (content): Merge conflict in contrib/postgres_fdw/sql/postgres_fdw.sql Auto-merging contrib/postgres_fdw/postgres_fdw.c Auto-merging contrib/postgres_fdw/option.c Auto-merging contrib/postgres_fdw/expected/postgres_fdw.out CONFLICT (content): Merge conflict in contrib/postgres_fdw/expected/postgres_fdw.out error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 postgres_fdw: show remote EXPLAIN plans via REMOTE_PLANS option When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v8-0001-postgres_fdw-show-remote-EXPLAIN-plans-via-REMOTE.patch === patching file contrib/postgres_fdw/Makefile patching file contrib/postgres_fdw/expected/postgres_fdw.out Hunk #1 succeeded at 455 (offset -16 lines). Hunk #2 succeeded at 660 (offset -16 lines). Hunk #3 succeeded at 855 (offset -16 lines). Hunk #4 succeeded at 5969 (offset 46 lines). Hunk #5 FAILED at 7236. Hunk #6 succeeded at 13351 (offset 17 lines). Hunk #7 succeeded at 13448 (offset 17 lines). 1 out of 7 hunks FAILED -- saving rejects to file contrib/postgres_fdw/expected/postgres_fdw.out.rej patching file contrib/postgres_fdw/expected/remote_plans_formats.out patching file contrib/postgres_fdw/meson.build patching file contrib/postgres_fdw/option.c Hunk #1 succeeded at 595 (offset 3 lines). patching file contrib/postgres_fdw/postgres_fdw.c Hunk #2 succeeded at 167 (offset 1 line). Hunk #3 succeeded at 3108 (offset 2 lines). Hunk #4 succeeded at 3232 (offset 2 lines). Hunk #5 succeeded at 3358 (offset 2 lines). Hunk #6 succeeded at 3396 (offset 2 lines). Hunk #7 succeeded at 3428 (offset 2 lines). Hunk #8 succeeded at 3444 (offset 2 lines). Hunk #9 succeeded at 3505 (offset 2 lines). Hunk #10 succeeded at 9575 (offset 41 lines). patching file contrib/postgres_fdw/postgres_fdw.h patching file contrib/postgres_fdw/sql/postgres_fdw.sql Hunk #1 succeeded at 293 (offset -18 lines). Hunk #2 succeeded at 329 (offset -18 lines). Hunk #3 succeeded at 383 (offset -18 lines). Hunk #5 FAILED at 1959. Hunk #6 succeeded at 4604 (offset -7 lines). Hunk #7 succeeded at 4628 (offset -7 lines). 1 out of 7 hunks FAILED -- saving rejects to file contrib/postgres_fdw/sql/postgres_fdw.sql.rej patching file contrib/postgres_fdw/sql/remote_plans_formats.sql patching file doc/src/sgml/postgres-fdw.sgml Hunk #1 succeeded at 1227 (offset -2 lines). patching file src/tools/pgindent/typedefs.list Hunk #1 succeeded at 2288 (offset 2 lines). Unstaged changes after reset: M contrib/postgres_fdw/Makefile M contrib/postgres_fdw/expected/postgres_fdw.out M contrib/postgres_fdw/meson.build M contrib/postgres_fdw/option.c M contrib/postgres_fdw/postgres_fdw.c M contrib/postgres_fdw/postgres_fdw.h M contrib/postgres_fdw/sql/postgres_fdw.sql M doc/src/sgml/postgres-fdw.sgml M src/tools/pgindent/typedefs.list Removing contrib/postgres_fdw/expected/postgres_fdw.out.rej Removing contrib/postgres_fdw/expected/remote_plans_formats.out Removing contrib/postgres_fdw/sql/postgres_fdw.sql.rej Removing contrib/postgres_fdw/sql/remote_plans_formats.sql === using 'git apply' to apply patch ./v8-0001-postgres_fdw-show-remote-EXPLAIN-plans-via-REMOTE.patch === Applied patch to 'contrib/postgres_fdw/Makefile' cleanly. Applied patch to 'contrib/postgres_fdw/expected/postgres_fdw.out' with conflicts. Falling back to direct application... Applied patch to 'contrib/postgres_fdw/meson.build' cleanly. Applied patch to 'contrib/postgres_fdw/option.c' cleanly. Applied patch to 'contrib/postgres_fdw/postgres_fdw.c' cleanly. Applied patch to 'contrib/postgres_fdw/postgres_fdw.h' cleanly. Applied patch to 'contrib/postgres_fdw/sql/postgres_fdw.sql' with conflicts. Falling back to direct application... Applied patch to 'doc/src/sgml/postgres-fdw.sgml' cleanly. Applied patch to 'src/tools/pgindent/typedefs.list' cleanly. U contrib/postgres_fdw/expected/postgres_fdw.out U contrib/postgres_fdw/sql/postgres_fdw.sql diff --cc contrib/postgres_fdw/expected/postgres_fdw.out index b3c73b83462,4399e18b4b4..00000000000 --- a/contrib/postgres_fdw/expected/postgres_fdw.out +++ b/contrib/postgres_fdw/expected/postgres_fdw.out @@@ -7079,6 -7179,82 +7225,85 @@@ DELETE FROM ft2 WHERE c1 = 1200 RETURNI ft2 (1 row) ++<<<<<<< ours ++======= + -- Test UPDATE FOR PORTION OF + UPDATE ft8 FOR PORTION OF c4 FROM '2005-01-01' TO '2006-01-01' + SET c2 = c2 + 1 + WHERE c1 = '[1,2)'; -- error + ERROR: foreign tables don't support FOR PORTION OF + DETAIL: "ft8" is a foreign table. + SELECT * FROM ft8 WHERE c1 = '[1,2)' ORDER BY c1, c4; + c1 | c2 | c3 | c4 + -------+----+--------+------------------------- + [1,2) | 2 | AAA001 | [01-01-2000,01-01-2020) + (1 row) + + -- Test DELETE FOR PORTION OF + DELETE FROM ft8 FOR PORTION OF c4 FROM '2005-01-01' TO '2006-01-01' + WHERE c1 = '[2,3)'; -- error + ERROR: foreign tables don't support FOR PORTION OF + DETAIL: "ft8" is a foreign table. + SELECT * FROM ft8 WHERE c1 = '[2,3)' ORDER BY c1, c4; + c1 | c2 | c3 | c4 + -------+----+--------+------------------------- + [2,3) | 3 | AAA002 | [01-01-2000,01-01-2020) + (1 row) + + -- FOR PORTION OF fails if a child partition is a foreign table, even if the + -- root is not. But a child partition that is pruned doesn't cause an error. + CREATE TABLE fpo_part_parent ( + c1 int4range NOT NULL, + c2 int NOT NULL, + c3 text, + c4 daterange NOT NULL + ) PARTITION BY LIST (c2); + CREATE TABLE fpo_part_local PARTITION OF fpo_part_parent FOR VALUES IN (1); + INSERT INTO fpo_part_local VALUES ('[1,2)', 1, 'one', '[2024-01-01,2024-12-31)'); + CREATE FOREIGN TABLE fpo_part_foreign + PARTITION OF fpo_part_parent FOR VALUES IN (6) + SERVER loopback OPTIONS (schema_name 'S 1', table_name 'T 5'); + DELETE FROM fpo_part_parent + FOR PORTION OF c4 FROM '2001-01-01' TO '2001-02-01' WHERE c2 = 6; -- error + ERROR: foreign tables don't support FOR PORTION OF + DETAIL: "fpo_part_foreign" is a foreign table. + UPDATE fpo_part_parent + FOR PORTION OF c4 FROM '2001-01-01' TO '2001-02-01' SET c3 = 'x' WHERE c2 = 6; -- error + ERROR: foreign tables don't support FOR PORTION OF + DETAIL: "fpo_part_foreign" is a foreign table. + UPDATE fpo_part_parent + FOR PORTION OF c4 FROM '2024-06-01' TO '2024-07-01' SET c3 = 'edited' WHERE c2 = 1; -- okay + DELETE FROM fpo_part_parent + FOR PORTION OF c4 FROM '2024-06-01' TO '2024-06-15' WHERE c2 = 1; -- okay + SELECT c1, c2, c3, c4 FROM fpo_part_local ORDER BY c4; + c1 | c2 | c3 | c4 + -------+----+--------+------------------------- + [1,2) | 1 | one | [01-01-2024,06-01-2024) + [1,2) | 1 | edited | [06-15-2024,07-01-2024) + [1,2) | 1 | one | [07-01-2024,12-31-2024) + (3 rows) + + DROP TABLE fpo_part_parent; + -- test write on foreign tables with REMOTE_PLANS + EXPLAIN (REMOTE_PLANS, VERBOSE, COSTS OFF) + UPDATE ft2 SET c2 = c2 + 300 WHERE c1 % 10 = 3; + QUERY PLAN + --------------------------------------------------------------------------------------- + Update on public.ft2 + Plan Node ID: 0 + -> Foreign Update on public.ft2 + Remote SQL: UPDATE "S 1"."T 1" SET c2 = (c2 + 300) WHERE ((("C 1" % 10) = 3)) + Plan Node ID: 1 + Remote Plans: + ------------- + Plan Node ID 1: + Update on "S 1"."T 1" + -> Seq Scan on "S 1"."T 1" + Output: (c2 + 300), ctid + Filter: (("T 1"."C 1" % 10) = 3) + (12 rows) + ++>>>>>>> theirs -- Test UPDATE/DELETE with RETURNING on a three-table join INSERT INTO ft2 (c1,c2,c3) SELECT id, id - 1200, to_char(id, 'FM00000') FROM generate_series(1201, 1300) id; diff --cc contrib/postgres_fdw/sql/postgres_fdw.sql index 8fc564ac37d,063d6c5f21b..00000000000 --- a/contrib/postgres_fdw/sql/postgres_fdw.sql +++ b/contrib/postgres_fdw/sql/postgres_fdw.sql @@@ -1885,6 -1925,44 +1925,47 @@@ EXPLAIN (verbose, costs off DELETE FROM ft2 WHERE c1 = 1200 RETURNING tableoid::regclass; -- can be pushed down DELETE FROM ft2 WHERE c1 = 1200 RETURNING tableoid::regclass; ++<<<<<<< ours ++======= + -- Test UPDATE FOR PORTION OF + UPDATE ft8 FOR PORTION OF c4 FROM '2005-01-01' TO '2006-01-01' + SET c2 = c2 + 1 + WHERE c1 = '[1,2)'; -- error + SELECT * FROM ft8 WHERE c1 = '[1,2)' ORDER BY c1, c4; + + -- Test DELETE FOR PORTION OF + DELETE FROM ft8 FOR PORTION OF c4 FROM '2005-01-01' TO '2006-01-01' + WHERE c1 = '[2,3)'; -- error + SELECT * FROM ft8 WHERE c1 = '[2,3)' ORDER BY c1, c4; + + -- FOR PORTION OF fails if a child partition is a foreign table, even if the + -- root is not. But a child partition that is pruned doesn't cause an error. + CREATE TABLE fpo_part_parent ( + c1 int4range NOT NULL, + c2 int NOT NULL, + c3 text, + c4 daterange NOT NULL + ) PARTITION BY LIST (c2); + CREATE TABLE fpo_part_local PARTITION OF fpo_part_parent FOR VALUES IN (1); + INSERT INTO fpo_part_local VALUES ('[1,2)', 1, 'one', '[2024-01-01,2024-12-31)'); + CREATE FOREIGN TABLE fpo_part_foreign + PARTITION OF fpo_part_parent FOR VALUES IN (6) + SERVER loopback OPTIONS (schema_name 'S 1', table_name 'T 5'); + DELETE FROM fpo_part_parent + FOR PORTION OF c4 FROM '2001-01-01' TO '2001-02-01' WHERE c2 = 6; -- error + UPDATE fpo_part_parent + FOR PORTION OF c4 FROM '2001-01-01' TO '2001-02-01' SET c3 = 'x' WHERE c2 = 6; -- error + UPDATE fpo_part_parent + FOR PORTION OF c4 FROM '2024-06-01' TO '2024-07-01' SET c3 = 'edited' WHERE c2 = 1; -- okay + DELETE FROM fpo_part_parent + FOR PORTION OF c4 FROM '2024-06-01' TO '2024-06-15' WHERE c2 = 1; -- okay + SELECT c1, c2, c3, c4 FROM fpo_part_local ORDER BY c4; + DROP TABLE fpo_part_parent; + -- test write on foreign tables with REMOTE_PLANS + EXPLAIN (REMOTE_PLANS, VERBOSE, COSTS OFF) + UPDATE ft2 SET c2 = c2 + 300 WHERE c1 % 10 = 3; + ++>>>>>>> theirs -- Test UPDATE/DELETE with RETURNING on a three-table join INSERT INTO ft2 (c1,c2,c3) SELECT id, id - 1200, to_char(id, 'FM00000') FROM generate_series(1201, 1300) id;