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:58:15 +0000 (11:58 -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-patch to v16 where that came in.

Bertrand Drouvot

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

src/backend/utils/adt/pgstatfuncs.c

index 68ecd3bc66ba9889d677f4e616d48f2169d9827c..05e7a048075c8091da77c112e5e68c741b67d81e 100644 (file)
@@ -1402,7 +1402,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