SQLite auto-extension support#4993
Open
LucaCappelletti94 wants to merge 4 commits intodiesel-rs:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thin wrappers around
sqlite3_auto_extension,sqlite3_cancel_auto_extension, andsqlite3_reset_auto_extension, plus anAutoExtensionEntryPointtype 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_extensionhas 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 (nodlopen).Users can already call
sqlite3_auto_extensiondirectly throughlibsqlite3-sys(orsqlite-wasm-rson 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
SqliteConnection: these are process-global, not per-connection. Matches existing patterns likediesel::pg::on_constraint. That said, associated functions onSqliteConnection(without&self) might be more discoverable for users.cancel_auto_extensionis safe: it only compares and removes a pointer from SQLite's internal list.SQLITE_OK_LOAD_PERMANENTLYmasking, NULLp_apionSQLITE_OMIT_LOAD_EXTENSIONbuilds, mutex release timing).