File tree Expand file tree Collapse file tree 4 files changed +25
-0
lines changed
Expand file tree Collapse file tree 4 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ pub unsafe extern "C" fn sqlite3_open_v2(
8989 connection : connection. unwrap ( ) ,
9090 transaction_baton : Mutex :: new ( None ) ,
9191 last_insert_rowid : Mutex :: new ( None ) ,
92+ rows_written : Mutex :: new ( None ) ,
9293 transaction_has_began : Mutex :: new ( false ) ,
9394 delete_hook : Mutex :: new ( None ) ,
9495 insert_hook : Mutex :: new ( None ) ,
@@ -383,6 +384,22 @@ pub unsafe extern "C" fn sqlite3_extended_errcode(_: *mut SQLite3) -> c_int {
383384 SQLITE_OK
384385}
385386
387+ #[ no_mangle]
388+ pub unsafe extern "C" fn sqlite3_changes ( db : * mut SQLite3 ) -> c_int {
389+ if !is_aligned ( db) {
390+ return SQLITE_OK ;
391+ }
392+ let db = & mut * db;
393+
394+ if let Ok ( rows_written) = db. rows_written . lock ( ) {
395+ if rows_written. is_some ( ) {
396+ return rows_written. unwrap ( ) as c_int ;
397+ }
398+ }
399+
400+ 0
401+ }
402+
386403#[ no_mangle]
387404pub unsafe extern "C" fn sqlite3_errmsg ( _: * mut SQLite3 ) -> * const c_char {
388405 if let Some ( error_entry) = sqlite:: get_latest_error ( ) {
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ lazy_static! {
8686pub struct SQLite3 {
8787 pub connection : transport:: DatabaseConnection , // Connection to the database
8888 pub last_insert_rowid : Mutex < Option < i64 > > , // Last inserted row ID
89+ pub rows_written : Mutex < Option < u64 > > , // Number of rows written
8990 pub transaction_baton : Mutex < Option < String > > , // Baton for transaction management
9091 pub transaction_has_began : Mutex < bool > , // Flag to check if a transaction has started
9192 pub update_hook : Mutex < Option < ( SqliteHook , * mut c_void ) > > , // Update hook callback
Original file line number Diff line number Diff line change @@ -51,6 +51,8 @@ pub struct RemoteRow {
5151pub struct QueryResult {
5252 pub cols : Vec < RemoteCol > ,
5353 pub rows : Vec < Vec < RemoteRow > > ,
54+ pub rows_read : Option < u64 > ,
55+ pub rows_written : Option < u64 > ,
5456 pub last_insert_rowid : Option < String > ,
5557}
5658
Original file line number Diff line number Diff line change @@ -144,5 +144,10 @@ pub fn get_execution_result<'a>(
144144 * last_insert_rowid_lock = Some ( last_insert_rowid. parse :: < i64 > ( ) . unwrap_or ( 0 ) ) ;
145145 }
146146
147+ if let Some ( rows_written) = & first_execution_result. rows_written {
148+ let mut rows_written_lock = db. rows_written . lock ( ) . unwrap ( ) ;
149+ * rows_written_lock = Some ( * rows_written) ;
150+ }
151+
147152 Ok ( first_execution_result)
148153}
You can’t perform that action at this time.
0 commit comments