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 submodules
8//! - `create_index.rs` - Main CREATE INDEX executor and dispatch logic
9//! - `validation.rs` - Pre-creation validation (column checks, privileges, etc.)
10//! - `btree_index.rs` - B-tree index creation (standard and unique)
11//! - `spatial_index.rs` - Spatial/R-tree index creation
12//! - `vector_index.rs` - IVFFlat and HNSW vector index creation
13//! - `expression_index.rs` - Expression-based functional index creation
14//!
15//! ## Other DDL operations
16//! - `drop_index.rs` - DROP INDEX executor
17//! - `reindex.rs` - REINDEX executor
18//! - `analyze.rs` - ANALYZE executor
19
20pub mod analyze;
21mod btree_index;
22pub mod create_index;
23pub mod drop_index;
24mod expression_index;
25pub mod reindex;
26mod spatial_index;
27mod validation;
28mod vector_index;
29
30pub use analyze::AnalyzeExecutor;
31pub use create_index::CreateIndexExecutor;
32pub use drop_index::DropIndexExecutor;
33pub use reindex::ReindexExecutor;
34use vibesql_ast::{CreateIndexStmt, DropIndexStmt, ReindexStmt};
35use vibesql_storage::Database;
36
37use crate::errors::ExecutorError;
38
39/// Unified executor for index operations (CREATE, DROP, and REINDEX INDEX)
40///
41/// This struct provides backward compatibility with the original API,
42/// delegating to specialized executors for each operation.
43pub struct IndexExecutor;
44
45impl IndexExecutor {
46 /// Execute a CREATE INDEX statement (delegates to CreateIndexExecutor)
47 pub fn execute(
48 stmt: &CreateIndexStmt,
49 database: &mut Database,
50 ) -> Result<String, ExecutorError> {
51 CreateIndexExecutor::execute(stmt, database)
52 }
53
54 /// Execute a DROP INDEX statement (delegates to DropIndexExecutor)
55 pub fn execute_drop(
56 stmt: &DropIndexStmt,
57 database: &mut Database,
58 ) -> Result<String, ExecutorError> {
59 DropIndexExecutor::execute(stmt, database)
60 }
61
62 /// Execute a REINDEX statement (delegates to ReindexExecutor)
63 pub fn execute_reindex(
64 stmt: &ReindexStmt,
65 database: &Database,
66 ) -> Result<String, ExecutorError> {
67 ReindexExecutor::execute(stmt, database)
68 }
69}