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    SQLError,
12};
13
14use crate::Engine;
15use uqa_execution::statement::context::session::{
16    PreparedPlanState, StatementControl, StatementNotifications, StatementSettings,
17};
18impl StatementSettings for Engine {
19    fn set_runtime_parameter(
20        &self,
21        name: &str,
22        value: Option<&str>,
23        local: bool,
24    ) -> Result<(), SQLError> {
25        Engine::set_runtime_parameter(self, name, value, local)
26    }
27    fn reset_all_variables(&self) {
28        Engine::reset_all_variables(self);
29    }
30    fn discard(&self, target: DiscardTarget) -> Result<(), SQLError> {
31        Engine::discard(self, target)
32    }
33    fn load_library(&self, library: &str) -> Result<(), SQLError> {
34        Engine::load_library(self, library)
35    }
36}
37impl StatementNotifications for Engine {
38    fn notification_subscriptions_required(&self) -> bool {
39        Engine::notification_subscriptions_required(self)
40    }
41
42    fn notify(&self, channel: &str, payload: &str) -> Result<(), SQLError> {
43        Engine::notify(self, channel, payload)
44    }
45    fn listen(&self, channel: &str) -> Result<(), SQLError> {
46        Engine::listen(self, channel)
47    }
48    fn unlisten(&self, channel: Option<&str>) -> Result<(), SQLError> {
49        Engine::unlisten(self, channel)
50    }
51}
52impl StatementControl for Engine {
53    fn transaction_failed(&self) -> bool {
54        Engine::transaction_failed(self)
55    }
56    fn run_transaction_statement(&self, statement: TransactionStmt) -> Result<(), SQLError> {
57        Engine::run_transaction_statement(self, statement)
58    }
59    fn set_constraints(
60        &self,
61        requested: &[SetConstraintName],
62        deferred: bool,
63        nested_statement: bool,
64    ) -> Result<(), SQLError> {
65        Engine::set_constraints(self, requested, deferred, nested_statement)
66    }
67}
68impl PreparedPlanState for Engine {
69    fn lookup_prepared(&self, name: &str) -> Option<uqa_sql::plan::SharedExecutablePlan> {
70        Engine::lookup_prepared(self, name)
71    }
72    fn prepared_parameter_types(&self, name: &str) -> Option<Vec<Option<ColumnType>>> {
73        Engine::prepared_parameter_types(self, name)
74    }
75    fn deallocate_prepared(&self, name: Option<&str>) {
76        Engine::deallocate_prepared(self, name);
77    }
78}