mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-10 18:54:22 +01:00
Adding indexes to the update plan
This commit is contained in:
@@ -668,6 +668,25 @@ fn emit_update_insns(
|
||||
_ => return Ok(()),
|
||||
};
|
||||
|
||||
// dbg!(&plan.indexes);
|
||||
// THIS IS SAME CODE AS WE HAVE ON INSERT
|
||||
// allocate cursor id's for each btree index cursor we'll need to populate the indexes
|
||||
// (idx name, root_page, idx cursor id)
|
||||
let idx_cursors = plan
|
||||
.indexes_to_update
|
||||
.iter()
|
||||
.map(|idx| {
|
||||
(
|
||||
&idx.name,
|
||||
idx.root_page,
|
||||
program.alloc_cursor_id(
|
||||
Some(idx.table_name.clone()),
|
||||
CursorType::BTreeIndex(idx.clone()),
|
||||
),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<(&String, usize, usize)>>();
|
||||
|
||||
for cond in plan
|
||||
.where_clause
|
||||
.iter()
|
||||
|
||||
@@ -82,7 +82,7 @@ impl IdxInsertFlags {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum RegisterOrLiteral<T: Copy> {
|
||||
pub enum RegisterOrLiteral<T: Copy + std::fmt::Display> {
|
||||
Register(usize),
|
||||
Literal(T),
|
||||
}
|
||||
@@ -93,6 +93,15 @@ impl From<PageIdx> for RegisterOrLiteral<PageIdx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy + std::fmt::Display> std::fmt::Display for RegisterOrLiteral<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Literal(lit) => lit.fmt(f),
|
||||
Self::Register(reg) => reg.fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Description, Debug)]
|
||||
pub enum Insn {
|
||||
/// Initialize the program state and jump to the given PC.
|
||||
|
||||
Reference in New Issue
Block a user