From 35b96ae8d8348aa700d220c1343aea2885d75eba Mon Sep 17 00:00:00 2001 From: Nikita Sivukhin Date: Mon, 27 Oct 2025 18:17:49 +0400 Subject: [PATCH] fix few places which needs to be hooked into new types --- cli/app.rs | 2 +- core/translate/display.rs | 27 +++++++++++++++++++++++++++ core/translate/subquery.rs | 4 ++++ core/types.rs | 10 ++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/cli/app.rs b/cli/app.rs index 9ae6b220e..a31cafc73 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -865,7 +865,7 @@ impl Limbo { ) -> usize { let indent_count = match prev_insn { "Rewind" | "Last" | "SorterSort" | "SeekGE" | "SeekGT" | "SeekLE" - | "SeekLT" | "BeginSubrtn" => indent_count + 1, + | "SeekLT" | "BeginSubrtn" | "IndexMethodQuery" => indent_count + 1, _ => indent_count, }; diff --git a/core/translate/display.rs b/core/translate/display.rs index 5939407dc..2b590d69b 100644 --- a/core/translate/display.rs +++ b/core/translate/display.rs @@ -119,6 +119,15 @@ impl Display for SelectPlan { )?; } }, + Operation::IndexMethodQuery(query) => { + let index_method = query.index.index_method.as_ref().unwrap(); + writeln!( + f, + "{}QUERY INDEX METHOD {}", + indent, + index_method.definition().method_name + )?; + } } } Ok(()) @@ -161,6 +170,15 @@ impl Display for DeletePlan { )?; } }, + Operation::IndexMethodQuery(query) => { + let module = query.index.index_method.as_ref().unwrap(); + writeln!( + f, + "{}QUERY MODULE {}", + indent, + module.definition().method_name + )?; + } } } Ok(()) @@ -215,6 +233,15 @@ impl fmt::Display for UpdatePlan { )?; } }, + Operation::IndexMethodQuery(query) => { + let module = query.index.index_method.as_ref().unwrap(); + writeln!( + f, + "{}QUERY MODULE {}", + indent, + module.definition().method_name + )?; + } } } if !self.order_by.is_empty() { diff --git a/core/translate/subquery.rs b/core/translate/subquery.rs index 38dd7b4b0..a2bc5e874 100644 --- a/core/translate/subquery.rs +++ b/core/translate/subquery.rs @@ -390,6 +390,10 @@ pub fn emit_from_clause_subqueries( ) } }, + Operation::IndexMethodQuery(query) => { + let index_method = query.index.index_method.as_ref().unwrap(); + format!("QUERY INDEX METHOD {}", index_method.definition().method_name) + } } ); diff --git a/core/types.rs b/core/types.rs index a7259f8b1..617d68a2e 100644 --- a/core/types.rs +++ b/core/types.rs @@ -5,6 +5,7 @@ use turso_parser::ast::SortOrder; use crate::error::LimboError; use crate::ext::{ExtValue, ExtValueType}; +use crate::index_method::IndexMethodCursor; use crate::numeric::format_float; use crate::pseudo::PseudoCursor; use crate::schema::Index; @@ -2271,6 +2272,7 @@ impl Record { pub enum Cursor { BTree(Box), + IndexMethod(Box), Pseudo(PseudoCursor), Sorter(Sorter), Virtual(VirtualTableCursor), @@ -2281,6 +2283,7 @@ impl Debug for Cursor { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::BTree(..) => f.debug_tuple("BTree").finish(), + Self::IndexMethod(..) => f.debug_tuple("IndexMethod").finish(), Self::Pseudo(..) => f.debug_tuple("Pseudo").finish(), Self::Sorter(..) => f.debug_tuple("Sorter").finish(), Self::Virtual(..) => f.debug_tuple("Virtual").finish(), @@ -2344,6 +2347,13 @@ impl Cursor { _ => panic!("Cursor is not a materialized view cursor"), } } + + pub fn as_index_method_mut(&mut self) -> &mut dyn IndexMethodCursor { + match self { + Self::IndexMethod(cursor) => cursor.as_mut(), + _ => panic!("Cursor is not an IndexMethod cursor"), + } + } } #[derive(Debug)]