=== Applying patches on top of PostgreSQL commit ID 4244818f8add2a8ffbc89fcaa03e2871cf270ec0 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Thu Nov 26 10:50:36 UTC 2026 On branch cf/4337 nothing to commit, working tree clean === using 'git am' to apply patch ./v40-0001-Allow-to-prolong-life-span-of-transition-tables-.patch === Applying: Allow to prolong life span of transition tables until transaction end Using index info to reconstruct a base tree... M src/backend/commands/trigger.c M src/include/commands/trigger.h Falling back to patching base and 3-way merge... Auto-merging src/include/commands/trigger.h Auto-merging src/backend/commands/trigger.c CONFLICT (content): Merge conflict in src/backend/commands/trigger.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 Allow to prolong life span of transition tables until transaction end 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 ./v40-0001-Allow-to-prolong-life-span-of-transition-tables-.patch === patching file src/backend/commands/trigger.c Hunk #1 succeeded at 3856 (offset 12 lines). Hunk #2 succeeded at 3925 (offset 12 lines). Hunk #3 succeeded at 3961 (offset -1 lines). Hunk #4 succeeded at 4001 (offset -8 lines). Hunk #5 succeeded at 4896 (offset -9 lines). Hunk #6 FAILED at 5184. Hunk #7 succeeded at 5332 (offset -26 lines). Hunk #8 FAILED at 5380. 2 out of 8 hunks FAILED -- saving rejects to file src/backend/commands/trigger.c.rej patching file src/include/commands/trigger.h Hunk #1 succeeded at 262 (offset -7 lines). Unstaged changes after reset: M src/backend/commands/trigger.c M src/include/commands/trigger.h Removing src/backend/commands/trigger.c.rej === using 'git apply' to apply patch ./v40-0001-Allow-to-prolong-life-span-of-transition-tables-.patch === Applied patch to 'src/backend/commands/trigger.c' with conflicts. Applied patch to 'src/include/commands/trigger.h' cleanly. U src/backend/commands/trigger.c diff --cc src/backend/commands/trigger.c index df267427c25,dc746bccc8e..00000000000 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@@ -5126,6 -5181,10 +5172,13 @@@ AfterTriggerBeginXact(void */ afterTriggers.firing_counter = (CommandId) 1; /* mustn't be 0 */ afterTriggers.query_depth = -1; ++<<<<<<< ours ++======= + afterTriggers.firing_depth = 0; + afterTriggers.batch_callbacks = NIL; + afterTriggers.firing_batch_callbacks = false; + afterTriggers.prolonged_tuplestores = NIL; ++>>>>>>> theirs /* * Verify that there is no leftover state remaining. If these assertions @@@ -5307,6 -5380,34 +5360,37 @@@ AfterTriggerFreeQuery(AfterTriggersQuer */ qs->tables = NIL; list_free_deep(tables); ++<<<<<<< ours ++======= + + /* Release prolonged tuplestores at the end of the outmost query */ + if (afterTriggers.query_depth == 0) + { + foreach(lc, afterTriggers.prolonged_tuplestores) + { + ts = (Tuplestorestate *) lfirst(lc); + if (ts) + tuplestore_end(ts); + } + afterTriggers.prolonged_tuplestores = NIL; + } + } + + /* + * Release the tuplestore, or append it to the prolonged tuplestores list. + */ + static void + release_or_prolong_tuplestore(Tuplestorestate *ts, bool prolonged) + { + if (prolonged && afterTriggers.query_depth > 0) + { + MemoryContext oldcxt = MemoryContextSwitchTo(CurTransactionContext); + afterTriggers.prolonged_tuplestores = lappend(afterTriggers.prolonged_tuplestores, ts); + MemoryContextSwitchTo(oldcxt); + } + else + tuplestore_end(ts); ++>>>>>>> theirs }