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

Convert more initialization code to Rust #398

Merged
merged 18 commits into from
Nov 14, 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
6 changes: 3 additions & 3 deletions core/rs/bundle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern crate alloc;

use core::alloc::GlobalAlloc;
use core::alloc::Layout;
use core::ffi::{c_char, c_int};
use core::ffi::c_char;
use core::panic::PanicInfo;
use crsql_core;
use crsql_core::sqlite3_crsqlcore_init;
Expand Down Expand Up @@ -43,12 +43,12 @@ pub extern "C" fn sqlite3_crsqlrustbundle_init(
db: *mut sqlite::sqlite3,
err_msg: *mut *mut c_char,
api: *mut sqlite::api_routines,
) -> c_int {
) -> *mut ::core::ffi::c_void {
sqlite::EXTENSION_INIT2(api);

let rc = sqlite3_crsqlfractionalindex_init(db, err_msg, api);
if rc != 0 {
return rc;
return core::ptr::null_mut();
}

sqlite3_crsqlcore_init(db, err_msg, api)
Expand Down
1 change: 0 additions & 1 deletion core/rs/core/src/automigrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use alloc::string::ToString;
use alloc::vec;
use alloc::vec::Vec;
use core::ffi::{c_char, c_int};
use core::slice;
use sqlite::ColumnType;
use sqlite_nostd as sqlite;

Expand Down
1 change: 1 addition & 0 deletions core/rs/core/src/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ extern "C" {
siteIdBuffer: *mut c_char,
) -> *mut crsql_ExtData;
pub fn crsql_freeExtData(pExtData: *mut crsql_ExtData);
pub fn crsql_finalize(pExtData: *mut crsql_ExtData);
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion core/rs/core/src/changes_vtab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use alloc::vec::Vec;
use core::ffi::{c_char, c_int, CStr};
use core::mem::{self, forget};
use core::ptr::null_mut;
use core::slice;

use alloc::ffi::CString;
#[cfg(not(feature = "std"))]
Expand Down
5 changes: 3 additions & 2 deletions core/rs/core/src/changes_vtab_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use alloc::format;
use alloc::vec::Vec;
use core::ffi::{c_char, c_int};
use core::mem;
use core::slice;
use sqlite::Stmt;
use sqlite_nostd as sqlite;
use sqlite_nostd::{sqlite3, ResultCode, Value};
Expand Down Expand Up @@ -575,7 +574,9 @@ unsafe fn merge_insert(
// In an in-order delivery situation then `sentinel_only` would have already resurrected the row
// In out-of-order delivery, we need to resurrect the row as soon as we get a value
// which should resurrect the row. I.e., don't wait on the sentinel value to resurrect the row!
if needs_resurrect && row_exists_locally {
// If the row does not exist locally and the insert_cl is > 1 then we need to create a sentinel to record the insert cl.
// Not doing so will cause us to assume a cl of 1.
if needs_resurrect && (row_exists_locally || (!row_exists_locally && insert_cl > 1)) {
// this should work -- same as `merge_sentinel_only_insert` except we're not done once we do it
// and the version to set to is the cl not col_vrsn of current insert
merge_sentinel_only_insert(
Expand Down
Loading