mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Change signature of VTab::best_index
This commit is contained in:
parent
c8b09e2ee7
commit
a90388e6bf
@ -9,7 +9,7 @@ use libc;
|
||||
use {Connection, Error, Result};
|
||||
use ffi;
|
||||
use types::Null;
|
||||
use vtab::{declare_vtab, escape_double_quote, Context, VTab, VTabCursor};
|
||||
use vtab::{declare_vtab, escape_double_quote, Context, IndexInfo, VTab, VTabCursor};
|
||||
|
||||
/// Register the "csv" module.
|
||||
pub fn load_module(conn: &Connection) -> Result<()> {
|
||||
@ -131,7 +131,7 @@ impl VTab<CSVTabCursor> for CSVTab {
|
||||
Ok(vtab)
|
||||
}
|
||||
|
||||
fn best_index(&self, _info: *mut ffi::sqlite3_index_info) {}
|
||||
fn best_index(&self, _info: &mut IndexInfo) {}
|
||||
|
||||
fn open(&self) -> Result<CSVTabCursor> {
|
||||
Ok(CSVTabCursor::new(try!(self.reader())))
|
||||
|
@ -7,7 +7,7 @@ use libc;
|
||||
|
||||
use {Connection, Error, Result};
|
||||
use ffi;
|
||||
use vtab::{declare_vtab, escape_double_quote, Context, VTab, VTabCursor};
|
||||
use vtab::{declare_vtab, escape_double_quote, Context, IndexInfo, VTab, VTabCursor};
|
||||
|
||||
/// Create a specific instance of an intarray object.
|
||||
/// The new intarray object is returned.
|
||||
@ -71,7 +71,7 @@ impl VTab<IntArrayVTabCursor> for IntArrayVTab {
|
||||
Ok(vtab)
|
||||
}
|
||||
|
||||
fn best_index(&self, _info: *mut ffi::sqlite3_index_info) {}
|
||||
fn best_index(&self, _info: &mut IndexInfo) {}
|
||||
|
||||
fn open(&self) -> Result<IntArrayVTabCursor> {
|
||||
Ok(IntArrayVTabCursor::new())
|
||||
|
@ -45,11 +45,17 @@ 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.
|
||||
fn create(db: *mut ffi::sqlite3, aux: *mut libc::c_void, args: &[&[u8]]) -> Result<Self>;
|
||||
/// Determine the best way to access the virtual table.
|
||||
fn best_index(&self, info: *mut ffi::sqlite3_index_info);
|
||||
fn best_index(&self, info: &mut IndexInfo);
|
||||
/// Create a new cursor used for accessing a virtual table.
|
||||
fn open(&self) -> Result<C>;
|
||||
}
|
||||
|
||||
pub struct IndexInfo(*mut ffi::sqlite3_index_info);
|
||||
|
||||
impl IndexInfo {
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// Virtual table cursor trait.
|
||||
pub trait VTabCursor<V: VTab<Self>>: Sized {
|
||||
/// Accessor to the associated virtual table.
|
||||
@ -71,6 +77,7 @@ pub trait VTabCursor<V: VTab<Self>>: Sized {
|
||||
fn rowid(&self) -> Result<i64>;
|
||||
}
|
||||
|
||||
// FIXME clash with functions::Context
|
||||
pub struct Context(*mut ffi::sqlite3_context);
|
||||
|
||||
impl Context {
|
||||
@ -221,7 +228,8 @@ unsafe extern "C" fn $best_index(vtab: *mut ffi::sqlite3_vtab,
|
||||
info: *mut ffi::sqlite3_index_info)
|
||||
-> libc::c_int {
|
||||
let vtab = vtab as *mut $vtab;
|
||||
(*vtab).best_index(info);
|
||||
let mut idx_info = IndexInfo(info);
|
||||
(*vtab).best_index(&mut idx_info);
|
||||
ffi::SQLITE_OK
|
||||
}
|
||||
unsafe extern "C" fn $destroy(vtab: *mut ffi::sqlite3_vtab) -> libc::c_int {
|
||||
|
Loading…
Reference in New Issue
Block a user