Skip to content

refactor(ios): run SQLite on the Mac plugin's driver - #4405

Merged
datlechin merged 4 commits into
mainfrom
refactor/ios-sqlite-plugin
Nov 21, 2026
Merged

datlechin merged 4 commits into
mainfrom
refactor/ios-sqlite-plugin

Conversation

@datlechin

@datlechin datlechin commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

  • iOS runs SQLite on the Mac plugin's SQLitePluginDriver behind PluginBackedDriver (SQLiteBackedDriver), compiled as a source path like DuckDB, D1, ClickHouse and MongoDB. The hand-written SQLiteDriver.swift and SQLiteTransferEngine.swift are gone; exports ask the plugin through PluginTransferCatalog, imports write through PluginWriteDialect.
  • iOS links the SDK's SQLite: the plugin and TableProSQLiteCore import SQLite3 under #if os(iOS) and CSQLite on macOS, whose dependency becomes macOS-only. SwiftLint's vendored_sqlite_import allows exactly that import. Extension loading and the SSH agent backend stay on the Mac.
  • SQLiteBackedDriver keeps the iOS file handling: app, picked and in-memory files, no create for an existing file, read-only readers, a WAL reader or VACUUM INTO snapshot for a transfer, leftover snapshots swept at launch, access ended after SQLite closed the file, a 5 s lock wait unless the connection sets a timeout, the rowid alias shown as auto-increment, a typeless all-blob column typed BLOB.
  • Plugin: SQLiteLocalBackend takes open flags; a failed open closes its handle.
  • Plugin: a grid read hands each value to a reader in place (readValues), so long text is copied up to its preview and a BLOB only counted. iOS cuts with PluginGridCut, now shared with DuckDB.
  • Plugin: an export on the session reads a batch per pull with the statement held between pulls (pulledRows), so the grid's statements run in between, as before on iOS.
  • Plugin: Stop interrupts a request only while it runs, a pulled read only while it steps; a statement whose caller was cancelled before the connection took it runs nothing. An interrupt left in effect by an open read ends that read, so the user's next write in a transaction is not interrupted and rolled back, and query_only is restored.
  • Plugin: an empty binary value binds an empty blob instead of NULL; a value list that does not match the placeholders is refused; text of only comments runs as an empty result.
  • Import: a driver that cannot name its database (SQLite, D1, DuckDB through PluginBackedDriver) leaves the window's database to compare, so an import whose session moved is still refused.
  • On purpose, iOS now does what the Mac does: a text of several statements is refused, execute spells a BLOB in hex, columns list generated columns, defaults read as the Mac shows them.
  • Tests rewritten for the new driver, behavior kept: SQLiteDriverFileTests (SQLiteInterruptHandleTests, which pinned the native interrupt handle, replaced by Stop, cap, cut and refusal cases in SQLiteBackedDriverTests), SQLiteTransferEngineTests, ExportTwinNameTests, IOSDriverFactoryLocalFileTests, DuckDBGridDecodeTests (rename), and the callers that built SQLiteDriver.
  • New plugin tests: SQLiteLocalBackendTests (binding, comment-only text, open flags, value reads, pulled reads, Stop beside an open read).

Refs #4272 (IO-09, second of seven engines).

Test plan

  • SQLiteBindingTests fails on main: an empty blob reads back as NULL, a short value list writes NULL.
  • verify.sh ios with the SQLite, transfer, import, factory and DuckDB suites.
  • verify.sh test SQLiteDriverTests and verify.sh plugins.

@datlechin
datlechin enabled auto-merge (squash) November 21, 2026 20:13
@datlechin
datlechin merged commit 6a929cc into main Nov 21, 2026
47 checks passed
@datlechin
datlechin deleted the refactor/ios-sqlite-plugin branch November 22, 2026 00:15
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