Skip to content

Commit c73c9fa

Browse files
committed
Mark RawStatement as Send and document thread safety constraints
1 parent 095998e commit c73c9fa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/duckdb/src/raw_statement.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ use super::{ffi, Result};
1111
use crate::arrow2;
1212
use crate::{error::result_from_duckdb_arrow, Error};
1313

14-
// Private newtype for raw sqlite3_stmts that finalize themselves when dropped.
15-
// TODO: destroy statement and result
14+
/// Private newtype for DuckDB prepared statements that finalize themselves when dropped.
15+
///
16+
/// # Thread Safety
17+
///
18+
/// `RawStatement` is `Send` but not `Sync`:
19+
/// - `Send` because it owns all its data and can be safely moved between threads
20+
/// - Not `Sync` because DuckDB prepared statements don't support concurrent access
1621
#[derive(Debug)]
1722
pub struct RawStatement {
1823
ptr: ffi::duckdb_prepared_statement,
@@ -325,3 +330,5 @@ impl Drop for RawStatement {
325330
}
326331
}
327332
}
333+
334+
unsafe impl Send for RawStatement {}

0 commit comments

Comments
 (0)