fix(sqlite): delete unused ConnectionHandleRaw type (#3146)

This commit is contained in:
Austin Bonander 2024-03-22 22:15:37 -07:00 committed by GitHub
parent 0b91ea68e5
commit 59d5ba606e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 32 deletions

View file

@ -15,10 +15,6 @@ use crate::{statement::unlock_notify, SqliteError};
#[derive(Debug)]
pub(crate) struct ConnectionHandle(NonNull<sqlite3>);
/// A wrapper around `ConnectionHandle` which *does not* finalize the handle on-drop.
#[derive(Clone, Debug)]
pub(crate) struct ConnectionHandleRaw(NonNull<sqlite3>);
// 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<sqlite3>);
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()) }

View file

@ -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;

View file

@ -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<WorkerSharedState>,
}
@ -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()