Re: Fix pgstat_database.c to honor passed database OIDs

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix pgstat_database.c to honor passed database OIDs
Date: 2026-04-10 06:12:41
Message-ID: adiU2YZ0auyO6jie@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Apr 10, 2026 at 01:53:15PM +0800, Chao Li wrote:
> For pgstat_reset_database_timestamp(), in most paths dboid is also
> just MyDatabaseId. However, there is one path where dboid can be
> InvalidOid:

The call of pgstat_reset_database_timestamp() in pgstat_reset() is a
bug that has to be backpatched down to v15. It does not make sense to
let a caller of pgstat_reset() pass down a custom dboid and then
decide to reset the timestamp of MyDatabaseId instead. The call of
pgstat_reset() in pgstat_create_transactional() is the only fishy one,
the other callers are OK.

If we decide to expand pgstat_reset() in other contexts in the
back-branches, we'd be silently trapped as well.

The connect and disconnect calls are less critical, perhaps we could
remove the argument altogether, but I cannot get excited about that
either as some extensions may rely on these as currently designed.

I cannot look at that today, will do so later..
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Xuneng Zhou 2026-04-10 06:13:05 Re: Implement waiting for wal lsn replay: reloaded
Previous Message vignesh C 2026-04-10 06:11:35 Use XLogRecPtrIsValid() instead of negated XLogRecPtrIsInvalid