Skip to content

sqlite3_sqlean_init: load define last - #162

Merged
nalgeon merged 1 commit into
nalgeon:mainfrom
DragonRulerX:jhinze/fix-module-load-ordering
Jun 11, 2026
Merged

sqlite3_sqlean_init: load define last#162
nalgeon merged 1 commit into
nalgeon:mainfrom
DragonRulerX:jhinze/fix-module-load-ordering

Conversation

@DragonRulerX

Copy link
Copy Markdown
Contributor

Fixes #161

Move define_init to after all other extension inits so that every sqlean function is already registered when define_load prepares the stored UDF bodies within the sqlean_define table.

define_init calls define_load which prepares every stored UDF body as a
SQLite statement. If a UDF body references a sqlean function (e.g.
uuid_str) that has not yet been registered, sqlite3_prepare_v3 fails
with SQLITE_ERROR and the error is emitted to the global SQLite log.
The failure is silently swallowed by define_load (it returns
sqlite3_finalize rather than the error code), so sqlite3_load_extension
still succeeds, but the UDF is not registered and must be re-run via
functions.sql on first open.

Move define_init to after all other extension inits so that every
sqlean function is already registered when define_load prepares the
stored UDF bodies. Add a comment explaining the ordering constraint.
@DragonRulerX
DragonRulerX force-pushed the jhinze/fix-module-load-ordering branch from b13d32e to 4f2b8f0 Compare June 10, 2026 21:50
@nalgeon
nalgeon merged commit 61cc75c into nalgeon:main Jun 11, 2026
3 checks passed
@nalgeon

nalgeon commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Thank you!

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.

Bug: Load the "define" module last

2 participants