Remix.run Logo
deivid 2 days ago

Building postgres server as a library. Some early success, but initdb and in-process restarts are much harder than expected

mysfi 2 days ago | parent [-]

Do you mind elaborating more about the use case? Postgres itself is heavily engineered around OS process boundaries for both correctness and resiliency.

deivid a day ago | parent [-]

I'm not sure it'll be a serious project, but the main goal is to use it in CI or dev, where setting up postgres is kind of a pain.

I got it to work already by setting up the global context in single-user mode (like postgres --single) and exposing bindings for SPI operations.

Yesterday night I got extensions working, but as this project builds as a static archive, the extensions also have to be part of the build. Both plpgsql and pgvector worked fine.

The bigger challenge is dealing with global state -- comparing the pre-start and post-shutdown state of the process memory, about 200 globals change state. Been slowly making progress to get restarts working