Skip to content

Explicit close#1366

Merged
jberkel merged 6 commits into
masterfrom
explicit-close
Jun 26, 2026
Merged

Explicit close#1366
jberkel merged 6 commits into
masterfrom
explicit-close

Conversation

@jberkel

@jberkel jberkel commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Based on #1361

RuiNelson and others added 6 commits May 31, 2026 00:33
Add an explicit Connection.close() API that synchronously closes the underlying sqlite3 handle and only clears it after sqlite3_close returns SQLITE_OK.

Previously Connection.deinit called sqlite3_close directly and ignored its result. If SQLite still had internal statements, BLOB handles, or backup objects alive, sqlite3_close could return SQLITE_BUSY and leave the database connection open. That made the Swift object appear destroyed while SQLite still held file descriptors, which could trigger iOS filesystem warnings when temporary database files were unlinked shortly afterwards.

The deinitializer now delegates to close(), preserving the existing automatic cleanup path while avoiding silent handle leaks when explicit close succeeds.
Add regression coverage for the explicit Connection.close() API.

The new tests verify that close() is idempotent, reports SQLITE_BUSY while a prepared statement is still active, leaves the connection usable after a failed close attempt, and succeeds once the statement has been released.
Co-authored-by: Cursor <cursoragent@cursor.com>
@jberkel jberkel merged commit ccaae3d into master Jun 26, 2026
4 checks passed
@jberkel jberkel deleted the explicit-close branch June 26, 2026 14:39
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.

2 participants