Skip to content

Commit 9da7cb2

Browse files
authored
Merge pull request #7 from superfly/fix-warnings
Fix warnings
2 parents e622733 + be881ce commit 9da7cb2

File tree

8 files changed

+33
-46
lines changed

8 files changed

+33
-46
lines changed

core/rs/core/src/c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use sqlite_nostd as sqlite;
99

1010
pub static INSERT_SENTINEL: &str = "-1";
1111
pub static DELETE_SENTINEL: &str = "-1";
12-
pub static DB_VERSION_SCHEMA_VERSION: c_int = 0;
12+
pub static _DB_VERSION_SCHEMA_VERSION: c_int = 0;
1313
pub static TABLE_INFO_SCHEMA_VERSION: c_int = 1;
1414

1515
#[derive(FromPrimitive, PartialEq, Debug)]

core/rs/core/src/changes_vtab_write.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn did_cid_win(
9090
match step_result {
9191
Ok(ResultCode::ROW) => {
9292
let local_value = col_val_stmt.column_value(0)?;
93-
let mut ret = crsql_compare_sqlite_values(insert_val, local_value);
93+
let ret = crsql_compare_sqlite_values(insert_val, local_value);
9494
reset_cached_stmt(col_val_stmt.stmt)?;
9595
if ret == 0 && unsafe { (*ext_data).mergeEqualValues == 1 } {
9696
// values are the same (ret == 0) and the option to tie break on site_id is true
@@ -215,7 +215,7 @@ fn set_winner_clock(
215215
);
216216

217217
if let Err(rc) = bind_result {
218-
reset_cached_stmt((*ext_data).pSetSiteIdOrdinalStmt);
218+
reset_cached_stmt((*ext_data).pSetSiteIdOrdinalStmt)?;
219219
return Err(rc);
220220
}
221221

@@ -322,7 +322,7 @@ fn merge_sentinel_only_insert(
322322
}
323323

324324
if rc.is_ok() {
325-
zero_clocks_on_resurrect(db, tbl_info, key, remote_db_vsn)?;
325+
zero_clocks_on_resurrect(db, tbl_info, key)?;
326326
return set_winner_clock(
327327
db,
328328
ext_data,
@@ -344,7 +344,6 @@ fn zero_clocks_on_resurrect(
344344
db: *mut sqlite3,
345345
tbl_info: &TableInfo,
346346
key: sqlite::int64,
347-
insert_db_vrsn: sqlite::int64,
348347
) -> Result<ResultCode, ResultCode> {
349348
let zero_stmt_ref = tbl_info.get_zero_clocks_on_resurrect_stmt(db)?;
350349
let zero_stmt = zero_stmt_ref.as_ref().ok_or(ResultCode::ERROR)?;

core/rs/core/src/consts.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ pub const TBL_SCHEMA: &'static str = "crsql_master";
1212
// and, if we ever need it, we can track individual builds of a patch release
1313
// 00_05_01_01
1414
pub const CRSQLITE_VERSION: i32 = 17_00_00;
15-
pub const CRSQLITE_VERSION_STR: &'static str = "0.17.0";
16-
pub const CRSQLITE_VERSION_0_15_0: i32 = 15_00_00;
15+
pub const _CRSQLITE_VERSION_STR: &'static str = "0.17.0";
1716
pub const CRSQLITE_VERSION_0_17_0: i32 = 17_00_00;
1817

1918
pub const SITE_ID_LEN: i32 = 16;

core/rs/core/src/db_version.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ use sqlite_nostd as sqlite;
1414

1515
use crate::c::crsql_ExtData;
1616
use crate::c::crsql_fetchPragmaDataVersion;
17-
use crate::c::crsql_fetchPragmaSchemaVersion;
18-
use crate::c::DB_VERSION_SCHEMA_VERSION;
1917
use crate::consts::MIN_POSSIBLE_DB_VERSION;
2018
use crate::consts::SITE_ID_LEN;
21-
use crate::ext_data::recreate_db_version_stmt;
2219
use crate::stmt_cache::reset_cached_stmt;
2320
#[no_mangle]
2421
pub extern "C" fn crsql_fill_db_version_if_needed(
@@ -135,7 +132,7 @@ pub fn fill_db_version_if_needed(
135132
}
136133

137134
pub fn fetch_db_version_from_storage(
138-
db: *mut sqlite3,
135+
_db: *mut sqlite3,
139136
ext_data: *mut crsql_ExtData,
140137
) -> Result<ResultCode, String> {
141138
unsafe {

core/rs/core/src/debug.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use alloc::format;
2-
use alloc::string::String;
3-
use core::ffi::c_void;
41
use sqlite::{context, value};
52
use sqlite_nostd as sqlite;
63

core/rs/core/src/lib.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,23 @@ pub extern "C" fn sqlite3_crsqlcore_init(
337337
return null_mut();
338338
}
339339

340+
let rc = db
341+
.create_function_v2(
342+
"crsql_version",
343+
0,
344+
sqlite::UTF8 | sqlite::INNOCUOUS | sqlite::DETERMINISTIC,
345+
None,
346+
Some(x_crsql_version),
347+
None,
348+
None,
349+
None,
350+
)
351+
.unwrap_or(ResultCode::ERROR);
352+
if rc != ResultCode::OK {
353+
unsafe { crsql_freeExtData(ext_data) };
354+
return null_mut();
355+
}
356+
340357
let rc = db
341358
.create_function_v2(
342359
"crsql_increment_and_get_seq",
@@ -903,8 +920,8 @@ unsafe extern "C" fn x_crsql_db_version(
903920
*/
904921
unsafe extern "C" fn x_crsql_next_db_version(
905922
ctx: *mut sqlite::context,
906-
argc: i32,
907-
argv: *mut *mut sqlite::value,
923+
_argc: i32,
924+
_argv: *mut *mut sqlite::value,
908925
) {
909926
let ext_data = ctx.user_data() as *mut c::crsql_ExtData;
910927
let db = ctx.db_handle();
@@ -962,8 +979,8 @@ unsafe extern "C" fn x_crsql_set_db_version(
962979
*/
963980
unsafe extern "C" fn x_crsql_peek_next_db_version(
964981
ctx: *mut sqlite::context,
965-
argc: i32,
966-
argv: *mut *mut sqlite::value,
982+
_argc: i32,
983+
_argv: *mut *mut sqlite::value,
967984
) {
968985
let ext_data = ctx.user_data() as *mut c::crsql_ExtData;
969986
let db = ctx.db_handle();
@@ -984,16 +1001,16 @@ unsafe extern "C" fn x_crsql_peek_next_db_version(
9841001
*/
9851002
unsafe extern "C" fn x_crsql_sha(
9861003
ctx: *mut sqlite::context,
987-
argc: i32,
988-
argv: *mut *mut sqlite::value,
1004+
_argc: i32,
1005+
_argv: *mut *mut sqlite::value,
9891006
) {
9901007
ctx.result_text_static(sha::SHA);
9911008
}
9921009

9931010
unsafe extern "C" fn x_crsql_version(
9941011
ctx: *mut sqlite::context,
995-
argc: i32,
996-
argv: *mut *mut sqlite::value,
1012+
_argc: i32,
1013+
_argv: *mut *mut sqlite::value,
9971014
) {
9981015
ctx.result_int64(consts::CRSQLITE_VERSION as i64);
9991016
}

core/rs/core/src/local_writes/after_update.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -200,30 +200,6 @@ fn after_update__move_non_pk_col(
200200
super::step_trigger_stmt(move_non_pk_col_stmt)
201201
}
202202

203-
// TODO: in the future we can keep sentinel information in the lookaside
204-
#[allow(non_snake_case)]
205-
fn after_update__move_non_sentinels(
206-
db: *mut sqlite3,
207-
tbl_info: &TableInfo,
208-
new_key: sqlite::int64,
209-
old_key: sqlite::int64,
210-
) -> Result<ResultCode, String> {
211-
let move_non_sentinels_stmt_ref = tbl_info
212-
.get_move_non_sentinels_stmt(db)
213-
.or_else(|_| Err("failed to get move_non_sentinels_stmt"))?;
214-
let move_non_sentinels_stmt = move_non_sentinels_stmt_ref
215-
.as_ref()
216-
.ok_or("Failed to deref move_non_sentinels_stmt")?;
217-
218-
move_non_sentinels_stmt
219-
// set things to new key
220-
.bind_int64(1, new_key)
221-
// where they have the old key
222-
.and_then(|_| move_non_sentinels_stmt.bind_int64(2, old_key))
223-
.or_else(|_| Err("failed to bind pks to move_non_sentinels_stmt"))?;
224-
super::step_trigger_stmt(move_non_sentinels_stmt)
225-
}
226-
227203
#[cfg(test)]
228204
mod tests {
229205
use super::*;

core/rs/core/src/tableinfo.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ impl TableInfo {
468468
Ok(self.mark_locally_deleted_stmt.try_borrow()?)
469469
}
470470

471+
#[allow(dead_code)]
471472
pub fn get_move_non_sentinels_stmt(
472473
&self,
473474
db: *mut sqlite3,
@@ -571,6 +572,7 @@ impl TableInfo {
571572
Ok(self.combo_insert_clock_stmt.try_borrow()?)
572573
}
573574

575+
#[allow(dead_code)]
574576
pub fn get_select_clock_stmt(
575577
&self,
576578
db: *mut sqlite3,

0 commit comments

Comments
 (0)