mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 10:08:20 +00:00
core: remove a bunch of warnings
Signed-off-by: Pere Diaz Bou <pere-altea@hotmail.com>
This commit is contained in:
parent
463292c2fe
commit
84bf0ea96a
12 changed files with 41 additions and 49 deletions
|
@ -6,7 +6,6 @@ use crate::sqlite3_ondisk::{
|
|||
use crate::types::{Cursor, CursorResult, OwnedRecord, OwnedValue};
|
||||
use crate::Result;
|
||||
|
||||
use std::borrow::BorrowMut;
|
||||
use std::cell::{Ref, RefCell};
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::{common, Completion, File, WriteCompletion, IO};
|
||||
use crate::{Result, LimboError};
|
||||
use super::{common, Completion, File, IO};
|
||||
use crate::{LimboError, Result};
|
||||
use libc::{c_short, fcntl, flock, iovec, F_SETLK};
|
||||
use log::{debug, trace};
|
||||
use nix::fcntl::{FcntlArg, OFlag};
|
||||
|
@ -95,7 +95,10 @@ impl IO for LinuxIO {
|
|||
while let Some(cqe) = ring.completion().next() {
|
||||
let result = cqe.result();
|
||||
if result < 0 {
|
||||
return Err(LimboError::LinuxIOError(format!("{}", LinuxIOError::IOUringCQError(result))));
|
||||
return Err(LimboError::LinuxIOError(format!(
|
||||
"{}",
|
||||
LinuxIOError::IOUringCQError(result)
|
||||
)));
|
||||
}
|
||||
let c = unsafe { Rc::from_raw(cqe.user_data() as *const Completion) };
|
||||
c.complete();
|
||||
|
@ -130,7 +133,9 @@ impl File for LinuxFile {
|
|||
if lock_result == -1 {
|
||||
let err = std::io::Error::last_os_error();
|
||||
if err.kind() == std::io::ErrorKind::WouldBlock {
|
||||
return Err(LimboError::LockingError("File is locked by another process".into()));
|
||||
return Err(LimboError::LockingError(
|
||||
"File is locked by another process".into(),
|
||||
));
|
||||
} else {
|
||||
return Err(LimboError::IOError(err));
|
||||
}
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
#![feature(box_into_raw_non_null)]
|
||||
use crate::buffer_pool::BufferPool;
|
||||
use crate::sqlite3_ondisk::BTreePage;
|
||||
use crate::sqlite3_ondisk::{self, DatabaseHeader};
|
||||
use crate::{PageSource, Result};
|
||||
use log::trace;
|
||||
use sieve_cache::SieveCache;
|
||||
use std::borrow::BorrowMut;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
use std::mem;
|
||||
use std::ptr::{drop_in_place, NonNull};
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
@ -105,10 +102,6 @@ impl PageCacheEntry {
|
|||
fn into_non_null(&mut self) -> NonNull<PageCacheEntry> {
|
||||
NonNull::new(&mut *self).unwrap()
|
||||
}
|
||||
|
||||
unsafe fn from_non_null(ptr: NonNull<PageCacheEntry>) -> Box<Self> {
|
||||
Box::from_raw(ptr.as_ptr())
|
||||
}
|
||||
}
|
||||
|
||||
struct DumbLruPageCache {
|
||||
|
@ -181,21 +174,21 @@ impl DumbLruPageCache {
|
|||
}
|
||||
|
||||
pub fn resize(&mut self, capacity: usize) {
|
||||
let _ = capacity;
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn detach(&mut self, entry: &mut PageCacheEntry) {
|
||||
let mut current = entry.into_non_null();
|
||||
|
||||
let mut next = None;
|
||||
let mut prev = None;
|
||||
unsafe {
|
||||
let (next, prev) = unsafe {
|
||||
let c = current.as_mut();
|
||||
next = c.next;
|
||||
prev = c.prev;
|
||||
let next = c.next;
|
||||
let prev = c.prev;
|
||||
c.prev = None;
|
||||
c.next = None;
|
||||
}
|
||||
(next, prev)
|
||||
};
|
||||
|
||||
// detach
|
||||
match (prev, next) {
|
||||
|
|
|
@ -51,6 +51,7 @@ impl Cursor for PseudoCursor {
|
|||
}
|
||||
|
||||
fn insert(&mut self, key: &OwnedValue, record: &OwnedRecord) -> Result<CursorResult<()>> {
|
||||
let _ = key;
|
||||
*self.current.borrow_mut() = Some(record.clone());
|
||||
Ok(CursorResult::Ok(()))
|
||||
}
|
||||
|
@ -64,6 +65,7 @@ impl Cursor for PseudoCursor {
|
|||
}
|
||||
|
||||
fn exists(&mut self, key: &OwnedValue) -> Result<bool> {
|
||||
let _ = key;
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ pub fn begin_write_database_header(header: &DatabaseHeader, pager: &Pager) -> Re
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BTreePageHeader {
|
||||
pub(crate) page_type: PageType,
|
||||
pub(crate) _first_freeblock_offset: u16,
|
||||
|
@ -200,7 +200,7 @@ pub struct BTreePageHeader {
|
|||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum PageType {
|
||||
IndexInterior = 2,
|
||||
TableInterior = 5,
|
||||
|
@ -222,7 +222,7 @@ impl TryFrom<u8> for PageType {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BTreePage {
|
||||
pub header: BTreePageHeader,
|
||||
pub cells: Vec<BTreeCell>,
|
||||
|
@ -340,7 +340,7 @@ pub fn begin_write_btree_page(pager: &Pager, page: &Rc<RefCell<Page>>) -> Result
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum BTreeCell {
|
||||
TableInteriorCell(TableInteriorCell),
|
||||
TableLeafCell(TableLeafCell),
|
||||
|
@ -348,27 +348,27 @@ pub enum BTreeCell {
|
|||
IndexLeafCell(IndexLeafCell),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TableInteriorCell {
|
||||
pub _left_child_page: u32,
|
||||
pub _rowid: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TableLeafCell {
|
||||
pub _rowid: u64,
|
||||
pub _payload: Vec<u8>,
|
||||
pub first_overflow_page: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct IndexInteriorCell {
|
||||
pub left_child_page: u32,
|
||||
pub payload: Vec<u8>,
|
||||
pub first_overflow_page: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct IndexLeafCell {
|
||||
pub payload: Vec<u8>,
|
||||
pub first_overflow_page: Option<u32>,
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
#[cfg(feature = "fs")]
|
||||
use crate::io::File;
|
||||
use crate::{
|
||||
error::LimboError,
|
||||
io::{Completion, WriteCompletion},
|
||||
Buffer, Result,
|
||||
};
|
||||
use crate::{error::LimboError, io::Completion, Buffer, Result};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub struct PageSource {
|
||||
|
@ -73,10 +69,6 @@ impl PageIO for FileStorage {
|
|||
}
|
||||
|
||||
fn write(&self, page_idx: usize, buffer: Rc<RefCell<Buffer>>, c: Rc<Completion>) -> Result<()> {
|
||||
let w = match &(*c) {
|
||||
Completion::Read(_) => unreachable!(),
|
||||
Completion::Write(w) => w,
|
||||
};
|
||||
let buffer_size = buffer.borrow().len();
|
||||
assert!(buffer_size >= 512);
|
||||
assert!(buffer_size <= 65536);
|
||||
|
|
|
@ -3,7 +3,7 @@ use sqlite3_parser::ast::{self, Expr, UnaryOperator};
|
|||
|
||||
use crate::{
|
||||
function::{Func, ScalarFunc},
|
||||
schema::{Schema, Table, Type},
|
||||
schema::{Table, Type},
|
||||
translate::select::{ColumnInfo, Select, SrcTable},
|
||||
util::normalize_ident,
|
||||
vdbe::{builder::ProgramBuilder, BranchOffset, Insn},
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use std::{cell::RefCell, ops::Deref, rc::Rc};
|
||||
|
||||
use sqlite3_parser::ast::{
|
||||
DistinctNames, InsertBody, Name, QualifiedName, ResolveType, ResultColumn, Select, With,
|
||||
DistinctNames, InsertBody, QualifiedName, ResolveType, ResultColumn, With,
|
||||
};
|
||||
|
||||
use crate::Result;
|
||||
use crate::{
|
||||
schema::{self, Schema, Table},
|
||||
schema::{Schema, Table},
|
||||
sqlite3_ondisk::DatabaseHeader,
|
||||
translate::expr::{resolve_ident_qualified, translate_expr},
|
||||
translate::expr::translate_expr,
|
||||
vdbe::{builder::ProgramBuilder, Insn, Program},
|
||||
};
|
||||
|
||||
|
@ -17,9 +17,9 @@ pub fn translate_insert(
|
|||
with: &Option<With>,
|
||||
or_conflict: &Option<ResolveType>,
|
||||
tbl_name: &QualifiedName,
|
||||
columns: &Option<DistinctNames>,
|
||||
_columns: &Option<DistinctNames>,
|
||||
body: &InsertBody,
|
||||
returning: &Option<Vec<ResultColumn>>,
|
||||
_returning: &Option<Vec<ResultColumn>>,
|
||||
database_header: Rc<RefCell<DatabaseHeader>>,
|
||||
) -> Result<Program> {
|
||||
assert!(with.is_none());
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use std::fmt::Display;
|
||||
use std::io::Read;
|
||||
use std::{cell::Ref, rc::Rc};
|
||||
|
||||
use crate::error::LimboError;
|
||||
|
|
|
@ -251,21 +251,21 @@ impl ProgramBuilder {
|
|||
*pc_if_next = to_offset;
|
||||
}
|
||||
Insn::InitCoroutine {
|
||||
yield_reg,
|
||||
yield_reg: _,
|
||||
jump_on_definition,
|
||||
start_offset,
|
||||
start_offset: _,
|
||||
} => {
|
||||
*jump_on_definition = to_offset;
|
||||
}
|
||||
Insn::NotExists {
|
||||
cursor,
|
||||
rowid_reg,
|
||||
cursor: _,
|
||||
rowid_reg: _,
|
||||
target_pc,
|
||||
} => {
|
||||
*target_pc = to_offset;
|
||||
}
|
||||
Insn::Yield {
|
||||
yield_reg,
|
||||
yield_reg: _,
|
||||
end_offset,
|
||||
} => {
|
||||
*end_offset = to_offset;
|
||||
|
|
|
@ -1300,7 +1300,7 @@ impl Program {
|
|||
cursor,
|
||||
key_reg,
|
||||
record_reg,
|
||||
flag,
|
||||
flag: _,
|
||||
} => {
|
||||
let cursor = cursors.get_mut(cursor).unwrap();
|
||||
let record = match &state.registers[*record_reg] {
|
||||
|
@ -1323,7 +1323,7 @@ impl Program {
|
|||
cursor.wait_for_completion()?;
|
||||
state.pc += 1;
|
||||
}
|
||||
Insn::NewRowid { reg } => todo!(),
|
||||
Insn::NewRowid { reg: _ } => todo!(),
|
||||
Insn::MustBeInt { reg } => {
|
||||
match state.registers[*reg] {
|
||||
OwnedValue::Integer(_) => {}
|
||||
|
|
|
@ -80,6 +80,7 @@ impl Cursor for Sorter {
|
|||
}
|
||||
|
||||
fn insert(&mut self, key: &OwnedValue, record: &OwnedRecord) -> Result<CursorResult<()>> {
|
||||
let _ = key;
|
||||
let key_fields = self.order.len();
|
||||
let key = OwnedRecord::new(record.values[0..key_fields].to_vec());
|
||||
self.insert(key, OwnedRecord::new(record.values[key_fields..].to_vec()));
|
||||
|
@ -95,6 +96,7 @@ impl Cursor for Sorter {
|
|||
}
|
||||
|
||||
fn exists(&mut self, key: &OwnedValue) -> Result<bool> {
|
||||
let _ = key;
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue