Re: Fix pgstat_database.c to honor passed database OIDs
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Dapeng Wang <wangdp20191008@gmail.com>
Cc: Chao Li <li.evan.chao@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2026-04-13T00:16:29Z
Lists: pgsql-hackers
On Fri, Apr 10, 2026 at 09:01:32PM +0800, Dapeng Wang wrote:
> Without the patch, calling
> pg_stat_reset_single_table_counters('pg_shdescription'::regclass)
> incorrectly updates the current database's stats_reset timestamp
> while leaving the shared db entry (datid=0) unchanged.
>
> With the patch, the shared db entry's stats_reset is correctly
> updated, and the current database's timestamp is not affected.
The coalesce() trick to bypass the fact that the reset timestamp may
not be reset was a bit ugly, so I have used instead a second reset.
I have limited the test to check for datid=0, not MyDatabaseId.
There is a bit down in stats.sql an extra portion of the test where we
use twice pg_stats_reset(). One reset could be removed, but I have
left it as-is in case someone decides to shuffle or split things in
this test script, to avoid problems in the future.
And fixed that down to v15.
--
Michael
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Honor passed-in database OIDs in pgstat_database.c
- c6d3f05851a9 15.18 landed
- c7cdcbd3e6a7 16.14 landed
- a4fefb3e0dc5 17.10 landed
- b081c5b07309 18.4 landed
- 80156cee06b9 19 (unreleased) landed