Skip to main content

uqa_execution/statement/
thread_scope.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Restore a thread's statement temporal input, cancellation and retained regex cache when the work that entered them ends.
8
9use super::thread_context::StatementThreadContext;
10
11/// Keeps one statement's temporal input, cancellation and retained regex cache entered on the invoking thread until it drops, on every exit of the work it covers.
12pub struct StatementThreadScope {
13    _retained_rows: crate::query::sources::retained_source::RetainedRowThreadScope,
14    _io: uqa_core::io_usage::IOScope,
15    _regex_cache: uqa_sql::expr::RegexCacheScope,
16    _temporal_input: uqa_sql::expr::TemporalInputScope,
17    _cancellation: uqa_sql::expr::StatementCancellationScope,
18}
19
20impl StatementThreadScope {
21    pub(super) fn enter(context: &StatementThreadContext) -> Self {
22        Self {
23            _retained_rows: context.retained_rows.enter(),
24            _io: context.io.enter(),
25            _regex_cache: uqa_sql::expr::RegexCacheScope::enter(context.regex_cache.clone()),
26            _temporal_input: context.temporal_input.enter(),
27            _cancellation: uqa_sql::expr::StatementCancellationScope::enter(
28                context.cancellation.clone(),
29            ),
30        }
31    }
32}