mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Merge pull request #1152 from thomcc/expose-changes
Expose `sqlite3_changes` (or `sqlite3_changes64` if available)
This commit is contained in:
commit
af8cd1caec
@ -277,14 +277,14 @@ impl InnerConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn changes(&self) -> usize {
|
pub fn changes(&self) -> u64 {
|
||||||
#[cfg(not(feature = "modern_sqlite"))]
|
#[cfg(not(feature = "modern_sqlite"))]
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::sqlite3_changes(self.db()) as usize
|
ffi::sqlite3_changes(self.db()) as u64
|
||||||
}
|
}
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.37.0
|
#[cfg(feature = "modern_sqlite")] // 3.37.0
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::sqlite3_changes64(self.db()) as usize
|
ffi::sqlite3_changes64(self.db()) as u64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/lib.rs
12
src/lib.rs
@ -1,5 +1,9 @@
|
|||||||
//! Rusqlite is an ergonomic wrapper for using SQLite from Rust. It attempts to
|
//! Rusqlite is an ergonomic wrapper for using SQLite from Rust.
|
||||||
//! expose an interface similar to [rust-postgres](https://github.com/sfackler/rust-postgres).
|
//!
|
||||||
|
//! Historically, the API was based on the one from
|
||||||
|
//! [`rust-postgres`](https://github.com/sfackler/rust-postgres). However, the
|
||||||
|
//! two have diverged in many ways, and no compatibility between the two is
|
||||||
|
//! intended.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use rusqlite::{params, Connection, Result};
|
//! use rusqlite::{params, Connection, Result};
|
||||||
@ -901,8 +905,10 @@ impl Connection {
|
|||||||
/// Return the number of rows modified, inserted or deleted by the most
|
/// Return the number of rows modified, inserted or deleted by the most
|
||||||
/// recently completed INSERT, UPDATE or DELETE statement on the database
|
/// recently completed INSERT, UPDATE or DELETE statement on the database
|
||||||
/// connection.
|
/// connection.
|
||||||
|
///
|
||||||
|
/// See <https://www.sqlite.org/c3ref/changes.html>
|
||||||
#[inline]
|
#[inline]
|
||||||
fn changes(&self) -> usize {
|
pub fn changes(&self) -> u64 {
|
||||||
self.db.borrow().changes()
|
self.db.borrow().changes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,7 +778,7 @@ impl Statement<'_> {
|
|||||||
let r = self.stmt.step();
|
let r = self.stmt.step();
|
||||||
self.stmt.reset();
|
self.stmt.reset();
|
||||||
match r {
|
match r {
|
||||||
ffi::SQLITE_DONE => Ok(self.conn.changes()),
|
ffi::SQLITE_DONE => Ok(self.conn.changes() as usize),
|
||||||
ffi::SQLITE_ROW => Err(Error::ExecuteReturnedResults),
|
ffi::SQLITE_ROW => Err(Error::ExecuteReturnedResults),
|
||||||
_ => Err(self.conn.decode_result(r).unwrap_err()),
|
_ => Err(self.conn.decode_result(r).unwrap_err()),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user