File tree Expand file tree Collapse file tree 1 file changed +1
-9
lines changed
sqlx-core/src/odbc/connection Expand file tree Collapse file tree 1 file changed +1
-9
lines changed Original file line number Diff line number Diff line change 1- use std:: sync:: OnceLock ;
21use std:: thread;
32
43use futures_channel:: oneshot;
@@ -22,9 +21,6 @@ type ExecuteSender = flume::Sender<ExecuteResult>;
2221type PrepareResult = Result < ( u64 , Vec < OdbcColumn > , usize ) , Error > ;
2322type PrepareSender = oneshot:: Sender < PrepareResult > ;
2423
25- // Shared ODBC environment - initialized once, used by all connections
26- static ODBC_ENV : OnceLock < & ' static odbc_api:: Environment > = OnceLock :: new ( ) ;
27-
2824#[ derive( Debug ) ]
2925pub ( crate ) struct ConnectionWorker {
3026 command_tx : flume:: Sender < Command > ,
@@ -177,11 +173,7 @@ fn worker_thread_main(
177173fn establish_connection ( options : & OdbcConnectOptions ) -> Result < OdbcConnection , Error > {
178174 // Get or create the shared ODBC environment
179175 // This ensures thread-safe initialization and prevents concurrent environment creation issues
180- let env = ODBC_ENV . get_or_init ( || {
181- Box :: leak ( Box :: new (
182- odbc_api:: Environment :: new ( ) . expect ( "Failed to create ODBC environment" ) ,
183- ) )
184- } ) ;
176+ let env = odbc_api:: environment ( ) . map_err ( |e| Error :: Configuration ( e. to_string ( ) . into ( ) ) ) ?;
185177
186178 let conn = env
187179 . connect_with_connection_string ( options. connection_string ( ) , Default :: default ( ) )
You can’t perform that action at this time.
0 commit comments