use std::collections::HashMap;
use crate::{catalog::objects::SchemaEntry, common::symbol::Symbol};
#[derive(Clone)]
pub struct DatabaseEntry {
pub oid: u32,
pub name: Symbol,
pub owner: Symbol,
pub encoding: Option<Symbol>,
pub locale: Option<Symbol>,
pub tablespace: Option<Symbol>,
pub connection_limit: Option<i64>,
pub allow_connections: bool,
pub is_template: bool,
pub schemas: HashMap<Symbol, SchemaEntry>,
}
impl DatabaseEntry {
pub fn new(
oid: u32,
name: Symbol,
resolved_owner: Symbol,
encoding: Option<Symbol>,
locale: Option<Symbol>,
tablespace: Option<Symbol>,
connection_limit: Option<i64>,
) -> Self {
Self {
oid,
name,
owner: resolved_owner,
encoding,
locale,
tablespace,
connection_limit,
allow_connections: true, is_template: false, schemas: HashMap::new(),
}
}
}
impl std::fmt::Debug for DatabaseEntry {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("DatabaseEntry")
.field("oid", &self.oid)
.field("name", &self.name)
.field("owner", &self.owner)
.field("encoding", &self.encoding)
.field("locale", &self.locale)
.field("tablespace", &self.tablespace)
.field("connection_limit", &self.connection_limit)
.field("allow_connections", &self.allow_connections)
.field("is_template", &self.is_template)
.field("schemas", &self.schemas)
.finish()
}
}