@@ -690,15 +690,31 @@ fn trace_profile(query: &str, duration: Duration) {
690
690
) ;
691
691
}
692
692
693
+ #[ cfg( feature = "profile-sqlite" ) ]
694
+ fn inner_connection_open < P : AsRef < Path > > (
695
+ path : P ,
696
+ flags : OpenFlags ,
697
+ ) -> Result < Connection , sqlite_error > {
698
+ let mut db = Connection :: open_with_flags ( path, flags) ?;
699
+ db. profile ( Some ( trace_profile) ) ;
700
+ Ok ( db)
701
+ }
702
+
703
+ #[ cfg( not( feature = "profile-sqlite" ) ) ]
704
+ fn inner_connection_open < P : AsRef < Path > > (
705
+ path : P ,
706
+ flags : OpenFlags ,
707
+ ) -> Result < Connection , sqlite_error > {
708
+ Connection :: open_with_flags ( path, flags)
709
+ }
710
+
693
711
/// Open a database connection and set some typically-used pragmas
694
712
pub fn sqlite_open < P : AsRef < Path > > (
695
713
path : P ,
696
714
flags : OpenFlags ,
697
715
foreign_keys : bool ,
698
716
) -> Result < Connection , sqlite_error > {
699
- let db = Connection :: open_with_flags ( path, flags) ?;
700
- #[ cfg( feature = "profile-sqlite" ) ]
701
- db. profile ( Some ( trace_profile) ) ;
717
+ let db = inner_connection_open ( path, flags) ?;
702
718
db. busy_handler ( Some ( tx_busy_handler) ) ?;
703
719
inner_sql_pragma ( & db, "journal_mode" , & "WAL" ) ?;
704
720
inner_sql_pragma ( & db, "synchronous" , & "NORMAL" ) ?;
0 commit comments