From 4151cd1007f6fba42d2afceb4da957490bf4db8a Mon Sep 17 00:00:00 2001 From: Matt <1009003+tantaman@users.noreply.github.com> Date: Thu, 30 Nov 2023 21:51:58 -0500 Subject: [PATCH] Revert "slight optimization where we do not check `pragma_schema_version` if already checked" This reverts commit 9a7204f1a7bcbfaf3ce1aecae27cd9845846cc49. --- core/rs/core/src/c.rs | 13 +------------ core/rs/core/src/db_version.rs | 4 ---- core/src/crsqlite.c | 2 -- core/src/ext-data.c | 1 - core/src/ext-data.h | 1 - 5 files changed, 1 insertion(+), 20 deletions(-) diff --git a/core/rs/core/src/c.rs b/core/rs/core/src/c.rs index 0c04e4ec7..de116be49 100644 --- a/core/rs/core/src/c.rs +++ b/core/rs/core/src/c.rs @@ -56,7 +56,6 @@ pub struct crsql_ExtData { pub pendingDbVersion: sqlite::int64, pub pragmaSchemaVersion: ::core::ffi::c_int, pub updatedTableInfosThisTx: ::core::ffi::c_int, - pub readDbVersionThisTx: ::core::ffi::c_int, pub pragmaSchemaVersionForTableInfos: ::core::ffi::c_int, pub siteId: *mut ::core::ffi::c_uchar, pub pDbVersionStmt: *mut sqlite::stmt, @@ -341,21 +340,11 @@ fn bindgen_test_layout_crsql_ExtData() { stringify!(updatedTableInfosThisTx) ) ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).readDbVersionThisTx) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(crsql_ExtData), - "::", - stringify!(readDbVersionThisTx) - ) - ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).pragmaSchemaVersionForTableInfos) as usize - ptr as usize }, - 52usize, + 48usize, concat!( "Offset of field: ", stringify!(crsql_ExtData), diff --git a/core/rs/core/src/db_version.rs b/core/rs/core/src/db_version.rs index 9d2e9f0ed..2b614400a 100644 --- a/core/rs/core/src/db_version.rs +++ b/core/rs/core/src/db_version.rs @@ -79,10 +79,6 @@ pub fn fill_db_version_if_needed( ext_data: *mut crsql_ExtData, ) -> Result { unsafe { - if (*ext_data).readDbVersionThisTx == 1 { - return Ok(ResultCode::OK); - } - (*ext_data).readDbVersionThisTx = 1; let rc = crsql_fetchPragmaDataVersion(db, ext_data); if rc == -1 { return Err("failed to fetch PRAGMA data_version".to_string()); diff --git a/core/src/crsqlite.c b/core/src/crsqlite.c index 0ff885aa5..65b20f595 100644 --- a/core/src/crsqlite.c +++ b/core/src/crsqlite.c @@ -36,7 +36,6 @@ static int commitHook(void *pUserData) { pExtData->pendingDbVersion = -1; pExtData->seq = 0; pExtData->updatedTableInfosThisTx = 0; - pExtData->readDbVersionThisTx = 0; return SQLITE_OK; } @@ -46,7 +45,6 @@ static void rollbackHook(void *pUserData) { pExtData->pendingDbVersion = -1; pExtData->seq = 0; pExtData->updatedTableInfosThisTx = 0; - pExtData->readDbVersionThisTx = 0; } #ifdef LIBSQL diff --git a/core/src/ext-data.c b/core/src/ext-data.c index d44d89d65..34c06b777 100644 --- a/core/src/ext-data.c +++ b/core/src/ext-data.c @@ -50,7 +50,6 @@ crsql_ExtData *crsql_newExtData(sqlite3 *db, unsigned char *siteIdBuffer) { pExtData->tableInfos = 0; pExtData->rowsImpacted = 0; pExtData->updatedTableInfosThisTx = 0; - pExtData->readDbVersionThisTx = 0; crsql_init_table_info_vec(pExtData); int pv = crsql_fetchPragmaDataVersion(db, pExtData); diff --git a/core/src/ext-data.h b/core/src/ext-data.h index b7bfe81b6..a24f61836 100644 --- a/core/src/ext-data.h +++ b/core/src/ext-data.h @@ -22,7 +22,6 @@ struct crsql_ExtData { sqlite3_int64 pendingDbVersion; int pragmaSchemaVersion; int updatedTableInfosThisTx; - int readDbVersionThisTx; // we need another schema version number that tracks when we checked it // for zpTableInfos.