mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-07-07 12:35:00 +00:00
fix: lint warnings
This commit is contained in:
parent
0e60f077ca
commit
00c26286ce
12 changed files with 50 additions and 60 deletions
|
@ -88,7 +88,7 @@ fn handle_dot_command(
|
|||
|
||||
match args[0] {
|
||||
".schema" => {
|
||||
let table_name = args.get(1).map(|s| *s);
|
||||
let table_name = args.get(1).copied();
|
||||
display_schema(io, conn, table_name)?;
|
||||
}
|
||||
".opcodes" => {
|
||||
|
@ -129,13 +129,13 @@ fn display_schema(
|
|||
),
|
||||
};
|
||||
|
||||
match conn.query(&sql) {
|
||||
match conn.query(sql) {
|
||||
Ok(Some(ref mut rows)) => {
|
||||
let mut found = false;
|
||||
loop {
|
||||
match rows.next()? {
|
||||
RowResult::Row(row) => {
|
||||
if let Some(Value::Text(schema)) = row.values.get(0) {
|
||||
if let Some(Value::Text(schema)) = row.values.first() {
|
||||
println!("{};", schema);
|
||||
found = true;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ pub struct OpCodeDescription {
|
|||
|
||||
impl Display for OpCodeDescription {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
return write!(f, "{}\n-------\n{}", self.name, self.description);
|
||||
write!(f, "{}\n-------\n{}", self.name, self.description)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,9 @@ impl IO for LinuxIO {
|
|||
trace!("run_once()");
|
||||
let mut ring = self.ring.borrow_mut();
|
||||
ring.submit_and_wait(1)?;
|
||||
loop {
|
||||
match ring.completion().next() {
|
||||
Some(cqe) => {
|
||||
let c = unsafe { Rc::from_raw(cqe.user_data() as *const Completion) };
|
||||
c.complete();
|
||||
}
|
||||
None => break,
|
||||
}
|
||||
while let Some(cqe) = ring.completion().next() {
|
||||
let c = unsafe { Rc::from_raw(cqe.user_data() as *const Completion) };
|
||||
c.complete();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -92,6 +92,10 @@ impl Buffer {
|
|||
self.data.len()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.data.is_empty()
|
||||
}
|
||||
|
||||
pub fn as_slice(&self) -> &[u8] {
|
||||
&self.data
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ impl Database {
|
|||
}
|
||||
let root_page: i64 = row.get::<i64>(3)?;
|
||||
let sql: &str = row.get::<&str>(4)?;
|
||||
let table = schema::BTreeTable::from_sql(&sql, root_page as usize)?;
|
||||
let table = schema::BTreeTable::from_sql(sql, root_page as usize)?;
|
||||
schema.add_table(Rc::new(table));
|
||||
}
|
||||
RowResult::IO => {
|
||||
|
|
|
@ -40,10 +40,7 @@ pub enum Table {
|
|||
|
||||
impl Table {
|
||||
pub fn is_pseudo(&self) -> bool {
|
||||
match self {
|
||||
Table::Pseudo(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, Table::Pseudo(_))
|
||||
}
|
||||
|
||||
pub fn column_is_rowid_alias(&self, col: &Column) -> bool {
|
||||
|
@ -167,23 +164,22 @@ fn create_table(
|
|||
} => {
|
||||
if let Some(constraints) = constraints {
|
||||
for c in constraints {
|
||||
match c.constraint {
|
||||
sqlite3_parser::ast::TableConstraint::PrimaryKey { columns, .. } => {
|
||||
for column in columns {
|
||||
primary_key_column_names.push(match column.expr {
|
||||
Expr::Id(id) => normalize_ident(&id.0),
|
||||
Expr::Literal(Literal::String(value)) => {
|
||||
value.trim_matches('\'').to_owned()
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Unsupported primary key expression"
|
||||
))
|
||||
}
|
||||
});
|
||||
}
|
||||
if let sqlite3_parser::ast::TableConstraint::PrimaryKey { columns, .. } =
|
||||
c.constraint
|
||||
{
|
||||
for column in columns {
|
||||
primary_key_column_names.push(match column.expr {
|
||||
Expr::Id(id) => normalize_ident(&id.0),
|
||||
Expr::Literal(Literal::String(value)) => {
|
||||
value.trim_matches('\'').to_owned()
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Unsupported primary key expression"
|
||||
))
|
||||
}
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -248,11 +244,9 @@ pub fn build_pseudo_table(columns: &[ResultColumn]) -> PseudoTable {
|
|||
let table = PseudoTable::new();
|
||||
for column in columns {
|
||||
match column {
|
||||
ResultColumn::Expr(expr, _as_name) => match expr {
|
||||
_ => {
|
||||
todo!("unsupported expression {:?}", expr);
|
||||
}
|
||||
},
|
||||
ResultColumn::Expr(expr, _as_name) => {
|
||||
todo!("unsupported expression {:?}", expr);
|
||||
}
|
||||
ResultColumn::Star => {
|
||||
todo!();
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ pub fn begin_read_btree_page(
|
|||
let buf = Buffer::new(buf, drop_fn);
|
||||
let complete = Box::new(move |buf: &Buffer| {
|
||||
let page = page.clone();
|
||||
if let Err(_) = finish_read_btree_page(page_idx, buf, page.clone()) {
|
||||
if finish_read_btree_page(page_idx, buf, page.clone()).is_err() {
|
||||
page.set_error();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -73,7 +73,7 @@ impl PageIO for FileStorage {
|
|||
let size = c.buf().len();
|
||||
assert!(page_idx > 0);
|
||||
ensure!(
|
||||
size >= 1 << 9 && size <= 1 << 16 && size & (size - 1) == 0,
|
||||
(1 << 9..=1 << 16).contains(&size) && size & (size - 1) == 0,
|
||||
StorageError::NotADB
|
||||
);
|
||||
let pos = (page_idx - 1) * size;
|
||||
|
|
|
@ -336,7 +336,7 @@ fn analyze_column(column: &sqlite3_parser::ast::ResultColumn, column_info_out: &
|
|||
} else {
|
||||
column_info_out.func = func_type;
|
||||
// TODO(pere): use lifetimes for args? Arenas would be lovely here :(
|
||||
column_info_out.args = args.clone();
|
||||
column_info_out.args.clone_from(args);
|
||||
}
|
||||
}
|
||||
ast::Expr::FunctionCallStar { .. } => todo!(),
|
||||
|
@ -388,9 +388,9 @@ fn translate_expr(
|
|||
ast::Expr::Literal(lit) => match lit {
|
||||
ast::Literal::Numeric(val) => {
|
||||
let maybe_int = val.parse::<i64>();
|
||||
if maybe_int.is_ok() {
|
||||
if let Ok(int_value) = maybe_int {
|
||||
program.emit_insn(Insn::Integer {
|
||||
value: maybe_int.unwrap(),
|
||||
value: int_value,
|
||||
dest: target_register,
|
||||
});
|
||||
} else {
|
||||
|
@ -439,7 +439,7 @@ fn translate_aggregation(
|
|||
assert!(info.func.is_some());
|
||||
let func = info.func.as_ref().unwrap();
|
||||
let empty_args = &Vec::<ast::Expr>::new();
|
||||
let args = info.args.as_ref().unwrap_or_else(|| empty_args);
|
||||
let args = info.args.as_ref().unwrap_or(empty_args);
|
||||
let dest = match func {
|
||||
AggFunc::Avg => {
|
||||
if args.len() != 1 {
|
||||
|
@ -471,7 +471,7 @@ fn translate_aggregation(
|
|||
});
|
||||
target_register
|
||||
}
|
||||
|
||||
|
||||
AggFunc::GroupConcat => todo!(),
|
||||
AggFunc::Max => todo!(),
|
||||
AggFunc::Min => todo!(),
|
||||
|
@ -552,8 +552,8 @@ fn translate_pragma(
|
|||
Ok(program.build())
|
||||
}
|
||||
|
||||
fn update_pragma(name: &String, value: i64, header: Rc<RefCell<DatabaseHeader>>, pager: Rc<Pager>) {
|
||||
match name.as_str() {
|
||||
fn update_pragma(name: &str, value: i64, header: Rc<RefCell<DatabaseHeader>>, pager: Rc<Pager>) {
|
||||
match name {
|
||||
"cache_size" => {
|
||||
let mut cache_size_unformatted = value;
|
||||
let mut cache_size = if cache_size_unformatted < 0 {
|
||||
|
|
|
@ -195,7 +195,7 @@ impl<'a> FromValue<'a> for String {
|
|||
impl<'a> FromValue<'a> for &'a str {
|
||||
fn from_value(value: &Value<'a>) -> Result<&'a str> {
|
||||
match value {
|
||||
Value::Text(s) => Ok(&s),
|
||||
Value::Text(s) => Ok(s),
|
||||
_ => anyhow::bail!("Expected text value"),
|
||||
}
|
||||
}
|
||||
|
|
14
core/vdbe.rs
14
core/vdbe.rs
|
@ -267,7 +267,7 @@ impl Program {
|
|||
println!("addr opcode p1 p2 p3 p4 p5 comment");
|
||||
println!("---- ------------- ---- ---- ---- ------------- -- -------");
|
||||
for (addr, insn) in self.insns.iter().enumerate() {
|
||||
print_insn(addr.try_into().unwrap(), insn);
|
||||
print_insn(addr, insn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ impl Program {
|
|||
pager: Rc<Pager>,
|
||||
) -> Result<StepResult<'a>> {
|
||||
loop {
|
||||
let insn = &self.insns[state.pc as usize];
|
||||
let insn = &self.insns[state.pc];
|
||||
trace_insn(state.pc, insn);
|
||||
let mut cursors = state.cursors.borrow_mut();
|
||||
match insn {
|
||||
|
@ -288,7 +288,7 @@ impl Program {
|
|||
cursor_id,
|
||||
root_page,
|
||||
} => {
|
||||
let cursor = Box::new(BTreeCursor::new(pager.clone(), *root_page as usize));
|
||||
let cursor = Box::new(BTreeCursor::new(pager.clone(), *root_page));
|
||||
cursors.insert(*cursor_id, cursor);
|
||||
state.pc += 1;
|
||||
}
|
||||
|
@ -557,16 +557,16 @@ impl Program {
|
|||
|
||||
fn make_record<'a>(registers: &'a [OwnedValue], start_reg: &usize, count: &usize) -> Record<'a> {
|
||||
let mut values = Vec::with_capacity(*count);
|
||||
for i in *start_reg..*start_reg + count {
|
||||
values.push(crate::types::to_value(®isters[i]));
|
||||
for r in registers.iter().skip(*start_reg).take(*count) {
|
||||
values.push(crate::types::to_value(r))
|
||||
}
|
||||
Record::new(values)
|
||||
}
|
||||
|
||||
fn make_owned_record(registers: &[OwnedValue], start_reg: &usize, count: &usize) -> OwnedRecord {
|
||||
let mut values = Vec::with_capacity(*count);
|
||||
for i in *start_reg..*start_reg + count {
|
||||
values.push(registers[i].clone());
|
||||
for r in registers.iter().skip(*start_reg).take(*count) {
|
||||
values.push(r.clone())
|
||||
}
|
||||
OwnedRecord::new(values)
|
||||
}
|
||||
|
|
|
@ -138,10 +138,7 @@ pub unsafe extern "C" fn sqlite3_column_text(
|
|||
None => return std::ptr::null(),
|
||||
};
|
||||
match row.values.get(idx as usize) {
|
||||
Some(value) => match value {
|
||||
limbo_core::Value::Text(text) => text.as_bytes().as_ptr(),
|
||||
_ => std::ptr::null(),
|
||||
},
|
||||
None => std::ptr::null(),
|
||||
Some(limbo_core::Value::Text(text)) => text.as_bytes().as_ptr(),
|
||||
_ => std::ptr::null(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue