Re: Fix pgstat_database.c to honor passed database OIDs

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Dapeng Wang <wangdp20191008(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix pgstat_database.c to honor passed database OIDs
Date: 2026-04-13 00:43:53
Message-ID: 9D34D3BC-9F52-489E-98BE-6CB595710446@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Apr 13, 2026, at 08:16, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> 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

Thank you very much for fixing the test and pushing the patch.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2026-04-13 00:47:00 Re: StringInfo fixes, v19 edition. Plus a few oddities
Previous Message Michael Paquier 2026-04-13 00:43:00 Re: [PATCH] Reduce pg_class scans in GRANT/REVOKE ON ALL TABLES IN SCHEMA