=== Applying patches on top of PostgreSQL commit ID bf5206f007732c64f857e6bc214f77b5f31efc6a === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Wed Jun 10 03:33:24 UTC 2026 On branch cf/6701 nothing to commit, working tree clean === using 'git am' to apply patch ./v13-0001-Require-UPDATE-permission-on-FOR-PORTION-OF-colu.patch === Applying: Require UPDATE permission on FOR PORTION OF column Using index info to reconstruct a base tree... M src/backend/parser/analyze.c M src/test/regress/expected/for_portion_of.out M src/test/regress/expected/privileges.out M src/test/regress/sql/for_portion_of.sql M src/test/regress/sql/privileges.sql Falling back to patching base and 3-way merge... Auto-merging src/test/regress/sql/for_portion_of.sql CONFLICT (content): Merge conflict in src/test/regress/sql/for_portion_of.sql Auto-merging src/test/regress/expected/for_portion_of.out CONFLICT (content): Merge conflict in src/test/regress/expected/for_portion_of.out Auto-merging src/backend/parser/analyze.c CONFLICT (content): Merge conflict in src/backend/parser/analyze.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Require UPDATE permission on FOR PORTION OF column 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 ./v13-0001-Require-UPDATE-permission-on-FOR-PORTION-OF-colu.patch === patching file src/backend/parser/analyze.c Hunk #1 succeeded at 1033 with fuzz 2 (offset -516 lines). Hunk #2 FAILED at 1599. 1 out of 2 hunks FAILED -- saving rejects to file src/backend/parser/analyze.c.rej patching file src/test/regress/expected/for_portion_of.out Hunk #1 succeeded at 1511 with fuzz 1 (offset 146 lines). Hunk #2 succeeded at 1530 with fuzz 1 (offset 149 lines). Hunk #3 FAILED at 1400. Hunk #4 FAILED at 1992. Hunk #5 FAILED at 1999. Hunk #6 FAILED at 2052. Hunk #7 FAILED at 2158. 5 out of 7 hunks FAILED -- saving rejects to file src/test/regress/expected/for_portion_of.out.rej patching file src/test/regress/expected/privileges.out Hunk #1 FAILED at 1152. 1 out of 1 hunk FAILED -- saving rejects to file src/test/regress/expected/privileges.out.rej patching file src/test/regress/sql/for_portion_of.sql Hunk #1 succeeded at 917 with fuzz 1 (offset 4 lines). Hunk #2 succeeded at 943 with fuzz 1 (offset 8 lines). Hunk #3 FAILED at 1300. Hunk #4 FAILED at 1308. Hunk #5 FAILED at 1315. Hunk #6 FAILED at 1366. Hunk #7 succeeded at 1599 with fuzz 2 (offset 193 lines). 4 out of 7 hunks FAILED -- saving rejects to file src/test/regress/sql/for_portion_of.sql.rej patching file src/test/regress/sql/privileges.sql Hunk #1 FAILED at 790. 1 out of 1 hunk FAILED -- saving rejects to file src/test/regress/sql/privileges.sql.rej Unstaged changes after reset: M src/backend/parser/analyze.c M src/test/regress/expected/for_portion_of.out M src/test/regress/sql/for_portion_of.sql Removing src/backend/parser/analyze.c.rej Removing src/test/regress/expected/for_portion_of.out.rej Removing src/test/regress/expected/privileges.out.rej Removing src/test/regress/sql/for_portion_of.sql.rej Removing src/test/regress/sql/privileges.sql.rej === using 'git apply' to apply patch ./v13-0001-Require-UPDATE-permission-on-FOR-PORTION-OF-colu.patch === Applied patch to 'src/backend/parser/analyze.c' with conflicts. Applied patch to 'src/test/regress/expected/for_portion_of.out' with conflicts. Applied patch to 'src/test/regress/expected/privileges.out' cleanly. Applied patch to 'src/test/regress/sql/for_portion_of.sql' with conflicts. Applied patch to 'src/test/regress/sql/privileges.sql' cleanly. U src/backend/parser/analyze.c U src/test/regress/expected/for_portion_of.out U src/test/regress/sql/for_portion_of.sql diff --cc src/backend/parser/analyze.c index 93fa66ae57c,03753b1c5a7..00000000000 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@@ -1601,7 -1601,7 +1601,11 @@@ transformForPortionOfClause(ParseState /* Mark the range column as requiring update permissions */ target_perminfo->updatedCols = bms_add_member(target_perminfo->updatedCols, ++<<<<<<< ours + range_attno - FirstLowInvalidHeapAttributeNumber); ++======= + range_attno - FirstLowInvalidHeapAttributeNumber); ++>>>>>>> theirs } else result->rangeTargetList = NIL; diff --cc src/test/regress/expected/for_portion_of.out index 43408972117,fe08186bc5b..00000000000 --- a/src/test/regress/expected/for_portion_of.out +++ b/src/test/regress/expected/for_portion_of.out @@@ -2036,7 -1998,7 +2036,11 @@@ SELECT * FROM for_portion_of_test2 ORDE DROP TABLE for_portion_of_test2; DROP TYPE mydaterange; -- Test FOR PORTION OF against a partitioned table. ++<<<<<<< ours +-- Include a stored generated column to test updatedCols column mapping. ++======= + -- Include a GENERATED STORED column to test updatedCols column mapping. ++>>>>>>> theirs -- temporal_partitioned_1 has the same attnums as the root -- temporal_partitioned_3 has the different attnums from the root -- temporal_partitioned_5 has the different attnums too, but reversed @@@ -2208,165 -2170,7 +2212,169 @@@ SELECT * FROM fpo_rule ORDER BY f1 (2 rows) DROP TABLE fpo_rule; ++<<<<<<< ours +-- UPDATE/DELETE FOR PORTION OF with table inheritance +-- Leftover rows must stay in the child table, preserving child-specific columns. +CREATE TABLE fpo_inh_parent ( + id int4range, + valid_at daterange, + name text +); +CREATE TABLE fpo_inh_child ( + description text +) INHERITS (fpo_inh_parent); +-- Update targets the parent; the matching row lives in the child. +INSERT INTO fpo_inh_child (id, valid_at, name, description) VALUES + ('[1,2)', '[2018-01-01,2019-01-01)', 'one', 'initial'); +UPDATE fpo_inh_parent FOR PORTION OF valid_at FROM '2018-04-01' TO '2018-10-01' + SET name = 'one^1'; +-- All three rows should be in the child, with description preserved. +SELECT tableoid::regclass, * FROM fpo_inh_parent ORDER BY valid_at; + tableoid | id | valid_at | name +---------------+-------+-------------------------+------- + fpo_inh_child | [1,2) | [2018-01-01,2018-04-01) | one + fpo_inh_child | [1,2) | [2018-04-01,2018-10-01) | one^1 + fpo_inh_child | [1,2) | [2018-10-01,2019-01-01) | one +(3 rows) + +SELECT * FROM fpo_inh_child ORDER BY valid_at; + id | valid_at | name | description +-------+-------------------------+-------+------------- + [1,2) | [2018-01-01,2018-04-01) | one | initial + [1,2) | [2018-04-01,2018-10-01) | one^1 | initial + [1,2) | [2018-10-01,2019-01-01) | one | initial +(3 rows) + +-- No rows should have leaked into the parent. +SELECT * FROM ONLY fpo_inh_parent ORDER BY valid_at; + id | valid_at | name +----+----------+------ +(0 rows) + +-- Same test for DELETE instead of UPDATE: +TRUNCATE fpo_inh_child, fpo_inh_parent; +INSERT INTO fpo_inh_child (id, valid_at, name, description) VALUES + ('[1,2)', '[2018-01-01,2019-01-01)', 'one', 'initial'); +DELETE FROM fpo_inh_parent FOR PORTION OF valid_at FROM '2018-04-01' TO '2018-10-01'; +-- Both rows should be in the child, with description preserved. +SELECT tableoid::regclass, * FROM fpo_inh_parent ORDER BY valid_at; + tableoid | id | valid_at | name +---------------+-------+-------------------------+------ + fpo_inh_child | [1,2) | [2018-01-01,2018-04-01) | one + fpo_inh_child | [1,2) | [2018-10-01,2019-01-01) | one +(2 rows) + +SELECT * FROM fpo_inh_child ORDER BY valid_at; + id | valid_at | name | description +-------+-------------------------+------+------------- + [1,2) | [2018-01-01,2018-04-01) | one | initial + [1,2) | [2018-10-01,2019-01-01) | one | initial +(2 rows) + +-- No rows should have leaked into the parent. +SELECT * FROM ONLY fpo_inh_parent ORDER BY valid_at; + id | valid_at | name +----+----------+------ +(0 rows) + +DROP TABLE fpo_inh_parent CASCADE; +NOTICE: drop cascades to table fpo_inh_child +-- UPDATE FOR PORTION OF with multiple inheritance +-- Leftover rows must stay in the child table, even if the range column's +-- attnum differs between the target parent and child. +CREATE TABLE temporal_parent ( + id int, + valid_at daterange, + name text +); +CREATE TABLE other_parent ( + prefix text, + note text +); +CREATE TABLE mi_child () INHERITS (other_parent, temporal_parent); +-- attnum of the range column is different in temporal_parent and mi_child +SELECT attnum, attname + FROM pg_attribute + WHERE attrelid = 'temporal_parent'::regclass + AND attnum > 0 AND NOT attisdropped + ORDER BY attnum; + attnum | attname +--------+---------- + 1 | id + 2 | valid_at + 3 | name +(3 rows) + +SELECT attnum, attname + FROM pg_attribute + WHERE attrelid = 'mi_child'::regclass + AND attnum > 0 AND NOT attisdropped + ORDER BY attnum; + attnum | attname +--------+---------- + 1 | prefix + 2 | note + 3 | id + 4 | valid_at + 5 | name +(5 rows) + +INSERT INTO mi_child (prefix, note, id, valid_at, name) VALUES + ('pfx', 'memo', 1, daterange('2000-01-01', '2010-01-01'), 'old'); +UPDATE temporal_parent FOR PORTION OF valid_at FROM '2001-01-01' TO '2002-01-01' + SET name = 'new' + WHERE id = 1; +SELECT tableoid::regclass, * FROM temporal_parent ORDER BY valid_at; + tableoid | id | valid_at | name +----------+----+-------------------------+------ + mi_child | 1 | [2000-01-01,2001-01-01) | old + mi_child | 1 | [2001-01-01,2002-01-01) | new + mi_child | 1 | [2002-01-01,2010-01-01) | old +(3 rows) + +SELECT * FROM mi_child ORDER BY valid_at; + prefix | note | id | valid_at | name +--------+------+----+-------------------------+------ + pfx | memo | 1 | [2000-01-01,2001-01-01) | old + pfx | memo | 1 | [2001-01-01,2002-01-01) | new + pfx | memo | 1 | [2002-01-01,2010-01-01) | old +(3 rows) + +SELECT * FROM ONLY temporal_parent ORDER BY valid_at; + id | valid_at | name +----+----------+------ +(0 rows) + +TRUNCATE mi_child, other_parent, temporal_parent; +INSERT INTO mi_child (prefix, note, id, valid_at, name) VALUES + ('pfx', 'memo', 1, daterange('2000-01-01', '2010-01-01'), 'old'); +DELETE FROM temporal_parent FOR PORTION OF valid_at FROM '2001-01-01' TO '2002-01-01' + WHERE id = 1; +SELECT tableoid::regclass, * FROM temporal_parent ORDER BY valid_at; + tableoid | id | valid_at | name +----------+----+-------------------------+------ + mi_child | 1 | [2000-01-01,2001-01-01) | old + mi_child | 1 | [2002-01-01,2010-01-01) | old +(2 rows) + +SELECT * FROM mi_child ORDER BY valid_at; + prefix | note | id | valid_at | name +--------+------+----+-------------------------+------ + pfx | memo | 1 | [2000-01-01,2001-01-01) | old + pfx | memo | 1 | [2002-01-01,2010-01-01) | old +(2 rows) + +SELECT * FROM ONLY temporal_parent ORDER BY valid_at; + id | valid_at | name +----+----------+------ +(0 rows) + +DROP TABLE temporal_parent CASCADE; +NOTICE: drop cascades to table mi_child +-- UPDATE FOR PORTION OF with generated columns ++======= + -- UPDATE FOR PORTION OF with generated stored columns ++>>>>>>> theirs -- The generated column depends on the range column, so it must be -- recomputed when FOR PORTION OF narrows the range. CREATE TABLE fpo_generated ( diff --cc src/test/regress/sql/for_portion_of.sql index 7b08f8cf45e,856e3f91291..00000000000 --- a/src/test/regress/sql/for_portion_of.sql +++ b/src/test/regress/sql/for_portion_of.sql @@@ -1338,7 -1300,7 +1338,11 @@@ DROP TABLE for_portion_of_test2 DROP TYPE mydaterange; -- Test FOR PORTION OF against a partitioned table. ++<<<<<<< ours +-- Include a stored generated column to test updatedCols column mapping. ++======= + -- Include a GENERATED STORED column to test updatedCols column mapping. ++>>>>>>> theirs -- temporal_partitioned_1 has the same attnums as the root -- temporal_partitioned_3 has the different attnums from the root -- temporal_partitioned_5 has the different attnums too, but reversed @@@ -1448,92 -1410,7 +1452,96 @@@ SELECT * FROM fpo_rule ORDER BY f1 DROP TABLE fpo_rule; ++<<<<<<< ours +-- UPDATE/DELETE FOR PORTION OF with table inheritance +-- Leftover rows must stay in the child table, preserving child-specific columns. +CREATE TABLE fpo_inh_parent ( + id int4range, + valid_at daterange, + name text +); +CREATE TABLE fpo_inh_child ( + description text +) INHERITS (fpo_inh_parent); + +-- Update targets the parent; the matching row lives in the child. +INSERT INTO fpo_inh_child (id, valid_at, name, description) VALUES + ('[1,2)', '[2018-01-01,2019-01-01)', 'one', 'initial'); +UPDATE fpo_inh_parent FOR PORTION OF valid_at FROM '2018-04-01' TO '2018-10-01' + SET name = 'one^1'; +-- All three rows should be in the child, with description preserved. +SELECT tableoid::regclass, * FROM fpo_inh_parent ORDER BY valid_at; +SELECT * FROM fpo_inh_child ORDER BY valid_at; +-- No rows should have leaked into the parent. +SELECT * FROM ONLY fpo_inh_parent ORDER BY valid_at; + +-- Same test for DELETE instead of UPDATE: +TRUNCATE fpo_inh_child, fpo_inh_parent; +INSERT INTO fpo_inh_child (id, valid_at, name, description) VALUES + ('[1,2)', '[2018-01-01,2019-01-01)', 'one', 'initial'); +DELETE FROM fpo_inh_parent FOR PORTION OF valid_at FROM '2018-04-01' TO '2018-10-01'; +-- Both rows should be in the child, with description preserved. +SELECT tableoid::regclass, * FROM fpo_inh_parent ORDER BY valid_at; +SELECT * FROM fpo_inh_child ORDER BY valid_at; +-- No rows should have leaked into the parent. +SELECT * FROM ONLY fpo_inh_parent ORDER BY valid_at; + +DROP TABLE fpo_inh_parent CASCADE; + +-- UPDATE FOR PORTION OF with multiple inheritance +-- Leftover rows must stay in the child table, even if the range column's +-- attnum differs between the target parent and child. +CREATE TABLE temporal_parent ( + id int, + valid_at daterange, + name text +); +CREATE TABLE other_parent ( + prefix text, + note text +); +CREATE TABLE mi_child () INHERITS (other_parent, temporal_parent); + +-- attnum of the range column is different in temporal_parent and mi_child +SELECT attnum, attname + FROM pg_attribute + WHERE attrelid = 'temporal_parent'::regclass + AND attnum > 0 AND NOT attisdropped + ORDER BY attnum; +SELECT attnum, attname + FROM pg_attribute + WHERE attrelid = 'mi_child'::regclass + AND attnum > 0 AND NOT attisdropped + ORDER BY attnum; + +INSERT INTO mi_child (prefix, note, id, valid_at, name) VALUES + ('pfx', 'memo', 1, daterange('2000-01-01', '2010-01-01'), 'old'); + +UPDATE temporal_parent FOR PORTION OF valid_at FROM '2001-01-01' TO '2002-01-01' + SET name = 'new' + WHERE id = 1; + +SELECT tableoid::regclass, * FROM temporal_parent ORDER BY valid_at; +SELECT * FROM mi_child ORDER BY valid_at; +SELECT * FROM ONLY temporal_parent ORDER BY valid_at; + +TRUNCATE mi_child, other_parent, temporal_parent; +INSERT INTO mi_child (prefix, note, id, valid_at, name) VALUES + ('pfx', 'memo', 1, daterange('2000-01-01', '2010-01-01'), 'old'); + +DELETE FROM temporal_parent FOR PORTION OF valid_at FROM '2001-01-01' TO '2002-01-01' + WHERE id = 1; + +SELECT tableoid::regclass, * FROM temporal_parent ORDER BY valid_at; +SELECT * FROM mi_child ORDER BY valid_at; +SELECT * FROM ONLY temporal_parent ORDER BY valid_at; + +DROP TABLE temporal_parent CASCADE; + +-- UPDATE FOR PORTION OF with generated columns ++======= + -- UPDATE FOR PORTION OF with generated stored columns ++>>>>>>> theirs -- The generated column depends on the range column, so it must be -- recomputed when FOR PORTION OF narrows the range. CREATE TABLE fpo_generated (