Skip to main content

MutableQueryPlan

Struct MutableQueryPlan 

Source
pub struct MutableQueryPlan { /* private fields */ }
Expand description

A private query destination with independently owned scalar fields and query children. Observation is read-only; consuming edits transfer or destroy the corresponding constructor records together with their IR.

Implementations§

Source§

impl MutableQueryPlan

Source

pub fn transform_scalar_arenas( self, control: &ProductionControl<'_>, transform: &mut ScalarArenaTransform<'_>, ) -> Result<Self, SQLError>

Source§

impl MutableQueryPlan

Source

pub fn transfer_expression_to( self, destination: Self, expression: OwnedScalarExpr, control: &ProductionControl<'_>, ) -> Result<(Self, Self, OwnedScalarExpr, bool), SQLError>

Transfer the detached expression’s exclusive query children into another query’s arena. Invalid or shared references leave all three private inputs unchanged. Successful movement preserves each child query’s own namespace and compacts only the source root’s indices.

Source§

impl MutableQueryPlan

Source

pub fn prune_subqueries( self, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Compact the local scalar-query arena through SQL’s existing namespace-aware remapping. Unreachable child payloads release before their constructor records, while the original arena capacity remains owned by the parent.

Source§

impl MutableQueryPlan

Source

pub fn take_where( self, control: &ProductionControl<'_>, ) -> Result<(Self, Option<OwnedScalarExpr>), SQLError>

Detach WHERE with its independent scalar constructor. Its former field metadata remains with the query until another qualification is installed or the query is discarded.

Source

pub fn projected( projections: impl ExactSizeIterator<Item = OwnedProjection>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Build a projection query from independently admitted scalar/name inputs. The query starts without FROM; callers attach a unit or relational source through the same owning boundary.

Source

pub fn replace_where( self, expression: Option<OwnedScalarExpr>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Replace an optional qualification, transferring the selected scalar owner even when the query previously had no WHERE clause.

Source

pub fn take_source( self, control: &ProductionControl<'_>, ) -> Result<(Self, Option<MutableSourcePlan>), SQLError>

Move FROM out of the query while retaining every sibling field and its exact owner.

Source

pub fn replace_source( self, source: Option<MutableSourcePlan>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Replace FROM after admitting its new field records. The old source is destroyed before its constructor leases are retired.

Source§

impl MutableQueryPlan

Source

pub fn map_cte( self, index: usize, control: &ProductionControl<'_>, map: impl FnOnce(MutableExecutablePlan) -> Result<MutableExecutablePlan, SQLError>, ) -> Result<Self, SQLError>

Rewrite one CTE body while preserving its query/command kind and original declaration box. Its name, columns and scheduling metadata stay with the parent query.

Source§

impl MutableQueryPlan

Source

pub fn take_deferred_rewrites( self, control: &ProductionControl<'_>, ) -> Result<(Self, OwnedDeferredRewriteIter), SQLError>

Source

pub fn replace_deferred_rewrites( self, rewrites: impl ExactSizeIterator<Item = Produced<DeferredOuterRewrite>>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Source

pub fn transform_root_scalar_arenas( self, control: &ProductionControl<'_>, transform: &mut ScalarArenaTransform<'_>, ) -> Result<Self, SQLError>

Edit block-owned roots while lending their scalar-query namespace. FROM expressions and nested query bodies retain their separate rewrite boundary.

Source

pub fn map_source_with_arena( self, control: &ProductionControl<'_>, map: impl FnOnce(MutableSourcePlan, &mut ScalarQueryArena) -> Result<MutableSourcePlan, SQLError>, ) -> Result<Self, SQLError>

Source§

impl MutableQueryPlan

Source

pub fn map_where_input( self, control: &ProductionControl<'_>, map: impl FnOnce(Option<OwnedScalarExpr>, &mut ScalarQueryArena) -> Result<Option<OwnedScalarExpr>, SQLError>, ) -> Result<Self, SQLError>

Edit an optional WHERE clause together with its scalar-query namespace, including construction of a previously absent predicate.

Source

pub fn take_where_expression( self, control: &ProductionControl<'_>, ) -> Result<(Self, Option<MutableExpressionPlan>), SQLError>

Detach a WHERE clause with its complete original query namespace. Unreferenced namespaces remain with a query that has no WHERE clause.

Source§

impl MutableQueryPlan

Source

pub fn map_value_rows<I: ExactSizeIterator<Item = OwnedScalarExpr>>( self, control: &ProductionControl<'_>, map: impl FnMut(OwnedValueRow) -> Result<I, SQLError>, ) -> Result<Self, SQLError>

Transform VALUES rows through independently owned scalars while keeping the query namespace and metadata unchanged.

Source

pub fn project_values( self, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Keep the original query scope and scalar arena while exposing VALUES as an ordinary projection block. A single row becomes the projection list; multiple rows retain their buffers in a lateral captured source.

Source§

impl MutableQueryPlan

Source

pub fn apply_grouping( self, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Source

pub fn discard_source_analysis( self, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Captured source layouts describe the pre-rewrite topology. Their immutable metadata retains its existing shared owner.

Source§

impl MutableQueryPlan

Source

pub fn clear_row_analysis( self, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Drop cached row and source analysis after a structural input rewrite; query syntax and its independently owned fields remain intact.

Source

pub fn append_row_lock( self, strength: LockStrength, wait: LockWait, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Source

pub fn set_privilege_subject( self, subject: Option<Produced<RoleReference>>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Source

pub fn clear_privilege_columns( self, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Source

pub fn include_privilege_column( self, identity: Produced<ColumnIdentity>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Retain one privilege dependency after admitting its tree node. Duplicate identities retain the original node and release the unused supplied identity.

Source

pub fn set_compute( self, compute: ComputePlan, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Change only the allocation-free compute decision chosen by the planner.

Source

pub fn set_access( self, access: AccessPathPlan, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Change only the allocation-free access decision chosen by the planner.

Source

pub fn select_scalar( self, slot: QueryScalarSlot, control: &ProductionControl<'_>, ) -> Result<Option<OwnedScalarExpr>, SQLError>

Select one expression and destroy every other query allocation, including its former projection and parent containers. An absent optional field returns None.

Source

pub fn replace_projection_alias( self, index: usize, alias: Option<Produced<String>>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Replace a projection’s name without changing its scalar or positional descriptor. The new text arrives from an admitted producer; removed text is freed before its lease.

Source§

impl MutableQueryPlan

Source

pub fn transform_scalar_nodes( self, control: &ProductionControl<'_>, transform: &mut ScalarNodeTransform<'_>, ) -> Result<Self, SQLError>

Source§

impl MutableQueryPlan

Source

pub fn rewrite_root_scalar_nodes( self, control: &ProductionControl<'_>, replacement: &mut (dyn FnMut(&ScalarExpr) -> Result<Option<OwnedScalarExpr>, SQLError> + '_), ) -> Result<Self, SQLError>

Rewrite local scalar nodes in source-first order without moving their original addresses. The observer receives read-only syntax and returns an independently owned replacement; nested queries retain separate traversal boundaries.

Source§

impl MutableQueryPlan

Source

pub fn map_scalar_with_parent( self, slot: QueryScalarSlot, control: &ProductionControl<'_>, map: impl FnOnce(&QueryPlan, OwnedScalarExpr) -> Result<OwnedScalarExpr, SQLError>, ) -> Result<Self, SQLError>

Rewrite a scalar with a read-only view of the enclosing query. The selected parent slot temporarily contains an allocation-free NULL; the callback receives its actual previous scalar and owner separately.

Source

pub fn map_query_child_with_parent( self, slot: QueryChildSlot, control: &ProductionControl<'_>, map: impl FnOnce(&QueryPlan, Self) -> Result<Self, SQLError>, ) -> Result<Self, SQLError>

Observe an enclosing query’s namespace while rewriting one directly owned child. Its original box or arena entry stays allocated in the parent and holds an empty query until the callback returns.

Source

pub fn map_source_with_parent( self, control: &ProductionControl<'_>, map: impl FnOnce(&QueryPlan, MutableSourcePlan) -> Result<MutableSourcePlan, SQLError>, ) -> Result<Self, SQLError>

Observe the query’s scalar and analysis inputs while rewriting its source. FROM is temporarily absent; its complete original source is moved into the callback.

Source§

impl MutableQueryPlan

Source

pub fn map_projection_inputs<I: ExactSizeIterator<Item = OwnedProjection>>( self, control: &ProductionControl<'_>, map: impl FnOnce(OwnedProjectionIter, &mut ScalarQueryArena) -> Result<I, SQLError>, ) -> Result<Self, SQLError>

Edit the projection list and its scalar-query namespace together, moving existing projection children without copying their payloads.

Source

pub fn take_projections( self, control: &ProductionControl<'_>, ) -> Result<(Self, OwnedProjectionIter), SQLError>

Move all projections into an owning iterator. The remaining query has an empty projection vector; its other constructors are unchanged.

Source

pub fn replace_projections( self, projections: impl ExactSizeIterator<Item = OwnedProjection>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Admit the destination vector and field records, then transfer each existing scalar and alias. Removed projections are freed before their old reservations.

Source

pub fn set_analyzed_output( self, schema: Option<RowSchema>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Retain an already published immutable output descriptor without copying its columns or charging its shared owner again.

Source§

impl MutableQueryPlan

Source

pub fn map_query_child( self, slot: QueryChildSlot, control: &ProductionControl<'_>, map: impl FnOnce(Self) -> Result<Self, SQLError>, ) -> Result<Self, SQLError>

Rewrite a query child while retaining its original parent box or arena slot. A failed callback destroys the complete private parent and all untouched siblings.

Source§

impl MutableQueryPlan

Source

pub fn set_relations_bound( self, bound: bool, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Source§

impl MutableQueryPlan

Source

pub fn map_source( self, control: &ProductionControl<'_>, map: impl FnOnce(MutableSourcePlan) -> Result<MutableSourcePlan, SQLError>, ) -> Result<Self, SQLError>

Rewrite the complete FROM source without exposing a mutable query or separating a source from its constructor ownership.

Source§

impl MutableQueryPlan

Source

pub fn map_queries_while( self, control: &ProductionControl<'_>, visit: &mut (dyn FnMut(MutableQueryPlan) -> Result<(MutableQueryPlan, bool), SQLError> + '_), ) -> Result<Self, SQLError>

Source§

impl MutableQueryPlan

Source

pub fn replace_group_by( self, expressions: impl ExactSizeIterator<Item = OwnedScalarExpr>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Replace all grouping keys while preserving projection, source and grouping-set owners.

Source§

impl MutableQueryPlan

Source

pub fn normalize_window_definitions( self, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Source§

impl MutableQueryPlan

Source

pub fn reserved_bytes(&self) -> usize

Source

pub fn map_scalar( self, slot: QueryScalarSlot, control: &ProductionControl<'_>, map: impl FnOnce(OwnedScalarExpr) -> Result<OwnedScalarExpr, SQLError>, ) -> Result<Self, SQLError>

Rewrite one selected scalar root without copying parent containers or siblings. An absent optional scalar is left absent. Error or unwind destroys the complete private query.

Source

pub fn retain_projections( self, control: &ProductionControl<'_>, keep: impl FnMut(usize, &ProjectionPlan) -> Result<bool, SQLError>, ) -> Result<Self, SQLError>

Keep selected projection entries in their original vector. Removed expression and alias storage is destroyed before its own constructor records; surviving aliases and scalar children keep their addresses and allowance.

Source

pub fn finish( self, control: &ProductionControl<'_>, ) -> Result<Produced<QueryPlan>, SQLError>

Freeze only the surviving query storage. Temporary constructor records release before publication; no size observation or retrospective reservation split is used.

Methods from Deref<Target = QueryPlan>§

Source

pub fn copy_with_set_inputs( &self, left: OwnedQueryPlan, right: OwnedQueryPlan, control: &ProductionControl<'_>, ) -> Result<OwnedQueryPlan, SQLError>

Retain a set operation’s declarations and clauses while transferring both independently optimized query inputs.

Source

pub fn copy_primary_with_control( &self, control: &ProductionControl<'_>, ) -> Result<Produced<Self>, SQLError>

Copy the primary query after its WITH definitions have been installed in the lexical scope. Excluded declarations are never allocated; all primary metadata and nested query scopes retain their meaning.

Source

pub fn set_ordering_with_control( &self, control: &ProductionControl<'_>, ) -> Result<Produced<QueryBlockPlan>, SQLError>

Produce the ordering/slicing block of a set operation without copying either operand. Scalar-query slots remain in the same order as their original expressions.

Source

pub fn clone_with_control( &self, control: &ProductionControl<'_>, ) -> Result<Produced<Self>, SQLError>

Copy a relational executable and its query/mutation CTEs, admitting destination capacities and owned payloads before allocation. Immutable analysis descriptors and retained row/literal identities remain shared.

Source

pub fn copy_for_rewrite( &self, control: &ProductionControl<'_>, ) -> Result<MutableQueryPlan, SQLError>

Copy a complete query while keeping mutable constructor ownership separate. Every destination and ownership-record buffer is admitted before allocation; published immutable schemas retain their original shared owners.

Source

pub fn visit_sources(&self, visit: &mut dyn FnMut(&SourcePlan))

Source

pub fn visit_scalar_expressions(&self, visit: &mut dyn FnMut(&ScalarExpr))

Visit every scalar expression this query owns, each root once, including those of its CTEs, relational sources and scalar subqueries.

Source

pub fn try_visit_scalar_expressions<'a, E>( &'a self, visit: &mut dyn FnMut(&'a ScalarExpr) -> Result<(), E>, ) -> Result<(), E>

Stop at the first callback error, without copying syntax or visiting later inputs.

Trait Implementations§

Source§

impl Debug for MutableQueryPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for MutableQueryPlan

Source§

type Target = QueryPlan

The resulting type after dereferencing.
Source§

fn deref(&self) -> &QueryPlan

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.