=== Applying patches on top of PostgreSQL commit ID 5ffc82103773eea1ab5aa699edc301d4f03de4ce === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Mon Nov 16 03:46:28 UTC 2026 On branch cf/6619 nothing to commit, working tree clean === using 'git am' to apply patch ./v2-0001-Fix-pg_stat_xact_-views-leaking-across-xact-bound.patch === Applying: Fix pg_stat_xact_* views leaking across xact boundaries Using index info to reconstruct a base tree... M src/backend/utils/activity/pgstat.c M src/backend/utils/activity/pgstat_function.c M src/backend/utils/activity/pgstat_relation.c M src/backend/utils/activity/pgstat_xact.c M src/include/pgstat.h M src/include/utils/pgstat_internal.h M src/test/modules/test_misc/meson.build M src/tools/pgindent/typedefs.list Falling back to patching base and 3-way merge... Auto-merging src/tools/pgindent/typedefs.list Auto-merging src/test/modules/test_misc/meson.build CONFLICT (content): Merge conflict in src/test/modules/test_misc/meson.build Auto-merging src/include/utils/pgstat_internal.h Auto-merging src/include/pgstat.h CONFLICT (content): Merge conflict in src/include/pgstat.h Auto-merging src/backend/utils/activity/pgstat_xact.c Auto-merging src/backend/utils/activity/pgstat_relation.c CONFLICT (content): Merge conflict in src/backend/utils/activity/pgstat_relation.c Auto-merging src/backend/utils/activity/pgstat_function.c Auto-merging src/backend/utils/activity/pgstat.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 Fix pg_stat_xact_* views leaking across xact boundaries 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 ./v2-0001-Fix-pg_stat_xact_-views-leaking-across-xact-bound.patch === patching file src/backend/utils/activity/pgstat.c Hunk #1 succeeded at 341 (offset 15 lines). Hunk #2 succeeded at 1358 (offset 1 line). patching file src/backend/utils/activity/pgstat_function.c patching file src/backend/utils/activity/pgstat_relation.c Hunk #1 FAILED at 505. Hunk #2 succeeded at 586 with fuzz 2 (offset 61 lines). 1 out of 2 hunks FAILED -- saving rejects to file src/backend/utils/activity/pgstat_relation.c.rej patching file src/backend/utils/activity/pgstat_xact.c patching file src/include/pgstat.h Hunk #2 FAILED at 198. 1 out of 2 hunks FAILED -- saving rejects to file src/include/pgstat.h.rej patching file src/include/utils/pgstat_internal.h Hunk #1 succeeded at 707 (offset 23 lines). patching file src/test/modules/test_misc/meson.build Hunk #1 FAILED at 21. 1 out of 1 hunk FAILED -- saving rejects to file src/test/modules/test_misc/meson.build.rej patching file src/test/modules/test_misc/t/013_pgstat_xact.pl patching file src/tools/pgindent/typedefs.list Hunk #1 succeeded at 2326 with fuzz 1 (offset -4 lines). Unstaged changes after reset: M src/backend/utils/activity/pgstat.c M src/backend/utils/activity/pgstat_function.c M src/backend/utils/activity/pgstat_relation.c M src/backend/utils/activity/pgstat_xact.c M src/include/pgstat.h M src/include/utils/pgstat_internal.h M src/tools/pgindent/typedefs.list Removing src/backend/utils/activity/pgstat_relation.c.rej Removing src/include/pgstat.h.rej Removing src/test/modules/test_misc/meson.build.rej Removing src/test/modules/test_misc/t/013_pgstat_xact.pl === using 'git apply' to apply patch ./v2-0001-Fix-pg_stat_xact_-views-leaking-across-xact-bound.patch === Applied patch to 'src/backend/utils/activity/pgstat.c' cleanly. Applied patch to 'src/backend/utils/activity/pgstat_function.c' cleanly. Applied patch to 'src/backend/utils/activity/pgstat_relation.c' with conflicts. Applied patch to 'src/backend/utils/activity/pgstat_xact.c' cleanly. Applied patch to 'src/include/pgstat.h' with conflicts. Applied patch to 'src/include/utils/pgstat_internal.h' cleanly. Applied patch to 'src/test/modules/test_misc/meson.build' with conflicts. Falling back to direct application... Applied patch to 'src/tools/pgindent/typedefs.list' cleanly. U src/backend/utils/activity/pgstat_relation.c U src/include/pgstat.h U src/test/modules/test_misc/meson.build diff --cc src/backend/utils/activity/pgstat_relation.c index 82861e88e0e,0de69ef8b1d..00000000000 --- a/src/backend/utils/activity/pgstat_relation.c +++ b/src/backend/utils/activity/pgstat_relation.c @@@ -571,35 -503,48 +571,60 @@@ find_relstat_entry_kind(PgStat_Kind kin { PgStat_EntryRef *entry_ref; PgStat_TableXactStatus *trans; ++<<<<<<< ours + PgStat_RelationStatus *relentry = NULL; + PgStat_RelationStatus *relstatus = NULL; ++======= + PgStat_TableStatus *tabentry = NULL; + PgStat_TableStatus *tablestatus = NULL; + PgStat_TableCounts *baseline; ++>>>>>>> theirs - entry_ref = pgstat_fetch_pending_entry(PGSTAT_KIND_RELATION, MyDatabaseId, rel_id); + entry_ref = pgstat_fetch_pending_entry(kind, MyDatabaseId, rel_id); if (!entry_ref) { - entry_ref = pgstat_fetch_pending_entry(PGSTAT_KIND_RELATION, InvalidOid, rel_id); + entry_ref = pgstat_fetch_pending_entry(kind, InvalidOid, rel_id); if (!entry_ref) - return tablestatus; + return relstatus; } - tabentry = (PgStat_TableStatus *) entry_ref->pending; - tablestatus = palloc_object(PgStat_TableStatus); - *tablestatus = *tabentry; + relentry = (PgStat_RelationStatus *) entry_ref->pending; + relstatus = palloc_object(PgStat_RelationStatus); + *relstatus = *relentry; + + /* + * For index entries, just return the copy. There is no transactional + * data. + */ + if (kind == PGSTAT_KIND_INDEX) + return relstatus; /* - * Reset tablestatus->trans in the copy of PgStat_TableStatus as it may - * point to a shared memory area. Its data is saved below, so removing it - * does not matter. + * Reset relstatus->tab.trans in the copy of PgStat_RelationStatus as it + * may point to a shared memory area. Its data is saved below, so + * removing it does not matter. */ - tablestatus->trans = NULL; + relstatus->tab.trans = NULL; + /* + * Subtract the xact baseline to show only the current top-level + * transaction's activity. Only subtract counters exposed through + * pg_stat_xact_* views. The remaining PgStat_TableCounts fields are + * cumulative relation-maintenance state, not xact-view output. + */ + baseline = &tabentry->xact_baseline; + tablestatus->counts.numscans -= baseline->numscans; + tablestatus->counts.tuples_returned -= baseline->tuples_returned; + tablestatus->counts.tuples_fetched -= baseline->tuples_fetched; + tablestatus->counts.tuples_inserted -= baseline->tuples_inserted; + tablestatus->counts.tuples_updated -= baseline->tuples_updated; + tablestatus->counts.tuples_deleted -= baseline->tuples_deleted; + tablestatus->counts.tuples_hot_updated -= baseline->tuples_hot_updated; + tablestatus->counts.tuples_newpage_updated -= + baseline->tuples_newpage_updated; + tablestatus->counts.blocks_fetched -= baseline->blocks_fetched; + tablestatus->counts.blocks_hit -= baseline->blocks_hit; + /* * Live subtransaction counts are not included yet. This is not a hot * code path so reconcile tuples_inserted, tuples_updated and diff --cc src/include/pgstat.h index 9b99062f853,dec7fcec8e0..00000000000 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@@ -214,34 -188,19 +229,42 @@@ typedef struct PgStat_IndexCount * aborted. Hence, we also keep a stack of per-(sub)transaction status * records for every table modified in the current transaction. At commit * or abort, we propagate tuples_inserted/updated/deleted up to the - * parent subtransaction level, or out to the parent PgStat_TableStatus, + * parent subtransaction level, or out to the parent PgStat_RelationStatus, * as appropriate. + * + * 'kind' tracks the stats kind we are dealing with, for table or index + * pending data. * ---------- */ -typedef struct PgStat_TableStatus +typedef struct PgStat_RelationStatus { ++<<<<<<< ours + PgStat_Kind kind; /* PGSTAT_KIND_RELATION or PGSTAT_KIND_INDEX */ ++======= + Oid id; /* table's OID */ + bool shared; /* is it a shared catalog? */ + struct PgStat_TableXactStatus *trans; /* lowest subxact's counts */ + PgStat_TableCounts counts; /* event counts to be sent */ + PgStat_TableCounts xact_baseline; /* snapshot at xact boundary */ ++>>>>>>> theirs Relation relation; /* rel that is using this entry */ -} PgStat_TableStatus; + union + { + /* table counters */ + struct + { + Oid id; /* table's OID */ + bool shared; /* is it a shared catalog? */ + bool truncdropped; /* pending truncate/drop reset */ + struct PgStat_TableXactStatus *trans; /* lowest subxact's counts */ + PgStat_TableCounts counts; /* event counts to be sent */ + PgStat_TableCountsXact counts_xact; /* transactional counts */ + } tab; + + /* index counters */ + PgStat_IndexCounts idx; + }; +} PgStat_RelationStatus; /* ---------- * PgStat_TableXactStatus Per-table, per-subtransaction status diff --cc src/test/modules/test_misc/meson.build index 5d81f5b13be,3bc56034fc0..00000000000 --- a/src/test/modules/test_misc/meson.build +++ b/src/test/modules/test_misc/meson.build @@@ -21,9 -21,7 +21,13 @@@ tests += 't/010_index_concurrently_upsert.pl', 't/011_lock_stats.pl', 't/012_ddlutils.pl', ++<<<<<<< ours + 't/013_temp_obj_multisession.pl', + 't/014_log_statement_max_length.pl', + 't/015_temp_schema_exit_deferrable.pl', ++======= + 't/013_pgstat_xact.pl', ++>>>>>>> theirs ], # The injection points are cluster-wide, so disable installcheck 'runningcheck': false,