Proposal: Add a callback data parameter to GetNamedDSMSegment
Zsolt Parragi <zsolt.parragi@percona.com>
From: Zsolt Parragi <zsolt.parragi@percona.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-03T18:06:51Z
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
Attachments
- 0001-Add-a-callback-data-parameter-to-GetNamedDSMSegment.patch (application/octet-stream) patch 0001
Hello hackers, While developing an extension and trying to write some generic code around DSM areas, I noticed a limitation: although GetNamedDSMSegment accepts a callback function, there is no way to pass additional arguments to that callback. For example, the documentation for creating LWLocks after startup [1] suggests creating locks in this callback. That works fine as long as the callback only needs to create a hardcoded lock. But if the lock name is a parameter to the function calling GetNamedDSMSegment, and not fixed, I do not see a clean way to pass it through to the callback (short of relying on global variables, for example). As a proper solution for this, and possibly for other similar issues, I propose adding a generic callback argument to GetNamedDSMSegment that can be forwarded to the callback function. What do you think about this? [1] https://www.postgresql.org/docs/current/xfunc-c.html#XFUNC-ADDIN-LWLOCKS-AFTER-STARTUP