Add extension loading support - #1525
Open
fnc12 wants to merge 3 commits into
Open
Conversation
storage.enable_load_extension() toggles extension loading via SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, which deliberately leaves the load_extension() SQL function disabled, as recommended for security. storage.load_extension() wraps sqlite3_load_extension and surfaces its error message in the thrown std::system_error. Both are gated by SQLITE_ORM_LOAD_EXTENSION_SUPPORTED: on unless SQLite was built with SQLITE_OMIT_LOAD_EXTENSION, and off on Apple platforms, whose system SQLite strips the API from the header without defining the omit macro - building against an unrestricted SQLite there can be declared with SQLITE_ORM_ENABLE_LOAD_EXTENSION. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fnc12
marked this pull request as draft
September 7, 2026 12:57
Like the journal mode, the setting set by enable_load_extension() is now stored on the storage and re-applied to every connection it opens, so it works with on-demand connections, not only with open_forever() ones. Also cover the success path: series.c is additionally built as a run-time loadable extension (except on Apple platforms, whose system SQLite omits the loading API), and a new test loads it - with both a derived and an explicit entry point - and queries generate_series through it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The wrapper .c file tripped over the clang-format lint, whose configuration supports only C++. A subdirectory achieves the same isolation from the SQLITE_CORE source file property without it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fnc12
marked this pull request as ready for review
September 7, 2026 13:46
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.
Summary
storage.enable_load_extension(bool)— toggles extension loading throughsqlite3_db_config'sSQLITE_DBCONFIG_ENABLE_LOAD_EXTENSIONoption, which enables the C API while deliberately leaving theload_extension()SQL function disabled, as recommended for security. Returns the C API result code.storage.load_extension(file[, entryPoint])— wrapssqlite3_load_extension, propagating its error message (e.g. the dlopen failure text) in the thrownstd::system_error.No wrapper for the
load_extension()SQL function — deliberate, per the security recommendation above.Availability gate
Both wrappers sit behind a new
SQLITE_ORM_LOAD_EXTENSION_SUPPORTEDmacro infunctional/sqlite3_config.h(next toSQLITE_ORM_JSON_SUPPORTED): on unless SQLite was built withSQLITE_OMIT_LOAD_EXTENSION, and off on Apple platforms by default — Apple's system SQLite stripssqlite3_load_extensionfrom both the library and its header without defining the omit macro (while still shippingsqlite3ext.h, so no__has_includetelltale exists). Building against an unrestricted SQLite on Apple (Homebrew, vcpkg) can be declared withSQLITE_ORM_ENABLE_LOAD_EXTENSION.Testing
load extensiontest: the load of an inexistent file must fail with a translated error both with loading disabled (default) and enabled. The assertion is deliberately justREQUIRE_THROWS_AS, since Debian-family SQLite builds enable the C API by default, changing which error fires.not authorized→ enable → dlopen error propagated → disable) and Ubuntu's system SQLite on Linux.🤖 Generated with Claude Code