Skip to content

Conversation

abonander
Copy link
Collaborator

@abonander abonander commented Jul 8, 2025

Changes to unreleased code (fold together with related PRs)

  • Rename config key common.drivers.sqlite.load-extensions to drivers.sqlite.unsafe-load-extensions
  • Added drivers.mysql, drivers.postgres, and support for future external drivers

Breaking Changes

  • Changed libsqlite3-sys versioning policy to use version ranges
  • Mark SqliteConnectOptions::extension() and ::extension_with_entrypoint() as unsafe
  • Added new non-default features corresponding to conditionally compiled SQLite APIs:
    • sqlite-deserialize enabling SqliteConnection::serialize() and SqliteConnection::deserialize()
    • sqlite-load-extension enabling SqliteConnectOptions::extension() and ::extension_with_entrypoint()
    • sqlite-unlock-notify enables internal use of sqlite3_unlock_notify()
  • SqliteValue and SqliteValueRef changes:
    • The sqlite3_value* interface reserves the right to be stateful. Without protection, any call could theoretically invalidate values previously returned, leading to dangling pointers.
    • SqliteValue is now !Sync and SqliteValueRef is !Send to prevent data races from concurrent accesses.
      • Instead, clone or wrap the SqliteValue in Mutex, or convert the SqliteValueRef to an owned value.
    • SqliteValue and any derived SqliteValueRefs now internally track if that value has been used to decode a borrowed &[u8] or &str and errors if it's used to decode any other type.
    • This is not expected to affect the vast majority of usages, which should only decode a single type per SqliteValue/SqliteValueRef.
    • See new docs on SqliteValue for details.
    • Considering filing a RUSTSEC advisory since the previous behavior could theoretically lead to UB in safe code, though it does require some significant contrivances to actually lead to UB.

TODO

  • sqlite3_value is not safe to access concurrently
  • SqliteValue drop internal Mutex and SqliteValue: Sync, it's largely unnecessary
  • list all the issues this fixes

Issues

fixes #3926
fixes #3921
fixes #3905

Superceded PRs

closes #3927
closes #3922
closes #3888
closes #3844

@abonander abonander changed the title WIP breaking(sqlite): libsqlite3-sys versioning, feature flags, ext… WIP breaking(sqlite): libsqlite3-sys versioning, feature flags, extension loading is unsafe Jul 8, 2025
@abonander abonander force-pushed the ab/sqlite-range branch 4 times, most recently from 104e61f to 3dd86ef Compare July 15, 2025 08:14
@abonander abonander changed the title WIP breaking(sqlite): libsqlite3-sys versioning, feature flags, extension loading is unsafe breaking(sqlite): libsqlite3-sys versioning, feature flags, extension loading is unsafe Jul 15, 2025
@abonander abonander marked this pull request as ready for review July 15, 2025 09:09
@abonander abonander changed the title breaking(sqlite): libsqlite3-sys versioning, feature flags, extension loading is unsafe breaking(sqlite): libsqlite3-sys versioning, feature flags, safety changes Jul 17, 2025
@abonander abonander force-pushed the ab/sqlite-range branch 2 times, most recently from 891a298 to 1180744 Compare July 17, 2025 07:59
@abonander abonander merged commit 21598cf into main Jul 17, 2025
92 checks passed
@abonander abonander deleted the ab/sqlite-range branch July 17, 2025 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant