mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Change signature of VTab::best_index
This commit is contained in:
parent
505abc0331
commit
438312c132
@ -131,7 +131,9 @@ impl VTab<CSVTabCursor> for CSVTab {
|
|||||||
Ok(vtab)
|
Ok(vtab)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn best_index(&self, _info: &mut IndexInfo) {}
|
fn best_index(&self, _info: &mut IndexInfo) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn open(&self) -> Result<CSVTabCursor> {
|
fn open(&self) -> Result<CSVTabCursor> {
|
||||||
Ok(CSVTabCursor::new(try!(self.reader())))
|
Ok(CSVTabCursor::new(try!(self.reader())))
|
||||||
|
@ -71,7 +71,9 @@ impl VTab<IntArrayVTabCursor> for IntArrayVTab {
|
|||||||
Ok(vtab)
|
Ok(vtab)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn best_index(&self, _info: &mut IndexInfo) {}
|
fn best_index(&self, _info: &mut IndexInfo) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn open(&self) -> Result<IntArrayVTabCursor> {
|
fn open(&self) -> Result<IntArrayVTabCursor> {
|
||||||
Ok(IntArrayVTabCursor::new())
|
Ok(IntArrayVTabCursor::new())
|
||||||
|
@ -46,7 +46,7 @@ pub trait VTab<C: VTabCursor<Self>>: Sized {
|
|||||||
/// The `db` parameter is a pointer to the SQLite database connection that is executing the CREATE VIRTUAL TABLE statement.
|
/// The `db` parameter is a pointer to the SQLite database connection that is executing the CREATE VIRTUAL TABLE statement.
|
||||||
fn create(db: *mut ffi::sqlite3, aux: *mut libc::c_void, args: &[&[u8]]) -> Result<Self>;
|
fn create(db: *mut ffi::sqlite3, aux: *mut libc::c_void, args: &[&[u8]]) -> Result<Self>;
|
||||||
/// Determine the best way to access the virtual table.
|
/// Determine the best way to access the virtual table.
|
||||||
fn best_index(&self, info: &mut IndexInfo);
|
fn best_index(&self, info: &mut IndexInfo) -> Result<()>;
|
||||||
/// Create a new cursor used for accessing a virtual table.
|
/// Create a new cursor used for accessing a virtual table.
|
||||||
fn open(&self) -> Result<C>;
|
fn open(&self) -> Result<C>;
|
||||||
}
|
}
|
||||||
@ -248,10 +248,25 @@ unsafe extern "C" fn $create(db: *mut ffi::sqlite3,
|
|||||||
unsafe extern "C" fn $best_index(vtab: *mut ffi::sqlite3_vtab,
|
unsafe extern "C" fn $best_index(vtab: *mut ffi::sqlite3_vtab,
|
||||||
info: *mut ffi::sqlite3_index_info)
|
info: *mut ffi::sqlite3_index_info)
|
||||||
-> libc::c_int {
|
-> libc::c_int {
|
||||||
let vtab = vtab as *mut $vtab;
|
use std::error::Error as StdError;
|
||||||
|
use vtab::set_err_msg;
|
||||||
|
let vt = vtab as *mut $vtab;
|
||||||
let mut idx_info = IndexInfo(info);
|
let mut idx_info = IndexInfo(info);
|
||||||
(*vtab).best_index(&mut idx_info);
|
match (*vt).best_index(&mut idx_info) {
|
||||||
ffi::SQLITE_OK
|
Ok(_) => ffi::SQLITE_OK,
|
||||||
|
Err(Error::SqliteFailure(err, s)) => {
|
||||||
|
if let Some(err_msg) = s {
|
||||||
|
set_err_msg(vtab, &err_msg);
|
||||||
|
}
|
||||||
|
err.extended_code
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
set_err_msg(vtab, err.description());
|
||||||
|
ffi::SQLITE_ERROR
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
unsafe extern "C" fn $destroy(vtab: *mut ffi::sqlite3_vtab) -> libc::c_int {
|
unsafe extern "C" fn $destroy(vtab: *mut ffi::sqlite3_vtab) -> libc::c_int {
|
||||||
let vtab = vtab as *mut $vtab;
|
let vtab = vtab as *mut $vtab;
|
||||||
|
Loading…
Reference in New Issue
Block a user