Skip to content

Commit f6d59f8

Browse files
authored
Merge pull request #3854 from bestmike007/fix/profile-sqlite
chore: fix profile-sqlite for stackslib
2 parents 0929a8b + 474cd78 commit f6d59f8

File tree

1 file changed

+19
-3
lines changed
  • stackslib/src/util_lib

1 file changed

+19
-3
lines changed

stackslib/src/util_lib/db.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,15 +690,31 @@ fn trace_profile(query: &str, duration: Duration) {
690690
);
691691
}
692692

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+
693711
/// Open a database connection and set some typically-used pragmas
694712
pub fn sqlite_open<P: AsRef<Path>>(
695713
path: P,
696714
flags: OpenFlags,
697715
foreign_keys: bool,
698716
) -> 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)?;
702718
db.busy_handler(Some(tx_busy_handler))?;
703719
inner_sql_pragma(&db, "journal_mode", &"WAL")?;
704720
inner_sql_pragma(&db, "synchronous", &"NORMAL")?;

0 commit comments

Comments
 (0)