use crate::{
binder::bound::database::BoundCreateDatabaseStmt,
executor::{ExecutionResult, error::ExecutionError, executor::Executor},
};
impl Executor {
pub fn execute_create_database(
&mut self,
stmt: BoundCreateDatabaseStmt,
) -> Result<ExecutionResult, ExecutionError> {
let name = stmt.name;
let name_str = self.catalog.interner.resolve(name).to_string();
self.catalog
.create_database(stmt.into(), self.session_user)
.map_err(ExecutionError::from)?;
if let Some(storage) = &self.storage {
storage
.create_database_dir(&name_str)
.map_err(|e| ExecutionError::Storage(e.to_string()))?;
}
Ok(ExecutionResult::DatabaseCreated { name })
}
}