Skip to content

Preserve SQLITE_DETERMINISTIC when re-registering functions on Open - #39159

Merged
AndriySvyryd merged 1 commit into
dotnet:mainfrom
ilkertskn:fix/sqlite-deterministic-functions-on-open
Oct 8, 2026
Merged

AndriySvyryd merged 1 commit into
dotnet:mainfrom
ilkertskn:fix/sqlite-deterministic-functions-on-open

Conversation

@ilkertskn

Copy link
Copy Markdown
Contributor

SqliteConnection stores the flags passed to CreateFunction/CreateAggregate, but Open() re-registered them through the sqlite3_create_function overload without flags. Functions created while the connection was closed, or created while open and then re-registered after Close/Open, silently lost isDeterministic: true and could no longer be used in partial indexes, generated columns, etc.

This also affected EF Core, which registers regexp and the ef_* decimal functions and aggregates as deterministic before the connection is opened.

  • [x ] I've read the guidelines for contributing and seen the walkthrough
  • [ x] I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • [x ] The code builds and tests pass locally (also verified by our automated build checks)
  • [x ] Commit messages follow this format:
        Summary of the changes
        - Detail 1
        - Detail 2

        Fixes #bugnumber
  • [x ] Tests for the changes have been added (for bug fixes / features)
  • [x ] Code follows the same patterns and style as existing code in this repo

SqliteConnection stores the flags passed to CreateFunction/CreateAggregate,
but Open() re-registered them through the sqlite3_create_function overload
without flags. Functions created while the connection was closed, or created
while open and then re-registered after Close/Open, silently lost
isDeterministic: true and could no longer be used in partial indexes,
generated columns, etc.

This also affected EF Core, which registers regexp and the ef_* decimal
functions and aggregates as deterministic before the connection is opened.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review issues were identified.

0 open findings

What changed in this PR

Preserves SQLite function and aggregate determinism flags when connections are opened or reopened, including EF Core built-ins.

Changes:

  • Reapplies stored flags during function registration.
  • Adds regression tests for closed, reopened, and EF Core registrations.
File Description
test/​Microsoft.Data.Sqlite.Tests/​SqliteConnectionTest.cs Tests deterministic functions and aggregates.
test/​EFCore.Sqlite.Tests/​Storage/​SqliteRelationalConnectionTest.cs Verifies deterministic EF Core built-in functions.
src/​Microsoft.Data.Sqlite.Core/​SqliteConnection.cs Restores registration flags during opening.

🧠 Review effort: Lite


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@AndriySvyryd AndriySvyryd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@AndriySvyryd
AndriySvyryd merged commit 56c46b6 into dotnet:main Oct 8, 2026
20 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants