uqa-engine 0.4.0

Engine: schema-aware table store, catalog restore, transactions
//
// Unified Query Algebra
//
// Copyright (c) 2023-2026 Cognica, Inc.
//

//! Bind routine privilege analysis and publication to current role and session state.

use crate::Engine;
use uqa_execution::routines::privileges::{RoutinePrivilegeContext, RoutinePrivilegeNotices};
use uqa_sql::catalog::roles::RoleReference;
use uqa_sql::routines::security::RoutineExecutionAuthority;

impl RoutineExecutionAuthority for Engine {
    fn current_role(&self) -> RoleReference {
        Engine::current_role(self)
    }
    fn current_user_has_role_identity_privileges(
        &self,
        role: uqa_sql::catalog::roles::RoleIdentity,
    ) -> bool {
        Engine::current_user_has_role_privileges(self, &role)
    }
}
impl RoutinePrivilegeNotices for Engine {
    fn routine_privilege_notice(&self, level: &str, message: &str) {
        self.push_sql_notice(level, message);
    }
}
impl Engine {
    pub(crate) fn routine_privilege_context(&self) -> RoutinePrivilegeContext<'_> {
        RoutinePrivilegeContext {
            locks: self,
            schemas: self,
            catalog: self.routine_mutation_context(),
            types: self,
            role_names: self,
            notices: self,
        }
    }
}