Skip to content
This repository has been archived by the owner on Jul 11, 2021. It is now read-only.

Commit

Permalink
make it compatible with 32 bit architecture and reworks the non-worki…
Browse files Browse the repository at this point in the history
…ng replication mechanism
  • Loading branch information
Simone Mosciatti committed Jan 17, 2018
1 parent a45fe4f commit c15bdff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 13 additions & 1 deletion src/community_statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ impl<'a> StatementTrait<'a> for Statement<'a> {

#[cfg(feature = "pro")]
fn to_replicate(&self) -> bool {
replication::to_replicate(self)
let v = replication::to_replicate(self);
v
}
}

Expand Down Expand Up @@ -302,6 +303,17 @@ impl<'a> StatementTrait<'a> for MultiStatement<'a> {
fn get_raw_stmt(&self) -> *mut ffi::sqlite3_stmt {
self.stmts[0].stmt
}

#[cfg(feature="pro")]
fn to_replicate(&self) -> bool {
for stmt in &self.stmts {
let v = stmt.to_replicate();
if v {
return true;
}
}
return false;
}
}

fn count_parameters<'a>
Expand Down
12 changes: 7 additions & 5 deletions src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use std::ffi::{CString, CStr};
use std::error;
use std::iter::FromIterator;

use std::os::raw::c_char;

use redisql_error as err;

pub use community_statement;
Expand Down Expand Up @@ -197,13 +199,13 @@ impl<'a> FromIterator<Cursor<'a>> for Cursor<'a> {
for cursor in cursors {
match cursor {
Cursor::OKCursor { to_replicate } => {
to_replicate_acc &= to_replicate;
to_replicate_acc |= to_replicate;
}
Cursor::DONECursor { to_replicate, .. } => {
to_replicate_acc &= to_replicate;
to_replicate_acc |= to_replicate;
}
Cursor::RowsCursor { to_replicate, .. } => {
to_replicate_acc &= to_replicate;
to_replicate_acc |= to_replicate;
result = Some(cursor);
}
}
Expand Down Expand Up @@ -282,14 +284,14 @@ impl<'a> Iterator for Cursor<'a> {
}
EntityType::Text => {
let value = unsafe {
CStr::from_ptr(ffi::sqlite3_column_text(stmt.get_raw_stmt(), i) as *const i8).to_string_lossy().into_owned()
CStr::from_ptr(ffi::sqlite3_column_text(stmt.get_raw_stmt(), i) as *const c_char).to_string_lossy().into_owned()
};
debug!("Got text: {:?}", value);
Entity::Text { text: value }
}
EntityType::Blob => {
let value = unsafe {
CStr::from_ptr(ffi::sqlite3_column_blob(stmt.get_raw_stmt(), i) as *const i8).to_string_lossy().into_owned()
CStr::from_ptr(ffi::sqlite3_column_blob(stmt.get_raw_stmt(), i) as *const c_char).to_string_lossy().into_owned()
};
debug!("Got blob: {:?}", value);
Entity::Blob { blob: value }
Expand Down

0 comments on commit c15bdff

Please sign in to comment.