vibesql_executor/
role_ddl.rs

1//! Role DDL executor
2
3use vibesql_ast::*;
4use vibesql_storage::Database;
5
6use crate::errors::ExecutorError;
7
8/// Executor for role DDL statements
9pub struct RoleExecutor;
10
11impl RoleExecutor {
12    /// Execute CREATE ROLE
13    pub fn execute_create_role(
14        stmt: &CreateRoleStmt,
15        database: &mut Database,
16    ) -> Result<String, ExecutorError> {
17        database
18            .catalog
19            .create_role(stmt.role_name.clone())
20            .map_err(|e| ExecutorError::StorageError(format!("Catalog error: {:?}", e)))?;
21        Ok(format!("Role '{}' created", stmt.role_name))
22    }
23
24    /// Execute DROP ROLE
25    pub fn execute_drop_role(
26        stmt: &DropRoleStmt,
27        database: &mut Database,
28    ) -> Result<String, ExecutorError> {
29        database
30            .catalog
31            .drop_role(&stmt.role_name)
32            .map_err(|e| ExecutorError::StorageError(format!("Catalog error: {:?}", e)))?;
33        Ok(format!("Role '{}' dropped", stmt.role_name))
34    }
35}