mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-12 03:34:20 +01:00
Move VTabOpaqueCursor to vtab module
This commit is contained in:
@@ -10,7 +10,8 @@ use crate::storage::sqlite3_ondisk::write_varint;
|
||||
use crate::translate::collate::CollationSeq;
|
||||
use crate::translate::plan::IterationDirection;
|
||||
use crate::vdbe::sorter::Sorter;
|
||||
use crate::vdbe::{Register, VTabOpaqueCursor};
|
||||
use crate::vdbe::Register;
|
||||
use crate::vtab::VTabOpaqueCursor;
|
||||
use crate::Result;
|
||||
use std::fmt::Display;
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ use regex::Regex;
|
||||
use std::{
|
||||
cell::{Cell, RefCell},
|
||||
collections::HashMap,
|
||||
ffi::c_void,
|
||||
num::NonZero,
|
||||
ops::Deref,
|
||||
rc::{Rc, Weak},
|
||||
@@ -203,37 +202,6 @@ impl<const N: usize> Bitfield<N> {
|
||||
}
|
||||
}
|
||||
|
||||
type VTabOpaqueCursorCloseFn = unsafe extern "C" fn(*const c_void) -> limbo_ext::ResultCode;
|
||||
|
||||
pub struct VTabOpaqueCursor {
|
||||
cursor: *const c_void,
|
||||
close: VTabOpaqueCursorCloseFn,
|
||||
}
|
||||
|
||||
impl VTabOpaqueCursor {
|
||||
pub fn new(cursor: *const c_void, close: VTabOpaqueCursorCloseFn) -> Result<Self> {
|
||||
if cursor.is_null() {
|
||||
return Err(LimboError::InternalError(
|
||||
"VTabOpaqueCursor: cursor is null".into(),
|
||||
));
|
||||
}
|
||||
Ok(Self { cursor, close })
|
||||
}
|
||||
|
||||
pub fn as_ptr(&self) -> *const c_void {
|
||||
self.cursor
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for VTabOpaqueCursor {
|
||||
fn drop(&mut self) {
|
||||
let result = unsafe { (self.close)(self.cursor) };
|
||||
if !result.is_ok() {
|
||||
tracing::error!("Failed to close virtual table cursor");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
/// The commit state of the program.
|
||||
/// There are two states:
|
||||
|
||||
32
core/vtab.rs
32
core/vtab.rs
@@ -1,6 +1,5 @@
|
||||
use crate::schema::Column;
|
||||
use crate::util::columns_from_create_table_body;
|
||||
use crate::vdbe::VTabOpaqueCursor;
|
||||
use crate::{Connection, LimboError, SymbolTable, Value};
|
||||
use fallible_iterator::FallibleIterator;
|
||||
use limbo_ext::{ConstraintInfo, IndexInfo, OrderByInfo, ResultCode, VTabKind, VTabModuleImpl};
|
||||
@@ -200,3 +199,34 @@ impl VirtualTable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type VTabOpaqueCursorCloseFn = unsafe extern "C" fn(*const c_void) -> limbo_ext::ResultCode;
|
||||
|
||||
pub struct VTabOpaqueCursor {
|
||||
cursor: *const c_void,
|
||||
close: VTabOpaqueCursorCloseFn,
|
||||
}
|
||||
|
||||
impl VTabOpaqueCursor {
|
||||
pub fn new(cursor: *const c_void, close: VTabOpaqueCursorCloseFn) -> crate::Result<Self> {
|
||||
if cursor.is_null() {
|
||||
return Err(LimboError::InternalError(
|
||||
"VTabOpaqueCursor: cursor is null".into(),
|
||||
));
|
||||
}
|
||||
Ok(Self { cursor, close })
|
||||
}
|
||||
|
||||
pub fn as_ptr(&self) -> *const c_void {
|
||||
self.cursor
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for VTabOpaqueCursor {
|
||||
fn drop(&mut self) {
|
||||
let result = unsafe { (self.close)(self.cursor) };
|
||||
if !result.is_ok() {
|
||||
tracing::error!("Failed to close virtual table cursor");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user