Skip to content

Compile SQLite with SQLITE_ENABLE_MATH_FUNCTIONS - #23

Open
louisabraham wants to merge 1 commit into
go-llsqlite:masterfrom
conception-ai:enable-math-functions
Open

louisabraham wants to merge 1 commit into
go-llsqlite:masterfrom
conception-ai:enable-math-functions

Conversation

@louisabraham

@louisabraham louisabraham commented Oct 14, 2026 •

Copy link
Copy Markdown

Adds #define SQLITE_ENABLE_MATH_FUNCTIONS 1 to c/sqlite_config.h.

Without it, sqrt(), pow(), floor(), ceil(), ln(), log10(), pi() and the rest of SQLite's math functions fail with "no such function". SQLite's own builds have them: per the compile-time options page, the configure script adds the option on Unix unless --disable-math is passed, and the Windows Makefile.msc build includes it. So SQL written against the sqlite3 shell or a system SQLite fails here.

We hit this when moving a service from zombiezen.com/go/sqlite (modernc, which has the math functions) to this package: SQL that already ran there stopped working.

The change only adds functions. An application-defined function with the same name still takes precedence, because SQLite lets sqlite3_create_function overload built-in functions.

Tests

  • TestMathFunctions checks sqrt, pow, floor, ceil, ln, log10 and pi. It fails without the define.
  • go test ./... passes.
  • CHANGELOG.md has an entry under Unreleased / Changed.

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