Re: [Proposal] Adding callback support for custom statistics kinds

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Sami Imseih <samimseih(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [Proposal] Adding callback support for custom statistics kinds
Date: 2025-12-17 07:03:36
Message-ID: d87a93b0-19c7-4db6-b9c0-d6827e7b2da1@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 13.12.25 01:41, Sami Imseih wrote:
> Thanks for the updates!
>
>> - Less fwrite() and fread(), more read_chunk() and write_chunk(). We
>> are exposing these APIs, let's use them.
>
> oops. That totally slipped my mind :( sorry about that.
>
>> - The callbacks are renamed, to be more generic: "finish" for the
>> end-of-operation actions and to/from_serialized_data.
>
> At first I wasn’t a fan of the name “finish” for the callback.
> I was thinking of calling it “finish_auxiliary”. But, we’re not
> forcing callbacks to be used together, and there could perhaps
> be cases where “finish" can be used on its own, so this is fine by me.
>
> I made some changes as well, in v8:
>
> 1/ looks like b4cbc106a6ce snuck into v7. I fixed that.
>
> 2/ After looking this over, I realized that “extra” and “auxiliary”
> were being used interchangeably. To avoid confusion, I replaced all
> instances of “extra” with “auxiliary" in both the comments and
> macros, i.e. TEST_CUSTOM_AUX_DATA_DESC

The function test_custom_stats_var_from_serialized_data() takes an
argument of type

const PgStatShared_Common *header

which is then later cast

entry = (PgStatShared_CustomVarEntry *) header;

where entry is defined as

PgStatShared_CustomVarEntry *entry;

So you are losing the const qualification here.

But fixing that by adding the const qualification to entry would not
work because what entry points to is later modified:

entry->description = InvalidDsaPointer;

So the header argument of the function should not be const qualified.

But the signature of that function is apparently determined by this new
callbacks API, so it cannot be changed in isolation.

So it seems to me that either the callbacks API needs some adjustments,
or this particular implementation of the callback function is incorrect.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-12-17 07:07:14 Re: Replace is_publishable_class() with relispublishable column in pg_class
Previous Message Rahila Syed 2025-12-17 06:57:46 Re: Segmentation fault on proc exit after dshash_find_or_insert