File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,19 @@ use crate::{
88} ; 
99
1010/// Appender for fast import data 
11+ /// 
12+ /// # Thread Safety 
13+ /// 
14+ /// `Appender` is neither `Send` nor `Sync`: 
15+ /// - Not `Send` because it holds a reference to `Connection`, which is `!Sync` 
16+ /// - Not `Sync` because DuckDB appenders don't support concurrent access 
17+ /// 
18+ /// To use an appender in another thread, move the `Connection` to that thread 
19+ /// and create the appender there. 
20+ /// 
21+ /// If you need to share an `Appender` across threads, wrap it in a `Mutex`. 
22+ /// 
23+ /// See [DuckDB concurrency documentation](https://duckdb.org/docs/stable/connect/concurrency.html) for more details. 
1124pub  struct  Appender < ' conn >  { 
1225    conn :  & ' conn  Connection , 
1326    app :  ffi:: duckdb_appender , 
Original file line number Diff line number Diff line change @@ -11,8 +11,13 @@ use super::{ffi, Result};
1111use  crate :: arrow2; 
1212use  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 ) ]  
1722pub  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  { } 
Original file line number Diff line number Diff line change @@ -12,6 +12,14 @@ use crate::{
1212} ; 
1313
1414/// A prepared statement. 
15+ /// 
16+ /// # Thread Safety 
17+ /// 
18+ /// `Statement` is neither `Send` nor `Sync`: 
19+ /// - Not `Send` because it holds a reference to `Connection`, which is `!Sync` 
20+ /// - Not `Sync` because DuckDB prepared statements don't support concurrent access 
21+ /// 
22+ /// See the [DuckDB concurrency documentation](https://duckdb.org/docs/stable/connect/concurrency.html) for more details. 
1523pub  struct  Statement < ' conn >  { 
1624    conn :  & ' conn  Connection , 
1725    pub ( crate )  stmt :  RawStatement , 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments