mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 01:58:16 +00:00
assertions and small cleanups
This commit is contained in:
parent
8b1f0ea23c
commit
750a9c6463
4 changed files with 20 additions and 14 deletions
|
@ -66,8 +66,14 @@ impl Table {
|
|||
|
||||
pub fn get_column_at(&self, index: usize) -> &Column {
|
||||
match self {
|
||||
Self::BTree(table) => table.columns.get(index).unwrap(),
|
||||
Self::Pseudo(table) => table.columns.get(index).unwrap(),
|
||||
Self::BTree(table) => table
|
||||
.columns
|
||||
.get(index)
|
||||
.expect("column index out of bounds"),
|
||||
Self::Pseudo(table) => table
|
||||
.columns
|
||||
.get(index)
|
||||
.expect("column index out of bounds"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,10 @@ pub fn init_loop(
|
|||
tables: &[TableReference],
|
||||
mode: &OperationMode,
|
||||
) -> Result<()> {
|
||||
assert!(
|
||||
t_ctx.meta_left_joins.len() == tables.len(),
|
||||
"meta_left_joins length does not match tables length"
|
||||
);
|
||||
for (table_index, table) in tables.iter().enumerate() {
|
||||
// Initialize bookkeeping for OUTER JOIN
|
||||
if let Some(join_info) = table.join_info.as_ref() {
|
||||
|
|
|
@ -302,14 +302,13 @@ impl Optimizable for ast::Expr {
|
|||
if *table != table_index {
|
||||
return Ok(None);
|
||||
}
|
||||
let available_indexes_for_table =
|
||||
available_indexes.get(table_reference.table.get_name());
|
||||
if available_indexes_for_table.is_none() {
|
||||
let Some(available_indexes_for_table) =
|
||||
available_indexes.get(table_reference.table.get_name())
|
||||
else {
|
||||
return Ok(None);
|
||||
}
|
||||
let available_indexes_for_table = available_indexes_for_table.unwrap();
|
||||
};
|
||||
let column = table_reference.table.get_column_at(*column);
|
||||
for index in available_indexes_for_table.iter() {
|
||||
let column = table_reference.table.get_column_at(*column);
|
||||
if index.columns.first().unwrap().name == column.name {
|
||||
return Ok(Some(index.clone()));
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ use super::{BranchOffset, CursorID, Insn, InsnReference, Program};
|
|||
#[allow(dead_code)]
|
||||
pub struct ProgramBuilder {
|
||||
next_free_register: usize,
|
||||
next_free_label: u32,
|
||||
next_free_cursor_id: usize,
|
||||
insns: Vec<Insn>,
|
||||
// for temporarily storing instructions that will be put after Transaction opcode
|
||||
|
@ -23,7 +22,7 @@ pub struct ProgramBuilder {
|
|||
next_insn_label: Option<BranchOffset>,
|
||||
// Cursors that are referenced by the program. Indexed by CursorID.
|
||||
pub cursor_ref: Vec<(Option<String>, CursorType)>,
|
||||
// Hashmap of label to insn reference. Resolved in build().
|
||||
/// A vector where index=label number, value=resolved offset. Resolved in build().
|
||||
label_to_resolved_offset: Vec<Option<InsnReference>>,
|
||||
// Bitmask of cursors that have emitted a SeekRowid instruction.
|
||||
seekrowid_emitted_bitmask: u64,
|
||||
|
@ -51,7 +50,6 @@ impl ProgramBuilder {
|
|||
pub fn new() -> Self {
|
||||
Self {
|
||||
next_free_register: 1,
|
||||
next_free_label: 0,
|
||||
next_free_cursor_id: 0,
|
||||
insns: Vec::new(),
|
||||
next_insn_label: None,
|
||||
|
@ -185,10 +183,9 @@ impl ProgramBuilder {
|
|||
}
|
||||
|
||||
pub fn allocate_label(&mut self) -> BranchOffset {
|
||||
let label_n = self.next_free_label;
|
||||
self.next_free_label += 1;
|
||||
let label_n = self.label_to_resolved_offset.len();
|
||||
self.label_to_resolved_offset.push(None);
|
||||
BranchOffset::Label(label_n)
|
||||
BranchOffset::Label(label_n as u32)
|
||||
}
|
||||
|
||||
// Effectively a GOTO <next insn> without the need to emit an explicit GOTO instruction.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue