osirisdb 0.6.0

A SQL database engine built from scratch in Rust featuring a custom parser, binder, query planner, optimizer, catalog, and storage engine.
Documentation
use crate::common::symbol::Symbol;

/// Errors that can occur during catalog operations.
///
/// Each variant carries the [`Symbol`] of the object involved so the caller
/// can resolve the name via the interner for error messages without the
/// catalog needing to own string formatting logic.
#[derive(Debug, Clone, PartialEq)]
pub enum CatalogError {
    /// `CREATE DATABASE` failed — a database with this name already exists
    /// and `IF NOT EXISTS` was not specified.
    DatabaseAlreadyExists(Symbol),

    /// An operation referenced a database that does not exist.
    DatabaseNotFound(Symbol),

    /// `CREATE SCHEMA` failed - a schema with this name already exist
    /// and `IF NOT EXIST` was not specified.
    SchemaAlreadyExists(Symbol),

    /// An operation referenced a schema that does not exist.
    SchemaNotFound(Symbol),

    /// `CREATE TABLE` failed - a schema with this name already exist
    /// and `IF NOT EXIST` was not specified.
    TableAlreadyExists(Symbol),

    /// An operation referenced a table that does not exist.
    TableNotFound(Symbol),
}

impl std::fmt::Display for CatalogError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            CatalogError::DatabaseAlreadyExists(sym) => {
                write!(f, "database {:?} already exists", sym)
            }
            CatalogError::DatabaseNotFound(sym) => {
                write!(f, "database {:?} does not exist", sym)
            }
            CatalogError::SchemaAlreadyExists(sym) => {
                write!(f, "schema {:?} already exists", sym)
            }
            CatalogError::SchemaNotFound(sym) => {
                write!(f, "schema {:?} does not exist", sym)
            }
            CatalogError::TableAlreadyExists(sym) => {
                write!(f, "table {:?} already exists", sym)
            }
            CatalogError::TableNotFound(sym) => {
                write!(f, "table {:?} does not exist", sym)
            }
        }
    }
}

impl std::error::Error for CatalogError {}