pub struct QueryControl { /* private fields */ }Expand description
A thread-safe handle for interrupting or observing one running query. A narrow, thread-safe handle for interrupting or observing one query.
Minted by Connection::query_control.
Unlike the connection itself,
QueryControl is Clone + Send + Sync: DuckDB explicitly permits
duckdb_interrupt and duckdb_query_progress to be called from a different
thread than the one running the query — that is their entire purpose. It
exposes only those two read/signal operations, never anything that would
execute SQL, so it cannot create a second concurrent user of the connection.
§Generation scoping
The control captures the connection’s query generation when minted.
interrupt only signals DuckDB while that
generation is still current; once the query completes (advancing the
generation) it becomes a no-op. This makes a delayed or racing cancellation
unable to interrupt a subsequent, unrelated query on the same connection.
Implementations§
Source§impl QueryControl
impl QueryControl
Sourcepub fn interrupt(&self) -> bool
pub fn interrupt(&self) -> bool
Requests interruption of the query this control was minted for.
Idempotent, and a no-op once that query has finished (the generation has
advanced). Returns true if the interrupt was actually signalled to
DuckDB, false if it was skipped as stale.
Sourcepub fn progress(&self) -> Option<QueryProgress>
pub fn progress(&self) -> Option<QueryProgress>
Reads the progress of the query currently running on the connection.
Returns None once the query this control was minted for has finished
(the generation has advanced), so a stale control cannot report a later
query’s progress as its own.
Trait Implementations§
Source§impl Clone for QueryControl
impl Clone for QueryControl
Source§fn clone(&self) -> QueryControl
fn clone(&self) -> QueryControl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more