vibesql_executor/index_ddl/
mod.rs

1//! CREATE INDEX, DROP INDEX, REINDEX, and ANALYZE statement execution
2//!
3//! This module provides executors for index DDL and statistics operations.
4//!
5//! # Structure
6//!
7//! - `create_index.rs` - CREATE INDEX executor
8//! - `drop_index.rs` - DROP INDEX executor
9//! - `reindex.rs` - REINDEX executor
10//! - `analyze.rs` - ANALYZE executor
11
12pub mod analyze;
13pub mod create_index;
14pub mod drop_index;
15pub mod reindex;
16
17pub use analyze::AnalyzeExecutor;
18pub use create_index::CreateIndexExecutor;
19pub use drop_index::DropIndexExecutor;
20pub use reindex::ReindexExecutor;
21use vibesql_ast::{CreateIndexStmt, DropIndexStmt, ReindexStmt};
22use vibesql_storage::Database;
23
24use crate::errors::ExecutorError;
25
26/// Unified executor for index operations (CREATE, DROP, and REINDEX INDEX)
27///
28/// This struct provides backward compatibility with the original API,
29/// delegating to specialized executors for each operation.
30pub struct IndexExecutor;
31
32impl IndexExecutor {
33    /// Execute a CREATE INDEX statement (delegates to CreateIndexExecutor)
34    pub fn execute(
35        stmt: &CreateIndexStmt,
36        database: &mut Database,
37    ) -> Result<String, ExecutorError> {
38        CreateIndexExecutor::execute(stmt, database)
39    }
40
41    /// Execute a DROP INDEX statement (delegates to DropIndexExecutor)
42    pub fn execute_drop(
43        stmt: &DropIndexStmt,
44        database: &mut Database,
45    ) -> Result<String, ExecutorError> {
46        DropIndexExecutor::execute(stmt, database)
47    }
48
49    /// Execute a REINDEX statement (delegates to ReindexExecutor)
50    pub fn execute_reindex(
51        stmt: &ReindexStmt,
52        database: &Database,
53    ) -> Result<String, ExecutorError> {
54        ReindexExecutor::execute(stmt, database)
55    }
56}