Fix incorrect pg_stat_io output on 32-bit machines.
authorTom Lane <[email protected]>
Fri, 6 Sep 2024 15:57:57 +0000 (11:57 -0400)
committerTom Lane <[email protected]>
Fri, 6 Sep 2024 15:57:57 +0000 (11:57 -0400)
pg_stat_get_io() applied TimestampTzGetDatum twice to the
stat_reset_timestamp value.  On 64-bit builds that's harmless because
TimestampTzGetDatum is a no-op, but on 32-bit builds it results in
displaying garbage in the stats_reset column of the pg_stat_io view.

Bug dates to commit a9c70b46d which introduced pg_stat_io, so
back- to v16 where that came in.

Bertrand Drouvot

Discussion: https://postgr.es/m/[email protected]

src/backend/utils/adt/pgstatfuncs.c

index 97dc09ac0d919dc79ba86580898676eff7377c63..33c7b25560b4e702fa20292ba4818a3bd16c8fb1 100644 (file)
@@ -1408,7 +1408,7 @@ pg_stat_get_io(PG_FUNCTION_ARGS)
                values[IO_COL_BACKEND_TYPE] = bktype_desc;
                values[IO_COL_CONTEXT] = CStringGetTextDatum(context_name);
                values[IO_COL_OBJECT] = CStringGetTextDatum(obj_name);
-               values[IO_COL_RESET_TIME] = TimestampTzGetDatum(reset_time);
+               values[IO_COL_RESET_TIME] = reset_time;
 
                /*
                 * Hard-code this to the value of BLCKSZ for now. Future