sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

SQLite: Avoid creating -wal / -shm files during proc-macro evaluation

Open max-kamps opened this issue 3 months ago • 0 comments

I have found these related issues/pull requests

Description

When using SQLx with an SQLite DATABASE_URL, the proc-macro process will create -shm and -wal files next to the database. This also happens when running under rust-analyzer. The files flickering in and out of existence are a minor annoyance. Occasionally the database is not correctly closed, which causes the files to remain indefinitely even after compilation finishes.

This can be prevented by adding ?immutable=true to the DATABASE_URL, however doing this in a .env file also causes the SQLx CLI to stop working (since it now can't mutate the database.)

Prefered solution

As far as I know, the proc-macro never needs to mutate the database, only prepare statements on it (Is that true?). As such, making the proc-macro always open SQLite databases in immutable mode would resolve this issue.

Is this a breaking change? Why or why not?

There should be no noticeable change in behavior.

max-kamps avatar Oct 17 '25 19:10 max-kamps