pub struct QueryContext { /* private fields */ }Expand description
Query context
The context for each query request is created whenever the query request is received by the query engine. This context object is visible to the parser, planner, optimizer, and executor.
§Responsibilities
- Query request context (session information, request parameters)
- Request-scoped cancellation token (shared with the execution runtime and the process-level query registry — one token for all cancellation)
- ID generation for query execution
- Space information management (space info, character set)
- Optional arena allocator for high-performance temporary allocations
§Creation
Use QueryContext::new for simple cases or QueryContext::builder for complex configuration.
Implementations§
Source§impl QueryContext
impl QueryContext
Sourcepub fn new(rctx: Arc<QueryRequestContext>) -> Self
pub fn new(rctx: Arc<QueryRequestContext>) -> Self
Create a new query context with default configuration.
For complex configuration (arena allocation, custom ID generator, etc.),
use QueryContext::builder instead.
Sourcepub fn builder(rctx: Arc<QueryRequestContext>) -> QueryContextBuilder
pub fn builder(rctx: Arc<QueryRequestContext>) -> QueryContextBuilder
Sourcepub fn request_context(&self) -> &QueryRequestContext
pub fn request_context(&self) -> &QueryRequestContext
Obtain the context of the query request.
Sourcepub fn request_context_arc(&self) -> Arc<QueryRequestContext> ⓘ
pub fn request_context_arc(&self) -> Arc<QueryRequestContext> ⓘ
The Arc reference that provides the context for the query request.
Sourcepub fn rctx(&self) -> &QueryRequestContext
pub fn rctx(&self) -> &QueryRequestContext
Obtain the context of the query request (compatible with old code)
Sourcepub fn cancel_token(&self) -> CancelToken
pub fn cancel_token(&self) -> CancelToken
The request-scoped cancellation token.
Threaded into the execution runtime and query registry at instantiation so all cancellation paths share one source of truth.
Sourcepub fn charset_info(&self) -> Option<&CharsetInfo>
pub fn charset_info(&self) -> Option<&CharsetInfo>
Obtaining character set information
Sourcepub fn set_charset_info(&mut self, charset_info: CharsetInfo)
pub fn set_charset_info(&mut self, charset_info: CharsetInfo)
Setting character set information
Sourcepub fn snapshot_ts(&self) -> Option<Timestamp>
pub fn snapshot_ts(&self) -> Option<Timestamp>
The MVCC snapshot timestamp for consistent reads within explicit transactions.
None means auto-commit single-statement execution, which reads the
current version of the data.
Sourcepub fn isolation_level(&self) -> Option<TransactionIsolationLevel>
pub fn isolation_level(&self) -> Option<TransactionIsolationLevel>
The transaction isolation level for this execution, when running inside an explicit transaction.
Sourcepub fn password_history_depth(&self) -> usize
pub fn password_history_depth(&self) -> usize
The retained password-history depth for user-management operations planned under this context.
Sourcepub fn authenticated_user(&self) -> Option<&str>
pub fn authenticated_user(&self) -> Option<&str>
The authenticated user that issued this query, when the request came from an authenticated session.
Self-service password changes omit the username in the statement; the planner backfills it from here so the execution chain targets the caller instead of failing on an empty username.
Sourcepub fn current_id(&self) -> i64
pub fn current_id(&self) -> i64
Retrieve the current ID value (without incrementing it).
Sourcepub fn space_info(&self) -> Option<&SpaceInfo>
pub fn space_info(&self) -> Option<&SpaceInfo>
Obtain the current spatial information
Sourcepub fn set_space_info(&mut self, space_info: SpaceInfo)
pub fn set_space_info(&mut self, space_info: SpaceInfo)
Set the current space information
Sourcepub fn space_name(&self) -> Option<String>
pub fn space_name(&self) -> Option<String>
Get the name of the current space.
Sourcepub fn mark_killed(&self)
pub fn mark_killed(&self)
Mark this query as killed.
Cancels the request-scoped token shared with the execution runtime and
the query registry, so running operators abort at the next cooperative
cancellation check and KILL QUERY observability reflects the state.
Sourcepub fn exist_parameter(&self, param: &str) -> bool
pub fn exist_parameter(&self, param: &str) -> bool
Check whether the parameters exist.
Sourcepub fn parameters(&self) -> &HashMap<String, Value>
pub fn parameters(&self) -> &HashMap<String, Value>
Obtain parameters
Trait Implementations§
Source§impl Debug for QueryContext
impl Debug for QueryContext
Auto Trait Implementations§
impl !Freeze for QueryContext
impl !RefUnwindSafe for QueryContext
impl !UnwindSafe for QueryContext
impl Send for QueryContext
impl Sync for QueryContext
impl Unpin for QueryContext
impl UnsafeUnpin for QueryContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.