From 72dac5981395e572b0dd910b8ea03eaeb357a188 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Tue, 15 Apr 2025 11:18:09 +0300 Subject: [PATCH] Operation: add method index() to retrieve used index, if any --- core/translate/plan.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/translate/plan.rs b/core/translate/plan.rs index ab7bc893c..4bf86ab8d 100644 --- a/core/translate/plan.rs +++ b/core/translate/plan.rs @@ -281,6 +281,17 @@ pub enum Operation { }, } +impl Operation { + pub fn index(&self) -> Option<&Arc> { + match self { + Operation::Scan { index, .. } => index.as_ref(), + Operation::Search(Search::RowidEq { .. }) => None, + Operation::Search(Search::Seek { index, .. }) => index.as_ref(), + Operation::Subquery { .. } => None, + } + } +} + impl TableReference { /// Returns the btree table for this table reference, if it is a BTreeTable. pub fn btree(&self) -> Option> {