![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
File-backed memory region with two interchangeable backends. More...
#include <cerrno>#include <cstddef>#include <cstdlib>#include <cstring>#include <stdexcept>#include <string>#include <fcntl.h>#include <unistd.h>#include "provsql_config.h"#include <sys/mman.h>

Go to the source code of this file.
Classes | |
| class | MappedRegion |
Functions | |
| static int | provsql_fdatasync (int fd) |
| Push a file's dirty data pages to stable storage. | |
File-backed memory region with two interchangeable backends.
A MappedRegion owns a backing file and a base pointer to length() bytes of it, with map() / remap() / sync() / close(). It is the single storage primitive under MMappedVector and MMappedUUIDHashTable.
Multi-process build: the region is a shared (MAP_SHARED) mmap of the file. The kernel keeps the mapping coherent across the backends and the worker and flushes dirty pages, so a backend's writes are visible to the others through the same file.
Single-process build (PROVSQL_INPROCESS_STORE): the region is a heap buffer loaded from the file on map() and written back explicitly on sync() / close(). Emscripten does not support MAP_SHARED write-back, and with a single process a shared mapping has no purpose; the file still lives under $PGDATA, so PGlite persists it. Write-back timing is the caller's responsibility (the store registers an on_proc_exit hook so a backend flushes before it exits).
Definition in file MappedRegion.h.
|
inlinestatic |
Push a file's dirty data pages to stable storage.
fdatasync where the platform has it; macOS does not declare it, and its fsync only reaches the drive's cache, so there the F_FULLFSYNC fcntl (what PostgreSQL itself issues) is the durable barrier, with fsync as the fallback on file systems that reject it.
errno set otherwise. Definition at line 51 of file MappedRegion.h.
