diff --git a/sqlx-sqlite/src/connection/handle.rs b/sqlx-sqlite/src/connection/handle.rs index bd2bd102..aaf5b74e 100644 --- a/sqlx-sqlite/src/connection/handle.rs +++ b/sqlx-sqlite/src/connection/handle.rs @@ -15,10 +15,6 @@ use crate::{statement::unlock_notify, SqliteError}; #[derive(Debug)] pub(crate) struct ConnectionHandle(NonNull); -/// A wrapper around `ConnectionHandle` which *does not* finalize the handle on-drop. -#[derive(Clone, Debug)] -pub(crate) struct ConnectionHandleRaw(NonNull); - // A SQLite3 handle is safe to send between threads, provided not more than // one is accessing it at the same time. This is upheld as long as [SQLITE_CONFIG_MULTITHREAD] is // enabled and [SQLITE_THREADSAFE] was enabled when sqlite was compiled. We refuse to work @@ -30,9 +26,6 @@ pub(crate) struct ConnectionHandleRaw(NonNull); unsafe impl Send for ConnectionHandle {} -// SAFETY: this type does nothing but provide access to the DB handle pointer. -unsafe impl Send for ConnectionHandleRaw {} - impl ConnectionHandle { #[inline] pub(super) unsafe fn new(ptr: *mut sqlite3) -> Self { @@ -48,11 +41,6 @@ impl ConnectionHandle { self.0 } - #[inline] - pub(crate) fn to_raw(&self) -> ConnectionHandleRaw { - ConnectionHandleRaw(self.0) - } - pub(crate) fn last_insert_rowid(&mut self) -> i64 { // SAFETY: we have exclusive access to the database handle unsafe { sqlite3_last_insert_rowid(self.as_ptr()) } diff --git a/sqlx-sqlite/src/connection/mod.rs b/sqlx-sqlite/src/connection/mod.rs index 6f6d9b0c..fadc9e41 100644 --- a/sqlx-sqlite/src/connection/mod.rs +++ b/sqlx-sqlite/src/connection/mod.rs @@ -1,27 +1,27 @@ -use futures_core::future::BoxFuture; -use futures_intrusive::sync::MutexGuard; -use futures_util::future; -use libsqlite3_sys::{sqlite3, sqlite3_progress_handler}; -use sqlx_core::common::StatementCache; -use sqlx_core::error::Error; -use sqlx_core::transaction::Transaction; use std::cmp::Ordering; +use std::fmt::Write; use std::fmt::{self, Debug, Formatter}; use std::os::raw::{c_int, c_void}; use std::panic::catch_unwind; use std::ptr::NonNull; +use futures_core::future::BoxFuture; +use futures_intrusive::sync::MutexGuard; +use futures_util::future; +use libsqlite3_sys::{sqlite3, sqlite3_progress_handler}; + +pub(crate) use handle::ConnectionHandle; +use sqlx_core::common::StatementCache; +pub(crate) use sqlx_core::connection::*; +use sqlx_core::error::Error; +use sqlx_core::executor::Executor; +use sqlx_core::transaction::Transaction; + use crate::connection::establish::EstablishParams; use crate::connection::worker::ConnectionWorker; use crate::options::OptimizeOnClose; use crate::statement::VirtualStatement; use crate::{Sqlite, SqliteConnectOptions}; -use sqlx_core::executor::Executor; -use std::fmt::Write; - -pub(crate) use sqlx_core::connection::*; - -pub(crate) use handle::{ConnectionHandle, ConnectionHandleRaw}; pub(crate) mod collation; pub(crate) mod describe; diff --git a/sqlx-sqlite/src/connection/worker.rs b/sqlx-sqlite/src/connection/worker.rs index 10cb4579..18e34aae 100644 --- a/sqlx-sqlite/src/connection/worker.rs +++ b/sqlx-sqlite/src/connection/worker.rs @@ -4,21 +4,21 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::thread; -use futures_intrusive::sync::{Mutex, MutexGuard}; - use futures_channel::oneshot; +use futures_intrusive::sync::{Mutex, MutexGuard}; +use tracing::span::Span; + use sqlx_core::describe::Describe; use sqlx_core::error::Error; use sqlx_core::transaction::{ begin_ansi_transaction_sql, commit_ansi_transaction_sql, rollback_ansi_transaction_sql, }; use sqlx_core::Either; -use tracing::span::Span; use crate::connection::describe::describe; use crate::connection::establish::EstablishParams; +use crate::connection::execute; use crate::connection::ConnectionState; -use crate::connection::{execute, ConnectionHandleRaw}; use crate::{Sqlite, SqliteArguments, SqliteQueryResult, SqliteRow, SqliteStatement}; // Each SQLite connection has a dedicated thread. @@ -29,8 +29,6 @@ use crate::{Sqlite, SqliteArguments, SqliteQueryResult, SqliteRow, SqliteStateme pub(crate) struct ConnectionWorker { command_tx: flume::Sender<(Command, tracing::Span)>, - /// The `sqlite3` pointer. NOTE: access is unsynchronized! - pub(crate) _handle_raw: ConnectionHandleRaw, /// Mutex for locking access to the database. pub(crate) shared: Arc, } @@ -105,7 +103,6 @@ impl ConnectionWorker { if establish_tx .send(Ok(Self { command_tx, - _handle_raw: conn.handle.to_raw(), shared: Arc::clone(&shared), })) .is_err()