expose total_changes()

This commit is contained in:
François 2024-02-27 02:16:15 +01:00
parent 322073a70d
commit 673a69d3c6
2 changed files with 22 additions and 0 deletions

View File

@ -288,6 +288,18 @@ impl InnerConnection {
}
}
#[inline]
pub fn total_changes(&self) -> u64 {
#[cfg(not(feature = "modern_sqlite"))]
unsafe {
ffi::sqlite3_total_changes(self.db()) as u64
}
#[cfg(feature = "modern_sqlite")] // 3.37.0
unsafe {
ffi::sqlite3_total_changes64(self.db()) as u64
}
}
#[inline]
pub fn is_autocommit(&self) -> bool {
unsafe { ffi::sqlite3_get_autocommit(self.db()) != 0 }

View File

@ -1005,6 +1005,16 @@ impl Connection {
self.db.borrow().changes()
}
/// Return the total number of rows modified, inserted or deleted by all
/// completed INSERT, UPDATE or DELETE statements since the database
/// connection was opened, including those executed as part of trigger programs.
///
/// See <https://www.sqlite.org/c3ref/total_changes.html>
#[inline]
pub fn total_changes(&self) -> u64 {
self.db.borrow().total_changes()
}
/// Test for auto-commit mode.
/// Autocommit mode is on by default.
#[inline]