=== Applying patches on top of PostgreSQL commit ID 7fc2f0423320e02beb8c44b863f1827604c47c75 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Mon Nov 16 12:29:30 UTC 2026 On branch cf/7055 nothing to commit, working tree clean === using 'git am' to apply patch ./0001-Collect-ALTER-PUBLICATION-mapping-drops-for-event-tr.patch === Applying: Collect ALTER PUBLICATION mapping drops for event triggers Using index info to reconstruct a base tree... M src/backend/commands/publicationcmds.c M src/test/regress/expected/event_trigger.out M src/test/regress/sql/event_trigger.sql Falling back to patching base and 3-way merge... Auto-merging src/test/regress/sql/event_trigger.sql CONFLICT (content): Merge conflict in src/test/regress/sql/event_trigger.sql Auto-merging src/test/regress/expected/event_trigger.out CONFLICT (content): Merge conflict in src/test/regress/expected/event_trigger.out Auto-merging src/backend/commands/publicationcmds.c CONFLICT (content): Merge conflict in src/backend/commands/publicationcmds.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 Collect ALTER PUBLICATION mapping drops for event triggers 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 ./0001-Collect-ALTER-PUBLICATION-mapping-drops-for-event-tr.patch === patching file src/backend/commands/publicationcmds.c Hunk #2 succeeded at 1229 (offset -9 lines). Hunk #3 succeeded at 1237 (offset -9 lines). Hunk #4 succeeded at 1245 (offset -9 lines). Hunk #5 succeeded at 1261 (offset -9 lines). Hunk #6 succeeded at 1396 (offset -9 lines). Hunk #7 succeeded at 1408 (offset -9 lines). Hunk #8 succeeded at 1417 (offset -9 lines). Hunk #9 succeeded at 1430 (offset -9 lines). Hunk #10 succeeded at 1473 (offset -9 lines). Hunk #11 succeeded at 1489 (offset -9 lines). Hunk #12 succeeded at 1497 (offset -9 lines). Hunk #13 FAILED at 1692. Hunk #14 succeeded at 1723 with fuzz 1 (offset 5 lines). Hunk #15 succeeded at 2084 (offset 5 lines). Hunk #16 succeeded at 2124 (offset 5 lines). Hunk #17 succeeded at 2159 (offset 5 lines). Hunk #18 succeeded at 2188 (offset 5 lines). 1 out of 18 hunks FAILED -- saving rejects to file src/backend/commands/publicationcmds.c.rej patching file src/test/regress/expected/event_trigger.out Hunk #1 succeeded at 379 (offset -19 lines). Hunk #2 FAILED at 453. Hunk #3 succeeded at 576 (offset -33 lines). 1 out of 3 hunks FAILED -- saving rejects to file src/test/regress/expected/event_trigger.out.rej patching file src/test/regress/sql/event_trigger.sql Hunk #1 succeeded at 286 (offset -14 lines). Hunk #2 succeeded at 329 with fuzz 2 (offset -20 lines). Hunk #3 succeeded at 415 (offset -20 lines). Unstaged changes after reset: M src/backend/commands/publicationcmds.c M src/test/regress/expected/event_trigger.out M src/test/regress/sql/event_trigger.sql Removing src/backend/commands/publicationcmds.c.rej Removing src/test/regress/expected/event_trigger.out.rej === using 'git apply' to apply patch ./0001-Collect-ALTER-PUBLICATION-mapping-drops-for-event-tr.patch === Applied patch to 'src/backend/commands/publicationcmds.c' with conflicts. Applied patch to 'src/test/regress/expected/event_trigger.out' with conflicts. Applied patch to 'src/test/regress/sql/event_trigger.sql' with conflicts. U src/backend/commands/publicationcmds.c U src/test/regress/expected/event_trigger.out U src/test/regress/sql/event_trigger.sql diff --cc src/backend/commands/publicationcmds.c index 301050104dd,ebb7750ee30..00000000000 --- a/src/backend/commands/publicationcmds.c +++ b/src/backend/commands/publicationcmds.c @@@ -1673,54 -1684,56 +1679,77 @@@ AlterPublication(ParseState *pstate, Al aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_PUBLICATION, stmt->pubname); ++<<<<<<< ours + pubid = pubform->oid; ++======= + if (stmt->options) + AlterPublicationOptions(pstate, stmt, rel, tup); + else + { + List *relations = NIL; + List *exceptrelations = NIL; + List *schemaidlist = NIL; + Oid pubid = pubform->oid; + bool tables_dropped; + bool schemas_dropped; ++>>>>>>> theirs + /* + * Resolve publication objects to OIDs when altering the publication + * objects. + */ + if (!stmt->options) ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations, &exceptrelations, &schemaidlist); - CheckAlterPublication(stmt, tup, relations, schemaidlist); + heap_freetuple(tup); - heap_freetuple(tup); + /* + * Lock the publication while we validate and update it. This prevents + * concurrent changes to the publication's relation and schema set, such + * as adding partitioned table(s) with WHERE clause(s) and/or column + * lists, which are not allowed when not publishing via root. It also + * ensures that the publication definition does not change via SET ALL + * TABLES between the validation performed by AlterPublicationOptions() + * and the subsequent catalog update. + */ + LockDatabaseObject(PublicationRelationId, pubid, 0, + stmt->options ? AccessShareLock : AccessExclusiveLock); - /* Lock the publication so nobody else can do anything with it. */ - LockDatabaseObject(PublicationRelationId, pubid, 0, - AccessExclusiveLock); + /* + * It is possible that by the time we acquire the lock on publication, + * concurrent DDL has removed it. We can test this by checking the + * existence of publication. We get the tuple again to avoid the risk of + * any publication option getting changed. + */ + tup = SearchSysCacheCopy1(PUBLICATIONOID, ObjectIdGetDatum(pubid)); + if (!HeapTupleIsValid(tup)) + ereport(ERROR, + errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("publication \"%s\" does not exist", + stmt->pubname)); - /* - * It is possible that by the time we acquire the lock on publication, - * concurrent DDL has removed it. We can test this by checking the - * existence of publication. We get the tuple again to avoid the risk - * of any publication option getting changed. - */ - tup = SearchSysCacheCopy1(PUBLICATIONOID, ObjectIdGetDatum(pubid)); - if (!HeapTupleIsValid(tup)) - ereport(ERROR, - errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("publication \"%s\" does not exist", - stmt->pubname)); + if (stmt->options) + AlterPublicationOptions(pstate, stmt, rel, tup); + else + { + CheckAlterPublication(stmt, tup, relations, schemaidlist); relations = list_concat(relations, exceptrelations); - AlterPublicationTables(stmt, tup, relations, pstate->p_sourcetext, - schemaidlist != NIL); - AlterPublicationSchemas(stmt, tup, schemaidlist); + tables_dropped = + AlterPublicationTables(stmt, tup, relations, pstate->p_sourcetext, + schemaidlist != NIL); + schemas_dropped = AlterPublicationSchemas(stmt, tup, schemaidlist); AlterPublicationAllFlags(stmt, rel, tup); + + if (tables_dropped || schemas_dropped) + { + ObjectAddress obj; + + ObjectAddressSet(obj, PublicationRelationId, pubid); + EventTriggerCollectSimpleCommand(obj, InvalidObjectAddress, + (Node *) stmt); + } } /* Cleanup. */ diff --cc src/test/regress/expected/event_trigger.out index f57e8ffa7a5,44503e6d0bd..00000000000 --- a/src/test/regress/expected/event_trigger.out +++ b/src/test/regress/expected/event_trigger.out @@@ -412,6 -439,30 +420,33 @@@ BEGI END; $$; CREATE EVENT TRIGGER regress_event_trigger_report_end ON ddl_command_end EXECUTE PROCEDURE event_trigger_report_end(); ++<<<<<<< ours ++======= + -- GRANT/REVOKE ON PROPERTY GRAPH with pg_event_trigger_ddl_commands() + GRANT SELECT ON PROPERTY GRAPH gx TO public; + NOTICE: END: command_tag=GRANT type=PROPERTY GRAPH identity= + REVOKE SELECT ON PROPERTY GRAPH gx FROM public; + NOTICE: END: command_tag=REVOKE type=PROPERTY GRAPH identity= + DROP PROPERTY GRAPH gx; + NOTICE: NORMAL: orig=t normal=f istemp=f type=property graph identity=public.gx schema=public name=gx addr={public,gx} args={} + NOTICE: NORMAL: orig=f normal=t istemp=f type=property graph element identity=te1 of property graph public.gx schema= name= addr={public,gx,te1} args={} + DROP TABLE tv1, tv2, te1; + NOTICE: NORMAL: orig=t normal=f istemp=f type=table identity=public.te1 schema=public name=te1 addr={public,te1} args={} + NOTICE: NORMAL: orig=t normal=f istemp=f type=table identity=public.tv2 schema=public name=tv2 addr={public,tv2} args={} + NOTICE: NORMAL: orig=f normal=t istemp=f type=table constraint identity=te1_b_fkey on public.te1 schema=public name= addr={public,te1,te1_b_fkey} args={} + NOTICE: NORMAL: orig=t normal=f istemp=f type=table identity=public.tv1 schema=public name=tv1 addr={public,tv1} args={} + NOTICE: NORMAL: orig=f normal=t istemp=f type=table constraint identity=te1_a_fkey on public.te1 schema=public name= addr={public,te1,te1_a_fkey} args={} + ALTER PUBLICATION evttrig_pub DROP TABLE evttrig_pub_tbl; + NOTICE: NORMAL: orig=t normal=f istemp=f type=publication relation identity=public.evttrig_pub_tbl in publication evttrig_pub schema= name= addr={public,evttrig_pub_tbl} args={evttrig_pub} + NOTICE: END: command_tag=ALTER PUBLICATION type=publication identity=evttrig_pub + ALTER PUBLICATION evttrig_pub DROP TABLES IN SCHEMA evttrig_pub_schema; + NOTICE: NORMAL: orig=t normal=f istemp=f type=publication namespace identity=evttrig_pub_schema in publication evttrig_pub schema= name= addr={evttrig_pub_schema} args={evttrig_pub} + NOTICE: END: command_tag=ALTER PUBLICATION type=publication identity=evttrig_pub + ALTER PUBLICATION evttrig_pub SET TABLE evttrig_pub_tbl2; + NOTICE: NORMAL: orig=t normal=f istemp=f type=publication namespace identity=evttrig_pub_schema2 in publication evttrig_pub schema= name= addr={evttrig_pub_schema2} args={evttrig_pub} + NOTICE: NORMAL: orig=t normal=f istemp=f type=publication relation identity=public.evttrig_pub_tbl3 in publication evttrig_pub schema= name= addr={public,evttrig_pub_tbl3} args={evttrig_pub} + NOTICE: END: command_tag=ALTER PUBLICATION type=publication identity=evttrig_pub ++>>>>>>> theirs CREATE SCHEMA evttrig CREATE TABLE one (col_a SERIAL PRIMARY KEY, col_b text DEFAULT 'forty two', col_c SERIAL) CREATE INDEX one_idx ON one (col_b) diff --cc src/test/regress/sql/event_trigger.sql index 32e9bb58c5e,34bd0c23fa9..00000000000 --- a/src/test/regress/sql/event_trigger.sql +++ b/src/test/regress/sql/event_trigger.sql @@@ -320,6 -343,16 +329,19 @@@ END; $$ CREATE EVENT TRIGGER regress_event_trigger_report_end ON ddl_command_end EXECUTE PROCEDURE event_trigger_report_end(); ++<<<<<<< ours ++======= + -- GRANT/REVOKE ON PROPERTY GRAPH with pg_event_trigger_ddl_commands() + GRANT SELECT ON PROPERTY GRAPH gx TO public; + REVOKE SELECT ON PROPERTY GRAPH gx FROM public; + DROP PROPERTY GRAPH gx; + DROP TABLE tv1, tv2, te1; + + ALTER PUBLICATION evttrig_pub DROP TABLE evttrig_pub_tbl; + ALTER PUBLICATION evttrig_pub DROP TABLES IN SCHEMA evttrig_pub_schema; + ALTER PUBLICATION evttrig_pub SET TABLE evttrig_pub_tbl2; + ++>>>>>>> theirs CREATE SCHEMA evttrig CREATE TABLE one (col_a SERIAL PRIMARY KEY, col_b text DEFAULT 'forty two', col_c SERIAL) CREATE INDEX one_idx ON one (col_b)