mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-09 10:57:08 +02:00
Adds db/pglite, a bridge that runs the PGlite WASI build of PostgreSQL 17.5 inside the Navidrome process with wazero and exposes it to database/sql through pgx over the real wire protocol. Selected with DbPath = "pglite://<dir>". The bridge handles what the WASI build cannot do on its own: it emulates dup2 onto stdin (wazero refuses fd_renumber on preopens), replays ParameterStatus for connections after the first, synthesizes a missing ReadyForQuery after an error, recovers from the trap every PG ERROR raises, and passes wire bytes through shared wasm memory instead of files (round-trip floor 377 µs to 39 µs). Several connections are accepted and serialized onto the single backend, holding the session across a whole transaction and a whole handshake; a client that disconnects mid-transaction gets a ROLLBACK. db.go opens the pglite:// scheme, skips the SQLite-only migrations, and can apply a translated schema from ND_PGLITE_SCHEMA. The shared count() helper now adds its ORDER BY only for SQLite, since Postgres rejects it next to count(distinct ...). The wasm archive is not committed. The README explains how to build it and lists the limits found: one session, one process (DevExternalScanner must be off), shared session state, simple protocol only. |
||
|---|---|---|
| .. | ||
| migrations | ||
| pglite | ||
| backup.go | ||
| backup_test.go | ||
| db.go | ||
| db_test.go | ||
| export_test.go | ||
| optimize.go | ||
| optimize_test.go | ||