mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 08:55:40 +01:00
Apply fmt, clippy
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
use crate::translate::emitter::emit_program_for_delete;
|
||||
use crate::translate::optimizer::optimize_delete_plan;
|
||||
use crate::translate::planner::prepare_delete_plan;
|
||||
use crate::{
|
||||
schema::Schema,
|
||||
storage::sqlite3_ondisk::DatabaseHeader,
|
||||
vdbe::Program,
|
||||
};
|
||||
use crate::{schema::Schema, storage::sqlite3_ondisk::DatabaseHeader, vdbe::Program};
|
||||
use crate::{Connection, Result};
|
||||
use sqlite3_parser::ast::{Expr, QualifiedName, ResultColumn};
|
||||
use std::rc::Weak;
|
||||
|
||||
@@ -532,7 +532,7 @@ fn init_source_for_delete(
|
||||
let root_page = table_reference.table.root_page;
|
||||
let next_row_label = program.allocate_label();
|
||||
metadata.next_row_labels.insert(*id, next_row_label);
|
||||
program.emit_insn(Insn::OpenWriteAsync{
|
||||
program.emit_insn(Insn::OpenWriteAsync {
|
||||
cursor_id,
|
||||
root_page,
|
||||
});
|
||||
@@ -573,9 +573,7 @@ fn init_source_for_delete(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
SourceOperator::Nothing => {
|
||||
Ok(())
|
||||
}
|
||||
SourceOperator::Nothing => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//! a SELECT statement will be translated into a sequence of instructions that
|
||||
//! will read rows from the database and filter them according to a WHERE clause.
|
||||
|
||||
pub(crate) mod delete;
|
||||
pub(crate) mod emitter;
|
||||
pub(crate) mod expr;
|
||||
pub(crate) mod insert;
|
||||
@@ -14,7 +15,6 @@ pub(crate) mod optimizer;
|
||||
pub(crate) mod plan;
|
||||
pub(crate) mod planner;
|
||||
pub(crate) mod select;
|
||||
pub(crate) mod delete;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::fmt::Display;
|
||||
@@ -24,13 +24,13 @@ use std::str::FromStr;
|
||||
use crate::schema::Schema;
|
||||
use crate::storage::pager::Pager;
|
||||
use crate::storage::sqlite3_ondisk::{DatabaseHeader, MIN_PAGE_CACHE_SIZE};
|
||||
use crate::translate::delete::translate_delete;
|
||||
use crate::vdbe::{builder::ProgramBuilder, Insn, Program};
|
||||
use crate::{bail_parse_error, Connection, Result};
|
||||
use insert::translate_insert;
|
||||
use select::translate_select;
|
||||
use sqlite3_parser::ast::fmt::ToTokens;
|
||||
use sqlite3_parser::ast::{self, PragmaName};
|
||||
use crate::translate::delete::translate_delete;
|
||||
|
||||
/// Translate SQL statement into bytecode program.
|
||||
pub fn translate(
|
||||
@@ -77,17 +77,15 @@ pub fn translate(
|
||||
where_clause,
|
||||
returning,
|
||||
order_by,
|
||||
limit
|
||||
} => {
|
||||
translate_delete(
|
||||
schema,
|
||||
&tbl_name,
|
||||
where_clause,
|
||||
&returning,
|
||||
database_header,
|
||||
connection
|
||||
)
|
||||
}
|
||||
limit,
|
||||
} => translate_delete(
|
||||
schema,
|
||||
&tbl_name,
|
||||
where_clause,
|
||||
&returning,
|
||||
database_header,
|
||||
connection,
|
||||
),
|
||||
ast::Stmt::Detach(_) => bail_parse_error!("DETACH not supported yet"),
|
||||
ast::Stmt::DropIndex { .. } => bail_parse_error!("DROP INDEX not supported yet"),
|
||||
ast::Stmt::DropTable { .. } => bail_parse_error!("DROP TABLE not supported yet"),
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use super::{
|
||||
plan::{
|
||||
Aggregate, BTreeTableReference, Direction, GroupBy, Plan, ResultSetColumn, SourceOperator,
|
||||
},
|
||||
use super::plan::{
|
||||
Aggregate, BTreeTableReference, Direction, GroupBy, Plan, ResultSetColumn, SourceOperator,
|
||||
};
|
||||
use crate::{function::Func, schema::Schema, util::normalize_ident, Result};
|
||||
use sqlite3_parser::ast::{self, Expr, FromClause, JoinType, QualifiedName, ResultColumn};
|
||||
@@ -753,7 +751,7 @@ pub fn prepare_delete_plan(
|
||||
let table_ref = BTreeTableReference {
|
||||
table: table.clone(),
|
||||
table_identifier: table_name.clone(),
|
||||
table_index: 0
|
||||
table_index: 0,
|
||||
};
|
||||
|
||||
// Parse and resolve the where_clause
|
||||
@@ -772,7 +770,7 @@ pub fn prepare_delete_plan(
|
||||
id: 0,
|
||||
table_reference: table_ref.clone(),
|
||||
predicates: resolved_where_clause.clone(),
|
||||
iter_dir: None
|
||||
iter_dir: None,
|
||||
},
|
||||
result_columns: vec![],
|
||||
where_clause: resolved_where_clause,
|
||||
@@ -782,7 +780,7 @@ pub fn prepare_delete_plan(
|
||||
limit: None,
|
||||
referenced_tables: vec![table_ref],
|
||||
available_indexes: vec![],
|
||||
contains_constant_false_condition: false
|
||||
contains_constant_false_condition: false,
|
||||
};
|
||||
|
||||
Ok(plan)
|
||||
|
||||
@@ -489,7 +489,7 @@ pub enum Insn {
|
||||
},
|
||||
|
||||
DeleteAwait {
|
||||
cursor_id: CursorID
|
||||
cursor_id: CursorID,
|
||||
},
|
||||
|
||||
NewRowid {
|
||||
@@ -2656,17 +2656,17 @@ impl Program {
|
||||
}
|
||||
}
|
||||
state.pc += 1;
|
||||
},
|
||||
}
|
||||
Insn::DeleteAsync { cursor_id } => {
|
||||
let cursor = cursors.get_mut(cursor_id).unwrap();
|
||||
return_if_io!(cursor.delete());
|
||||
state.pc += 1;
|
||||
},
|
||||
}
|
||||
Insn::DeleteAwait { cursor_id } => {
|
||||
let cursor = cursors.get_mut(cursor_id).unwrap();
|
||||
cursor.wait_for_completion()?;
|
||||
state.pc += 1;
|
||||
},
|
||||
}
|
||||
Insn::NewRowid {
|
||||
cursor, rowid_reg, ..
|
||||
} => {
|
||||
@@ -3897,7 +3897,7 @@ mod tests {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn delete(&mut self, key: &OwnedValue) -> Result<CursorResult<()>> {
|
||||
fn delete(&mut self) -> Result<CursorResult<()>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user