pgsql: Fix initialization of pg_stat_get_lastscan()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix initialization of pg_stat_get_lastscan()
Date: 2022-11-08 01:51:05
Message-ID: E1osDlY-0006K2-Lw@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix initialization of pg_stat_get_lastscan()

A NULL result should be reported when a stats timestamp is set to 0, but
c037471 missed that, leading to a confusing timestamp value after for
example a DML on a freshly-created relation with no scans done on it
yet.

This impacted the following attributes for two system views:
- pg_stat_all_tables.last_idx_scan
- pg_stat_all_tables.last_seq_scan
- pg_stat_all_indexes.last_idx_scan

Reported-by: Robert Treat
Analyzed-by: Peter Eisentraut
Author: Dave Page
Discussion: https://postgr.es/m/CABV9wwPzMfSaz3EfKXXDxKmMprbxwF5r6WPuxqA=5mzRUqfTGg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d7744d50a5394db8d973d1cfa034ed6640aec13c

Modified Files
--------------
src/backend/utils/adt/pgstatfuncs.c | 8 +++++++-
src/test/regress/expected/stats.out | 6 ++++++
src/test/regress/sql/stats.sql | 1 +
3 files changed, 14 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2022-11-08 03:24:24 pgsql: Introduce pg_pwrite_zeros() in fileutils.c
Previous Message David Rowley 2022-11-07 21:55:27 Re: pgsql: Resolve partition strategy during early parsing