theseus-rs / postgresql-embedded

Embed PostgreSQL database
Apache License 2.0
34 stars 5 forks source link

programmatic interface to set pg config #73

Closed JimFuller-RedHat closed 3 weeks ago

JimFuller-RedHat commented 4 weeks ago

We would like to configure postgres with startup configurations, for example

shared_preload_libraries = 'pg_stat_statements

this can be achieved today by manually editing generated postgres.conf (and restart to pick up the change)... or I guess subsequent ALTER setting config (on non postmaster pg configs) or maybe we can do this today with pg_ctl reload (which I think is already supported here) ... will research.

Probably (optionally) pass a HashMap into the function and then process around https://github.com/theseus-rs/postgresql-embedded/blob/1973b5849caaf910adaf4a99e38631e024e9d5c2/postgresql_embedded/src/postgresql.rs#L257

maybe its possible to chain .options() so we can just add '-c shared_preload_libraries='pg_stat_statements' string ... though I do not know if the current pg config builder is aware enough or if we have to munge strings direct here.

alternately we could support PG native env vars (ex. PGDATA) to control this. Maybe this already works if we start up in default without passing in any settings ... will research.

The end goal is to start a pg with custom pg configurations.

brianheineman commented 3 weeks ago

Hello @JimFuller-RedHat, thank you for the feature request. From the description, it sounds like you are planning on spending some more time researching this. I put together the start of something that may meet your needs; would you mind taking a look at #74 and letting me know what your thoughts are?

JimFuller-RedHat commented 3 weeks ago

addresses perfectly ... thx ... maybe next time I will raise a PR (you were very fast!).

brianheineman commented 3 weeks ago

Please feel free to submit PRs if there are any changes / improvements you would like to see in the project

brianheineman commented 3 weeks ago

The changes for #74 have been released in version 0.10.1