Skip to content

Commit

Permalink
Revert "slight optimization where we do not check `pragma_schema_vers…
Browse files Browse the repository at this point in the history
…ion` if already checked"

This reverts commit 9a7204f.
  • Loading branch information
tantaman committed Dec 1, 2023
1 parent 606e18d commit 0db5c14
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 20 deletions.
13 changes: 1 addition & 12 deletions core/rs/core/src/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 0 additions & 4 deletions core/rs/core/src/db_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ pub fn fill_db_version_if_needed(
ext_data: *mut crsql_ExtData,
) -> Result<ResultCode, String> {
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());
Expand Down
2 changes: 0 additions & 2 deletions core/src/crsqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ static int commitHook(void *pUserData) {
pExtData->pendingDbVersion = -1;
pExtData->seq = 0;
pExtData->updatedTableInfosThisTx = 0;
pExtData->readDbVersionThisTx = 0;
return SQLITE_OK;
}

Expand All @@ -46,7 +45,6 @@ static void rollbackHook(void *pUserData) {
pExtData->pendingDbVersion = -1;
pExtData->seq = 0;
pExtData->updatedTableInfosThisTx = 0;
pExtData->readDbVersionThisTx = 0;
}

#ifdef LIBSQL
Expand Down
1 change: 0 additions & 1 deletion core/src/ext-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion core/src/ext-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0db5c14

Please sign in to comment.