![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Shared-memory segment and inter-process pipe management. More...
#include "postgres.h"#include "miscadmin.h"#include "storage/ipc.h"#include "storage/lwlock.h"

Go to the source code of this file.
Classes | |
| struct | provsqlSharedState |
| Shared state stored in the PostgreSQL shared-memory segment. More... | |
Functions | |
| void | provsql_shmem_startup (void) |
| Initialise the ProvSQL shared-memory segment. | |
| Size | provsql_memsize (void) |
| Return the number of bytes required for the shared-memory segment. | |
| void | provsql_shmem_request (void) |
| Request shared memory from PostgreSQL (PG ≥ 15). | |
| void | provsql_shmem_lock_exclusive (void) |
| Acquire the ProvSQL LWLock in exclusive mode. | |
| void | provsql_shmem_lock_shared (void) |
| Acquire the ProvSQL LWLock in shared mode. | |
| void | provsql_shmem_unlock (void) |
| Release the ProvSQL LWLock. | |
Variables | |
| shmem_startup_hook_type | prev_shmem_startup |
Saved pointer to the previous shmem_startup_hook, for chaining. | |
| provsqlSharedState * | provsql_shared_state |
Pointer to the ProvSQL shared-memory segment (set in provsql_shmem_startup). | |
Shared-memory segment and inter-process pipe management.
ProvSQL uses a small PostgreSQL shared-memory segment (provsqlSharedState) to hold the file descriptors of the anonymous pipes that connect normal backends to the mmap background worker, together with a lightweight lock that serialises concurrent gate-creation requests.
This header declares:
provsqlSharedState, the layout of the shared segment.provsql_shmem_startup, provsql_shmem_request) that integrate with PostgreSQL's shared-memory lifecycle.provsql_shmem_lock_exclusive, etc.) around the embedded LWLock.Definition in file provsql_shmem.h.
| Size provsql_memsize | ( | void | ) |
Return the number of bytes required for the shared-memory segment.
Used by PostgreSQL's shared-memory allocator during startup.
provsqlSharedState structure. Definition at line 69 of file provsql_shmem.c.

| void provsql_shmem_lock_exclusive | ( | void | ) |
Acquire the ProvSQL LWLock in exclusive mode.
Callers must pair this with provsql_shmem_unlock().
Definition at line 86 of file provsql_shmem.c.

| void provsql_shmem_lock_shared | ( | void | ) |
Acquire the ProvSQL LWLock in shared mode.
Multiple backends may hold the shared lock simultaneously. Callers must pair this with provsql_shmem_unlock().
Definition at line 91 of file provsql_shmem.c.

| void provsql_shmem_request | ( | void | ) |
Request shared memory from PostgreSQL (PG ≥ 15).
Called from the shmem_request_hook (introduced in PostgreSQL 15) to reserve the segment before shared memory is finalised. Chains to prev_shmem_request if set. On older PostgreSQL versions this is a no-op because memory reservation happened in _PG_init().
Definition at line 74 of file provsql_shmem.c.


| void provsql_shmem_startup | ( | void | ) |
Initialise the ProvSQL shared-memory segment.
Called from the shmem_startup_hook. Creates (or attaches to) the provsqlSharedState segment and initialises the embedded LWLock and pipe file descriptors. Chains to prev_shmem_startup if set.
Definition at line 31 of file provsql_shmem.c.

| void provsql_shmem_unlock | ( | void | ) |
Release the ProvSQL LWLock.
Must be called after provsql_shmem_lock_exclusive() or provsql_shmem_lock_shared().
Definition at line 96 of file provsql_shmem.c.

|
extern |
Saved pointer to the previous shmem_startup_hook, for chaining.
Definition at line 24 of file provsql_shmem.c.
|
extern |
Pointer to the ProvSQL shared-memory segment (set in provsql_shmem_startup).
Definition at line 29 of file provsql_shmem.c.