Skip to content

Commit 0db5c14

Browse files
committed
Revert "slight optimization where we do not check pragma_schema_version if already checked"
This reverts commit 9a7204f.
1 parent 606e18d commit 0db5c14

File tree

5 files changed

+1
-20
lines changed

5 files changed

+1
-20
lines changed

core/rs/core/src/c.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ pub struct crsql_ExtData {
5656
pub pendingDbVersion: sqlite::int64,
5757
pub pragmaSchemaVersion: ::core::ffi::c_int,
5858
pub updatedTableInfosThisTx: ::core::ffi::c_int,
59-
pub readDbVersionThisTx: ::core::ffi::c_int,
6059
pub pragmaSchemaVersionForTableInfos: ::core::ffi::c_int,
6160
pub siteId: *mut ::core::ffi::c_uchar,
6261
pub pDbVersionStmt: *mut sqlite::stmt,
@@ -341,21 +340,11 @@ fn bindgen_test_layout_crsql_ExtData() {
341340
stringify!(updatedTableInfosThisTx)
342341
)
343342
);
344-
assert_eq!(
345-
unsafe { ::core::ptr::addr_of!((*ptr).readDbVersionThisTx) as usize - ptr as usize },
346-
48usize,
347-
concat!(
348-
"Offset of field: ",
349-
stringify!(crsql_ExtData),
350-
"::",
351-
stringify!(readDbVersionThisTx)
352-
)
353-
);
354343
assert_eq!(
355344
unsafe {
356345
::core::ptr::addr_of!((*ptr).pragmaSchemaVersionForTableInfos) as usize - ptr as usize
357346
},
358-
52usize,
347+
48usize,
359348
concat!(
360349
"Offset of field: ",
361350
stringify!(crsql_ExtData),

core/rs/core/src/db_version.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ pub fn fill_db_version_if_needed(
7979
ext_data: *mut crsql_ExtData,
8080
) -> Result<ResultCode, String> {
8181
unsafe {
82-
if (*ext_data).readDbVersionThisTx == 1 {
83-
return Ok(ResultCode::OK);
84-
}
85-
(*ext_data).readDbVersionThisTx = 1;
8682
let rc = crsql_fetchPragmaDataVersion(db, ext_data);
8783
if rc == -1 {
8884
return Err("failed to fetch PRAGMA data_version".to_string());

core/src/crsqlite.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ static int commitHook(void *pUserData) {
3636
pExtData->pendingDbVersion = -1;
3737
pExtData->seq = 0;
3838
pExtData->updatedTableInfosThisTx = 0;
39-
pExtData->readDbVersionThisTx = 0;
4039
return SQLITE_OK;
4140
}
4241

@@ -46,7 +45,6 @@ static void rollbackHook(void *pUserData) {
4645
pExtData->pendingDbVersion = -1;
4746
pExtData->seq = 0;
4847
pExtData->updatedTableInfosThisTx = 0;
49-
pExtData->readDbVersionThisTx = 0;
5048
}
5149

5250
#ifdef LIBSQL

core/src/ext-data.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ crsql_ExtData *crsql_newExtData(sqlite3 *db, unsigned char *siteIdBuffer) {
5050
pExtData->tableInfos = 0;
5151
pExtData->rowsImpacted = 0;
5252
pExtData->updatedTableInfosThisTx = 0;
53-
pExtData->readDbVersionThisTx = 0;
5453
crsql_init_table_info_vec(pExtData);
5554

5655
int pv = crsql_fetchPragmaDataVersion(db, pExtData);

core/src/ext-data.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ struct crsql_ExtData {
2222
sqlite3_int64 pendingDbVersion;
2323
int pragmaSchemaVersion;
2424
int updatedTableInfosThisTx;
25-
int readDbVersionThisTx;
2625

2726
// we need another schema version number that tracks when we checked it
2827
// for zpTableInfos.

0 commit comments

Comments
 (0)