Skip to content

SQLite auto-extension support#4993

Open
LucaCappelletti94 wants to merge 4 commits intodiesel-rs:mainfrom
LucaCappelletti94:sqlite3_auto_extension
Open

SQLite auto-extension support#4993
LucaCappelletti94 wants to merge 4 commits intodiesel-rs:mainfrom
LucaCappelletti94:sqlite3_auto_extension

Conversation

@LucaCappelletti94
Copy link
Contributor

Thin wrappers around sqlite3_auto_extension, sqlite3_cancel_auto_extension, and sqlite3_reset_auto_extension, plus an AutoExtensionEntryPoint type alias for the entry point signature.

These let users register statically-linked SQLite extensions (e.g. Spatialite, sqlite-vec) that run automatically for every new connection. sqlite3_auto_extension has been part of core SQLite since 3.3.8 (2006) and is the standard mechanism for extensions compiled into the binary and the only option on WASM (no dlopen).

Users can already call sqlite3_auto_extension directly through libsqlite3-sys (or sqlite-wasm-rs on WASM), but getting the types and safety invariants right is fiddly. These wrappers provide a typed signature, proper error mapping, and documented safety requirements so users don't have to piece it together from the SQLite C docs.

Design

  • Free functions, not methods on SqliteConnection: these are process-global, not per-connection. Matches existing patterns like diesel::pg::on_constraint. That said, associated functions on SqliteConnection (without &self) might be more discoverable for users.
  • cancel_auto_extension is safe: it only compares and removes a pointer from SQLite's internal list.
  • Docs include verified source links for non-obvious SQLite behaviors (SQLITE_OK_LOAD_PERMANENTLY masking, NULL p_api on SQLITE_OMIT_LOAD_EXTENSION builds, mutex release timing).

@LucaCappelletti94 LucaCappelletti94 marked this pull request as ready for review February 28, 2026 19:52
@weiznich weiznich requested a review from a team March 1, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant