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

Adds a method get the underlying sqlite3 pointer #438

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sqlx-core/src/sqlite/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::sync::Arc;
use futures_core::future::BoxFuture;
use futures_util::future;
use hashbrown::HashMap;
use libsqlite3_sys::sqlite3;

use crate::connection::{Connect, Connection};
use crate::error::Error;
Expand Down Expand Up @@ -33,6 +34,13 @@ pub struct SqliteConnection {
scratch_row_column_names: Arc<HashMap<UStr, usize>>,
}

impl SqliteConnection {
/// Returns the underlying sqlite3* connection handle
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like we need to list some do-s and don't-s for this pointer but I'm not sure what those should be.

Copy link
Contributor Author

@agentsim agentsim Jun 23, 2020

Choose a reason for hiding this comment

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

The obvious two that come to mind are not to close the connection or free the pointer. I don't think the Rust docs in the standard library for similar low-level things spell out the do-s and don't-s.

pub fn as_raw_handle(&mut self) -> *mut sqlite3 {
self.handle.as_ptr()
}
}

impl Debug for SqliteConnection {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("SqliteConnection").finish()
Expand Down