aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/pgstatfuncs.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-02-26 16:48:54 +0900
committerMichael Paquier <michael@paquier.xyz>2025-02-26 16:48:54 +0900
commit0e42d31b0b2273c376ce9de946b59d155fac589c (patch)
tree87c7e5a0016d657fbc70a6d19bcce43e7fe7bf97 /src/backend/utils/adt/pgstatfuncs.c
parentd7cbeaf261da346d8c745870da1d31075ae0313c (diff)
downloadpostgresql-0e42d31b0b2273c376ce9de946b59d155fac589c.tar.gz
postgresql-0e42d31b0b2273c376ce9de946b59d155fac589c.zip
Adding new PgStat_WalCounters structure in pgstat.h
This new structure contains the counters and the data related to the WAL activity statistics gathered from WalUsage, separated into its own structure so as it can be shared across more than one Stats structure in pg_stat.h. This refactoring will be used by an upcoming patch introducing backend-level WAL statistics. Bump PGSTAT_FILE_FORMAT_ID. Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://postgr.es/m/Z3zqc4o09dM/Ezyz@ip-10-97-1-34.eu-west-3.compute.internal
Diffstat (limited to 'src/backend/utils/adt/pgstatfuncs.c')
-rw-r--r--src/backend/utils/adt/pgstatfuncs.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 68e16e52ab6..0ea41299e07 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -1643,6 +1643,7 @@ pg_stat_get_wal(PG_FUNCTION_ARGS)
bool nulls[PG_STAT_GET_WAL_COLS] = {0};
char buf[256];
PgStat_WalStats *wal_stats;
+ PgStat_WalCounters wal_counters;
/* Initialise attributes information in the tuple descriptor */
tupdesc = CreateTemplateTupleDesc(PG_STAT_GET_WAL_COLS);
@@ -1661,19 +1662,20 @@ pg_stat_get_wal(PG_FUNCTION_ARGS)
/* Get statistics about WAL activity */
wal_stats = pgstat_fetch_stat_wal();
+ wal_counters = wal_stats->wal_counters;
/* Fill values and NULLs */
- values[0] = Int64GetDatum(wal_stats->wal_records);
- values[1] = Int64GetDatum(wal_stats->wal_fpi);
+ values[0] = Int64GetDatum(wal_counters.wal_records);
+ values[1] = Int64GetDatum(wal_counters.wal_fpi);
/* Convert to numeric. */
- snprintf(buf, sizeof buf, UINT64_FORMAT, wal_stats->wal_bytes);
+ snprintf(buf, sizeof buf, UINT64_FORMAT, wal_counters.wal_bytes);
values[2] = DirectFunctionCall3(numeric_in,
CStringGetDatum(buf),
ObjectIdGetDatum(0),
Int32GetDatum(-1));
- values[3] = Int64GetDatum(wal_stats->wal_buffers_full);
+ values[3] = Int64GetDatum(wal_counters.wal_buffers_full);
values[4] = TimestampTzGetDatum(wal_stats->stat_reset_timestamp);