Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "slight optimization where we do not check `pragma_schema_vers… #411

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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