Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Connection::from_handle_owned #1263

Merged
merged 1 commit into from
Dec 11, 2022

Conversation

psarna
Copy link
Contributor

@psarna psarna commented Nov 29, 2022

It behaves almost the same as Connection::from_handle, but it promises to close the inner connection when the returned connection is closed or dropped.

The rationale for having this function is that some users of Connection::from_handle obtain the handle simply by calling ffi::sqlite3_open_v2 or other similar function manually, and would still like for its resources to be released once the connection is dropped.

The use-case behind this commit is from https://github.com/libsql/libsql/, where a new libsql_open function is introduced to pass other parameters (like virtual WAL interface) to the connection.

This commit comes with a simple test case loosely based on test_from_handle.

It behaves almost the same as Connection::from_handle,
but it promises to close the inner connection when
the returned connection is closed or dropped.

The rationale for having this function is that some users
of Connection::from_handle obtain the handle simply by calling
ffi::sqlite3_open_v2 or other similar function manually, and would
still like for its resources to be released once the connection
is dropped.

The use-case behind this commit is from https://github.com/libsql/libsql/,
where a new libsql_open call is introduced to pass other parameters
(like virtual WAL interface) to the connection.
Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

@gwenn gwenn merged commit a1b8342 into rusqlite:master Dec 11, 2022
gwenn added a commit to gwenn/rusqlite that referenced this pull request Dec 13, 2022
@gwenn gwenn mentioned this pull request Dec 13, 2022
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.

None yet

3 participants