Re: Proposal: Add a callback data parameter to GetNamedDSMSegment
Sami Imseih <samimseih@gmail.com>
From: Sami Imseih <samimseih@gmail.com>
To: Zsolt Parragi <zsolt.parragi@percona.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-04T16:30:38Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Allow passing a pointer to GetNamedDSMSegment()'s init callback.
- 48d4a1423d2e 19 (unreleased) landed
-
Move dynamically-allocated LWLock tranche names to shared memory.
- 38b602b0289f 19 (unreleased) cited
> struct Foo {
> LWLock lock;
> size_t size;
> Bar data[];
> };
>
> * To create a few of these, I have to provide a lock name to the
> callback, that's the "reusing the same callback" part again
> * And then there's the question of initialization. Either I leave it
> to the caller after returning from GetNamedDSHash using the lock,
"caller after returning from GetNamedDSHash" <- do you mean
GetNamedDSMSegment ?
> or somehow I have to tell the initialization callback the array size -
> even if I can calculate the size based on a GUC,
```
typedef struct Bar {
int f1;
int f2;
} Bar;
typedef struct Foo {
LWLock lock;
size_t size;
Bar data[];
} Foo;
foo_state = GetNamedDSMSegment("Foo",
offsetof(Foo, data) + BAR_ARRAY_SIZE * sizeof(int),
foo_init_state,
&found);
```
wouldn't the above be sufficient to create a DSM segment containing
a flexible array?
--
Sami Imseih
Amazon Web Services (AWS)