Re: Proposal: Add a callback data parameter to GetNamedDSMSegment

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal: Add a callback data parameter to GetNamedDSMSegment
Date: 2025-12-05 17:18:24
Message-ID: aTMT4GESqgbKW5Up@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 04, 2025 at 05:40:21PM +0000, Zsolt Parragi wrote:
>> wouldn't the above be sufficient to create a DSM segment containing
>> a flexible array?
>
> Yes, it creates it, but can I initialize it properly in
> foo_init_state? How can I set the size member to the proper array
> size, and how can I zero-initialize the array with the correct length
> in it? What I can do currently is:
>
> 1. create the lwlock and set size to 0 in foo_init_state
> 2. take the lwlock after GetNamedDSMSegment returns
> 3. if size is 0 set it properly and zero-initialize the array
>
> That's why I said that there is a workaround, but it would be nicer if
> I could do it properly in the init callback, by passing the array size
> as a parameter to it.

So, it seems like we've established at least 2 potential use-cases for this
argument (tranche name and flexible arrays). And the amount of extension
breakage doesn't seem too bad either. IMHO it'd be reasonable to proceed
with this change.

--
nathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-12-05 18:09:37 Re: Tighten up range checks for pg_resetwal arguments
Previous Message Heikki Linnakangas 2025-12-05 16:38:03 Re: commented out code