Skip to main content

uqa_engine/capabilities/statements/
session.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Expose current settings, portals, notification queues and prepared registry state.
8
9use uqa_sql::{
10    ast::{ColumnType, DiscardTarget, SetConstraintName, TransactionStmt},
11    plan::UnifiedPlan,
12    SQLError,
13};
14
15use crate::Engine;
16use uqa_execution::statement::context::session::{
17    PreparedPlanState, StatementControl, StatementNotifications, StatementSettings,
18};
19impl StatementSettings for Engine {
20    fn set_runtime_parameter(
21        &self,
22        name: &str,
23        value: Option<&str>,
24        local: bool,
25    ) -> Result<(), SQLError> {
26        Engine::set_runtime_parameter(self, name, value, local)
27    }
28    fn reset_all_variables(&self) {
29        Engine::reset_all_variables(self);
30    }
31    fn discard(&self, target: DiscardTarget) -> Result<(), SQLError> {
32        Engine::discard(self, target)
33    }
34    fn load_library(&self, library: &str) -> Result<(), SQLError> {
35        Engine::load_library(self, library)
36    }
37}
38impl StatementNotifications for Engine {
39    fn notification_subscriptions_required(&self) -> bool {
40        Engine::notification_subscriptions_required(self)
41    }
42
43    fn notify(&self, channel: &str, payload: &str) -> Result<(), SQLError> {
44        Engine::notify(self, channel, payload)
45    }
46    fn listen(&self, channel: &str) -> Result<(), SQLError> {
47        Engine::listen(self, channel)
48    }
49    fn unlisten(&self, channel: Option<&str>) -> Result<(), SQLError> {
50        Engine::unlisten(self, channel)
51    }
52}
53impl StatementControl for Engine {
54    fn transaction_failed(&self) -> bool {
55        Engine::transaction_failed(self)
56    }
57    fn run_transaction_statement(&self, statement: TransactionStmt) -> Result<(), SQLError> {
58        Engine::run_transaction_statement(self, statement)
59    }
60    fn set_constraints(
61        &self,
62        requested: &[SetConstraintName],
63        deferred: bool,
64        nested_statement: bool,
65    ) -> Result<(), SQLError> {
66        Engine::set_constraints(self, requested, deferred, nested_statement)
67    }
68}
69impl PreparedPlanState for Engine {
70    fn lookup_prepared(&self, name: &str) -> Option<UnifiedPlan> {
71        Engine::lookup_prepared(self, name)
72    }
73    fn prepared_parameter_types(&self, name: &str) -> Option<Vec<Option<ColumnType>>> {
74        Engine::prepared_parameter_types(self, name)
75    }
76    fn deallocate_prepared(&self, name: Option<&str>) {
77        Engine::deallocate_prepared(self, name);
78    }
79}