diff --git a/src/sql/engine/engine.rs b/src/sql/engine/engine.rs index 9ce71cf24..24452442c 100644 --- a/src/sql/engine/engine.rs +++ b/src/sql/engine/engine.rs @@ -61,15 +61,8 @@ pub trait Transaction { fn scan(&self, table: &str, filter: Option) -> Result; /// Updates table rows by primary key. Uses a BTreeMap for test determinism. fn update(&self, table: &str, rows: BTreeMap) -> Result<()>; - - /// Scans a column's index entries. - /// TODO: this is only used for tests, remove it. - fn scan_index(&self, table: &str, column: &str) -> Result; } -/// An index scan iterator. -pub type IndexScan = Box)>>>; - /// The catalog stores table schema information. It is required for /// Engine::Transaction, and thus fully transactional. For simplicity, it only /// supports very simple operations: creating and dropping tables. There are no diff --git a/src/sql/engine/local.rs b/src/sql/engine/local.rs index f8df0bad9..6adad0a7e 100644 --- a/src/sql/engine/local.rs +++ b/src/sql/engine/local.rs @@ -1,9 +1,9 @@ use super::Catalog; use crate::encoding::{self, Key as _, Value as _}; +use crate::errinput; use crate::error::Result; use crate::sql::types::{Expression, Row, Rows, Table, Value}; use crate::storage::{self, mvcc}; -use crate::{errdata, errinput}; use serde::{Deserialize, Serialize}; use std::borrow::Cow; @@ -268,22 +268,6 @@ impl super::Transaction for Transaction { )) } - fn scan_index(&self, table: &str, column: &str) -> Result { - debug_assert!(self.has_index(table, column)?, "index scan without index"); - Ok(Box::new( - self.txn.scan_prefix(&KeyPrefix::Index(table.into(), column.into()).encode()).map( - |r| { - r.and_then(|(k, v)| { - let Key::Index(_, _, value) = Key::decode(&k)? else { - return errdata!("invalid index key"); - }; - Ok((value.into_owned(), BTreeSet::decode(&v)?)) - }) - }, - ), - )) - } - fn update(&self, table: &str, rows: BTreeMap) -> Result<()> { let table = self.must_get_table(table)?; diff --git a/src/sql/engine/mod.rs b/src/sql/engine/mod.rs index 27426e9e2..aadd19c29 100644 --- a/src/sql/engine/mod.rs +++ b/src/sql/engine/mod.rs @@ -3,7 +3,7 @@ mod local; mod raft; mod session; -pub use engine::{Catalog, Engine, IndexScan, Transaction}; +pub use engine::{Catalog, Engine, Transaction}; pub use local::{Key, Local}; pub use raft::{Raft, Status}; pub use session::{Session, StatementResult}; diff --git a/src/sql/engine/raft.rs b/src/sql/engine/raft.rs index 321ef730e..60a2219f7 100644 --- a/src/sql/engine/raft.rs +++ b/src/sql/engine/raft.rs @@ -1,4 +1,4 @@ -use super::{Catalog, Engine as _, IndexScan, Transaction as _}; +use super::{Catalog, Engine as _, Transaction as _}; use crate::encoding::{self, bincode, Value as _}; use crate::errdata; use crate::error::Result; @@ -187,15 +187,6 @@ impl<'a> super::Transaction for Transaction<'a> { Ok(Box::new(scan.into_iter().map(Ok))) } - fn scan_index(&self, table: &str, column: &str) -> Result { - let scan: Vec<_> = self.engine.read(Read::ScanIndex { - txn: (&self.state).into(), - table: table.into(), - column: column.into(), - })?; - Ok(Box::new(scan.into_iter().map(Ok))) - } - fn update(&self, table: &str, rows: BTreeMap) -> Result<()> { self.engine.write(Write::Update { txn: (&self.state).into(), table: table.into(), rows }) } @@ -338,13 +329,6 @@ impl raft::State for State { .collect::>>()? .encode() } - Read::ScanIndex { txn, table, column } => self - .local - .resume(txn.into_owned())? - .scan_index(&table, &column)? - .collect::>>()? - .encode(), - Read::GetTable { txn, table } => { self.local.resume(txn.into_owned())?.get_table(&table)?.encode() } @@ -380,11 +364,6 @@ enum Read<'a> { table: Cow<'a, str>, filter: Option, }, - ScanIndex { - txn: Cow<'a, mvcc::TransactionState>, - table: Cow<'a, str>, - column: Cow<'a, str>, - }, GetTable { txn: Cow<'a, mvcc::TransactionState>,