Skip to content

Expand C API coverage: reset/backup/blob I/O/error reporting#5

Merged
colemancda merged 12 commits into
masterfrom
feature/expand-c-api-coverage
Jul 18, 2026
Merged

Expand C API coverage: reset/backup/blob I/O/error reporting#5
colemancda merged 12 commits into
masterfrom
feature/expand-c-api-coverage

Conversation

@colemancda

@colemancda colemancda commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

  • Add sqlite3_reset, sqlite3_clear_bindings, and sqlite3_expanded_sql to Statement, allowing prepared statements to be reused instead of only finalized.
  • Let custom scalar and aggregate functions report failures back to SQLite via sqlite3_result_error (block/final closures can now throw).
  • Switch Connection's close path to sqlite3_close_v2 and add sqlite3_get_autocommit, sqlite3_busy_timeout, and sqlite3_interrupt wrappers.
  • Add an IncrementalBlob wrapper around the incremental BLOB I/O API (sqlite3_blob_open/read/write/bytes/close/reopen).
  • Add a Backup wrapper around the online backup API (sqlite3_backup_init/step/finish/remaining/pagecount).
  • Add WAL support: Connection.journalMode / setJournalMode(_:) (via PRAGMA journal_mode, since there's no dedicated C API for it) and walCheckpoint(mode:database:) / setWALAutoCheckpoint(pageCount:) wrapping sqlite3_wal_checkpoint_v2 / sqlite3_wal_autocheckpoint.

Out of scope for this PR: sqlite3_exec (redundant with the existing Connection.run convenience), and update/commit/rollback hooks (sqlite3_update_hook, etc.) — those need a retained callback box tied to Connection's lifetime, which the current struct doesn't have room for without a larger design change. sqlite3_wal_hook falls in the same bucket and is likewise deferred.

Test plan

  • swift test — 124 tests pass, including new suites IncrementalBlobTests, BackupTests, and WALTests, and new cases in ConnectionStatementTests / FunctionEdgeCaseTests.

@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Swift

Swift / code-coverage/llvm-cov

The overall coverage in the branch is 96%. The coverage in the branch is 97%.

Show a code coverage summary of the most impacted files.
File 248ab01 7b2b849 +/-
Sources/SQLite/Statement.swift 97% 94% -3%
Sources/SQLite/...onnection.swift 96% 96% 0%
Sources/SQLite/Function.swift 98% 98% 0%
Sources/SQLite/...eFunction.swift 87% 88% +1%
Sources/SQLite/Backup.swift 0% 85% +85%
Sources/SQLite/WAL.swift 0% 88% +88%
Sources/SQLite/...entalBlob.swift 0% 96% +96%

Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@colemancda
colemancda merged commit 19b9b5a into master Jul 18, 2026
5 checks passed
@colemancda
colemancda deleted the feature/expand-c-api-coverage branch July 18, 2026 02:24
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