Skip to content

Commit 59d5ba6

Browse files
authored
fix(sqlite): delete unused ConnectionHandleRaw type (#3146)
1 parent 0b91ea6 commit 59d5ba6

File tree

3 files changed

+14
-29
lines changed

3 files changed

+14
-29
lines changed

sqlx-sqlite/src/connection/handle.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ use crate::{statement::unlock_notify, SqliteError};
1515
#[derive(Debug)]
1616
pub(crate) struct ConnectionHandle(NonNull<sqlite3>);
1717

18-
/// A wrapper around `ConnectionHandle` which *does not* finalize the handle on-drop.
19-
#[derive(Clone, Debug)]
20-
pub(crate) struct ConnectionHandleRaw(NonNull<sqlite3>);
21-
2218
// A SQLite3 handle is safe to send between threads, provided not more than
2319
// one is accessing it at the same time. This is upheld as long as [SQLITE_CONFIG_MULTITHREAD] is
2420
// enabled and [SQLITE_THREADSAFE] was enabled when sqlite was compiled. We refuse to work
@@ -30,9 +26,6 @@ pub(crate) struct ConnectionHandleRaw(NonNull<sqlite3>);
3026

3127
unsafe impl Send for ConnectionHandle {}
3228

33-
// SAFETY: this type does nothing but provide access to the DB handle pointer.
34-
unsafe impl Send for ConnectionHandleRaw {}
35-
3629
impl ConnectionHandle {
3730
#[inline]
3831
pub(super) unsafe fn new(ptr: *mut sqlite3) -> Self {
@@ -48,11 +41,6 @@ impl ConnectionHandle {
4841
self.0
4942
}
5043

51-
#[inline]
52-
pub(crate) fn to_raw(&self) -> ConnectionHandleRaw {
53-
ConnectionHandleRaw(self.0)
54-
}
55-
5644
pub(crate) fn last_insert_rowid(&mut self) -> i64 {
5745
// SAFETY: we have exclusive access to the database handle
5846
unsafe { sqlite3_last_insert_rowid(self.as_ptr()) }

sqlx-sqlite/src/connection/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1+
use std::cmp::Ordering;
2+
use std::fmt::Write;
3+
use std::fmt::{self, Debug, Formatter};
4+
use std::os::raw::{c_int, c_void};
5+
use std::panic::catch_unwind;
6+
use std::ptr::NonNull;
7+
18
use futures_core::future::BoxFuture;
29
use futures_intrusive::sync::MutexGuard;
310
use futures_util::future;
411
use libsqlite3_sys::{sqlite3, sqlite3_progress_handler};
12+
13+
pub(crate) use handle::ConnectionHandle;
514
use sqlx_core::common::StatementCache;
15+
pub(crate) use sqlx_core::connection::*;
616
use sqlx_core::error::Error;
17+
use sqlx_core::executor::Executor;
718
use sqlx_core::transaction::Transaction;
8-
use std::cmp::Ordering;
9-
use std::fmt::{self, Debug, Formatter};
10-
use std::os::raw::{c_int, c_void};
11-
use std::panic::catch_unwind;
12-
use std::ptr::NonNull;
1319

1420
use crate::connection::establish::EstablishParams;
1521
use crate::connection::worker::ConnectionWorker;
1622
use crate::options::OptimizeOnClose;
1723
use crate::statement::VirtualStatement;
1824
use crate::{Sqlite, SqliteConnectOptions};
19-
use sqlx_core::executor::Executor;
20-
use std::fmt::Write;
21-
22-
pub(crate) use sqlx_core::connection::*;
23-
24-
pub(crate) use handle::{ConnectionHandle, ConnectionHandleRaw};
2525

2626
pub(crate) mod collation;
2727
pub(crate) mod describe;

sqlx-sqlite/src/connection/worker.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ use std::sync::atomic::{AtomicUsize, Ordering};
44
use std::sync::Arc;
55
use std::thread;
66

7+
use futures_channel::oneshot;
78
use futures_intrusive::sync::{Mutex, MutexGuard};
9+
use tracing::span::Span;
810

9-
use futures_channel::oneshot;
1011
use sqlx_core::describe::Describe;
1112
use sqlx_core::error::Error;
1213
use sqlx_core::transaction::{
1314
begin_ansi_transaction_sql, commit_ansi_transaction_sql, rollback_ansi_transaction_sql,
1415
};
1516
use sqlx_core::Either;
16-
use tracing::span::Span;
1717

1818
use crate::connection::describe::describe;
1919
use crate::connection::establish::EstablishParams;
20+
use crate::connection::execute;
2021
use crate::connection::ConnectionState;
21-
use crate::connection::{execute, ConnectionHandleRaw};
2222
use crate::{Sqlite, SqliteArguments, SqliteQueryResult, SqliteRow, SqliteStatement};
2323

2424
// Each SQLite connection has a dedicated thread.
@@ -29,8 +29,6 @@ use crate::{Sqlite, SqliteArguments, SqliteQueryResult, SqliteRow, SqliteStateme
2929

3030
pub(crate) struct ConnectionWorker {
3131
command_tx: flume::Sender<(Command, tracing::Span)>,
32-
/// The `sqlite3` pointer. NOTE: access is unsynchronized!
33-
pub(crate) _handle_raw: ConnectionHandleRaw,
3432
/// Mutex for locking access to the database.
3533
pub(crate) shared: Arc<WorkerSharedState>,
3634
}
@@ -105,7 +103,6 @@ impl ConnectionWorker {
105103
if establish_tx
106104
.send(Ok(Self {
107105
command_tx,
108-
_handle_raw: conn.handle.to_raw(),
109106
shared: Arc::clone(&shared),
110107
}))
111108
.is_err()

0 commit comments

Comments
 (0)