Skip to content

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

@max-kamps

Description

@max-kamps

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions