Re: [PATCH] pgstat: Add helper to drop entries from a stats kind's hash

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] pgstat: Add helper to drop entries from a stats kind's hash
Date: 2026-10-30 05:09:12
Message-ID: auQmeOAPI2oXq0rZ@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Fri, Oct 30, 2026 at 10:19:15AM +0900, Michael Paquier wrote:
> On Thu, Oct 29, 2026 at 07:05:14PM -0500, Sami Imseih wrote:
> > Ok, there maybe a reason for the subset use case. v4 attached
> > does it that way.

Thanks for the new version!

> Thanks. Bertrand, what do you think?

Having a single pgstat_drop_matching_entries() makes sense and looks cleaner
than the previous design to me.

Regarding v4, just a few comments:

=== 1 (Nit)

+ * If kind is PGSTAT_KIND_INVALID, match all kinds;

while:

/* use 0 for INVALID, to catch zero-initialized data */
#define PGSTAT_KIND_INVALID 0

I wonder if a new PGSTAT_KIND_ALL wouldn't make more sense for the all kinds
case?

=== 2

Looking closely at the tests, it looks like we are not testing PGSTAT_KIND_INVALID
with a non NULL callback (means scanning all kinds and dropping only entries matching
the callback).

This is not due to this patch and looks like a past oversight: the old injection_points
test was testing pgstat_drop_matching_entries() with a non NULL callback, but
d52c24b0f80 removed that test and 31280d96a64 did not restore this case in
test_custom_stats.

Worth adding it back while at it?

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2026-10-30 05:25:12 Re: Report buffer access strategies in EXPLAIN
Previous Message Suraj Kharage 2026-10-30 04:40:09 psql: tab completion offers invalid COPY option values