Skip to main content

OwnedScalarExpr

Struct OwnedScalarExpr 

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

A scalar expression whose child allocations can be transferred or discarded independently. The expression is read-only outside this owner’s consuming operations; replacing raw IR through a mutable dereference would separate allocations from their reservations.

Implementations§

Source§

impl OwnedScalarExpr

Source

pub fn set_call_order_syntax( self, syntax: FunctionOrderSyntax, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Preserve the parser’s inline ordering-syntax identity without rebuilding any call storage.

Source

pub fn set_call_dispatch( self, dispatch: Option<FunctionDispatch>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Change an inline call dispatch without moving or replacing any allocating field.

Source

pub fn replace_call_binding( self, binding: Option<Produced<FunctionBinding>>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Replace a call’s selected binding without changing its name, arguments, ordering or filter. The old metadata and containers remain owned until the replacement’s admitted containers hold all surviving children.

Source

pub fn replace_call_metadata( self, name: Produced<String>, binding: Option<Produced<FunctionBinding>>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Install an independently produced call name and binding. This storage operation retains scalar payload identity and performs no overload selection or expression evaluation.

Source§

impl OwnedScalarExpr

Source

pub fn typed_null( ty: &str, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Construct an unbound typed NULL, admitting the declared type name before copying it. This storage constructor performs no type resolution or value evaluation.

Source

pub fn boolean( children: impl ExactSizeIterator<Item = Self>, conjunction: bool, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Build AND or OR from already owned children. The destination vector and ownership metadata reserve before allocation; input payloads move without copying or changing their allowance.

Source§

impl OwnedScalarExpr

Source

pub fn typed_literal( value: Produced<Value>, declaration: Produced<String>, bound_type: Option<Produced<ColumnType>>, collation_oid: Option<u32>, parameter_index: Option<usize>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Construct a typed literal from independently admitted value and type metadata. This operation only transfers storage; it performs no type resolution, conversion or evaluation.

Source

pub fn retained_literal( literal: RetainedScalarLiteral, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Attach an already retained constant without charging its independently shared payload a second time.

Source

pub fn cast( child: Self, declaration: Produced<String>, implicit: bool, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Wrap an independently owned child in a cast. The child box and ownership slot are admitted before allocation; the destination declaration retains its original producer lease.

Source§

impl OwnedScalarExpr

Source

pub fn replace_child( self, index: usize, replacement: Self, control: &ProductionControl<'_>, ) -> Result<(Self, Self), CatalogRetentionError>

Replace one immediate child and return the previous child with its complete independent owner. The parent retains the same box or vector slot; neither child is copied or implicitly discarded.

Source

pub fn swap_children( self, left: usize, right: usize, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Exchange two immediate children without changing either container or payload ownership. Both indices use the same ordering as map_child.

Source

pub fn truncate_call_arguments( self, count: usize, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Retain at most count arguments of a function call. Ordering expressions and the filter retain their original owners; argument and metadata capacities remain with the parent.

Source

pub fn truncate_case_arms( self, count: usize, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Retain at most count CASE arms. The base and ELSE remain in their original boxes, and the original arm vector retains its capacity.

Source

pub fn truncate_boolean_children( self, count: usize, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Retain at most count AND/OR children after selection or permutation. This storage operation performs no boolean simplification.

Source

pub fn set_case_else( self, replacement: Self, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Install an already owned CASE fallback. An existing ELSE box is reused; an absent box and its child-metadata slot are admitted before allocation. A failed edit destroys both private input owners.

Source§

impl OwnedScalarExpr

Source

pub fn case( base: Option<Self>, branches: impl ExactSizeIterator<Item = (Self, Self)>, fallback: Option<Self>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Construct CASE from independent scalar owners, admitting branch storage before moving any child.

Source

pub fn replace_composite_type( self, bound_type: Option<Produced<ColumnType>>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Replace a named row constructor’s resolved type while moving its scalar fields into admitted destination slots. Binding metadata is copied through its existing owner before the old constructor is retired.

Source

pub fn array( children: impl ExactSizeIterator<Item = Self>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Construct an array expression from independently owned scalar elements.

Source

pub fn row( children: impl ExactSizeIterator<Item = Self>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Construct a ROW from independently owned fields, admitting its vector and ownership slots before moving children.

Source

pub fn binary( op: BinaryOp, left: Self, right: Self, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Construct a binary operator without copying either operand. The two boxes and mutable child slots are admitted before allocation.

Source

pub fn call( name: Produced<String>, binding: Option<Produced<FunctionBinding>>, arguments: impl ExactSizeIterator<Item = Self>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Construct an undecorated selected call from admitted metadata and movable arguments. Overload selection and argument evaluation remain with the caller.

Source§

impl OwnedScalarExpr

Source

pub fn into_children(self) -> OwnedScalarChildren ⓘ

Consume the parent while moving its children. Selecting the final child immediately destroys the now-empty parent; abandoning the iterator destroys the unvisited children as well.

Source§

impl OwnedScalarExpr

Source

pub fn into_literal_value( self, control: &ProductionControl<'_>, ) -> Result<Produced<Value>, CatalogRetentionError>

Consume an untyped literal while keeping its exact value payload lease. No metadata or child allocation belongs to this constructor.

Source

pub fn replace_literal_type( self, declaration: Produced<String>, bound_type: Produced<ColumnType>, collation_oid: Option<u32>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Replace a literal’s declared type and collation while preserving its parameter and original composite source. The old leaf’s allocating fields share one constructor lease, so the replacement copies surviving fields under their producers before releasing that complete old lease.

Source§

impl OwnedScalarExpr

Source

pub fn collated( child: Self, ty: Produced<ColumnType>, collation: ResultCollation, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Wrap the surviving expression in the exact type and collation selected during ordered analysis.

Source

pub fn set_call_input_collation( self, collation: Option<CollationSelection>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Set a selected call’s inline collation identity without rebuilding its allocating metadata.

Source

pub fn set_literal_collation( self, oid: u32, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Set a typed literal’s inline collation identity while retaining its exact value and type owners.

Source§

impl OwnedScalarExpr

Source

pub fn set_cast_implicit( self, implicit: bool, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Set only a cast’s display origin; its destination spelling and complete child retain their existing owners.

Source§

impl OwnedScalarExpr

Source

pub fn remap_subquery_ids( self, control: &ProductionControl<'_>, map: &mut dyn FnMut(usize) -> usize, ) -> Result<Self, SQLError>

Remap only this expression’s local scalar-query references after their query owners have moved together. Nested query arenas are not part of the scalar tree.

Source§

impl OwnedScalarExpr

Source

pub fn column( column: Produced<String>, qualifier: Option<Produced<String>>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Construct a generated column reference without copying its admitted name or qualification.

Source

pub fn positioned_column( column: Produced<String>, qualifier: Option<Produced<String>>, position: Option<u32>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Preserve the source location when a rewrite changes a column’s namespace or physical name.

Source

pub fn replace_qualifier( self, qualifier: &str, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Replace only a reference’s qualifier. Existing capacity is reused; growth admits a replacement buffer while the original is still live.

Source§

impl OwnedScalarExpr

Source

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

Remove only a column reference’s qualifier, preserving its name buffer and parser position.

Source§

impl OwnedScalarExpr

Source

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

Transform children before their parent, retaining the original address as an opaque selection identity. The callback owns all surviving children and may move them into an admitted wrapper.

Source

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

Replace selected nodes in pre-order. The observer receives no mutable syntax; every returned node carries its own complete constructor owner.

Source§

impl OwnedScalarExpr

Source

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

Remove validated call-argument markers by transferring their value child and immediately retiring marker metadata and containers.

Source

pub fn map_child_with_parent<E>( self, index: usize, control: &ProductionControl<'_>, map: impl FnOnce(&ScalarExpr, Self) -> Result<Self, E>, ) -> Result<Self, E>

Rewrite one child while borrowing its parent’s metadata. The selected child slot contains a NULL placeholder during the callback; all other parent fields remain unchanged and read-only.

Source

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

Move a call’s argument vector into an OR container while retaining its call metadata, ordering expressions and filter in the returned parent. The vector’s exact constructor capacity transfers with it; no argument payload is copied.

Source

pub fn replace_call_arguments( self, replacement: Self, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Replace a call’s argument vector with an independently owned AND/OR vector. The boolean container’s children become call arguments without evaluation; the old argument storage is destroyed before its exact lease is released.

Source§

impl OwnedScalarExpr

Source

pub fn replace_window_spec( self, specification: &ScalarWindowSpec, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Source§

impl OwnedScalarExpr

Source

pub fn uncontrolled(expression: ScalarExpr) -> Self

Move an ordinary scalar without claiming that its existing allocations were admitted. Controlled construction uses ScalarExpr::copy_for_rewrite instead.

Source

pub fn literal( value: Produced<Value>, control: &ProductionControl<'_>, ) -> Result<Self, CatalogRetentionError>

Construct a scalar leaf from a value whose producer already owns its payload allowance.

Source

pub fn reserved_bytes(&self) -> usize

Source

pub fn rewrite<E>( self, control: &ProductionControl<'_>, rewrite: impl FnOnce(Self) -> Result<Self, E>, ) -> Result<Self, E>

Rewrite a complete scalar owner. The callback may replace or select the root, but both its input and output must retain this production scope. Failure destroys all private inputs before returning.

Source

pub fn child_count(&self) -> usize

Number of immediate scalar children, in copy order: call arguments, ordering keys and filter; window arguments, partition keys, ordering keys, frame bounds and filter; CASE base, condition/result pairs and ELSE.

Source

pub fn select_child(self, index: usize) -> Self

Move one child out and destroy the parent and its other children. The child’s former box or vector slot belongs to the discarded parent, so only the selected child’s own allocations survive.

Source

pub fn map_children<E>( self, control: &ProductionControl<'_>, map: impl FnMut(usize, Self) -> Result<Self, E>, ) -> Result<Self, E>

Rewrite immediate children without reallocating the parent’s boxes or vectors. Each callback consumes one complete owner and must return an owner from the same production scope. Error or unwind destroys the private rewrite, including unvisited children; no partly rewritten tree escapes.

Source

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

Rewrite one immediate child while retaining all parent containers and sibling owners.

Source

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

Freeze a completed rewrite. Surviving IR reservations become one immutable lease, while the temporary ownership metadata is destroyed and its capacity released.

Methods from Deref<Target = ScalarExpr>§

Source

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

Compare exactly the same syntax and metadata as PartialEq, with cancellation between children and admission for any independent retained-value reads.

Source

pub fn visit(&self, visitor: &mut impl FnMut(&Self))

Visit this expression and every nested scalar expression in pre-order.

Source

pub fn try_visit<'a, E>( &'a self, visitor: &mut impl FnMut(&'a Self) -> Result<bool, E>, ) -> Result<(), E>

Visit in pre-order, skipping a subtree when the visitor returns false and stopping immediately on its first error.

Source

pub fn collect_columns(&self, output: &mut BTreeSet<String>) -> bool

Collect every column needed to evaluate this expression. Returns false when evaluation needs row shape or a relational child that a projected field scan cannot provide.

Source

pub fn try_visit_columns<'a, E>( &'a self, visitor: &mut impl FnMut(&'a str) -> Result<(), E>, ) -> Result<bool, E>

Borrow referenced column names in evaluation-tree order, stopping at the first visitor failure or unprojectable expression. Qualified references yield their column component, matching collect_columns; repeated references remain visible to the visitor. No name or result container is allocated by this traversal.

Source

pub fn contains_window(&self) -> bool

Source

pub fn contains_subquery(&self) -> bool

Source

pub fn contains_parameter(&self) -> bool

Source

pub fn contains_aggregate(&self, is_aggregate: &dyn Fn(&str) -> bool) -> bool

Source

pub fn reference_qualifier(&self) -> Option<&str>

Relation qualifier of a named attribute or qualified wildcard.

Source

pub fn reference_position(&self) -> Option<u32>

Original one-based character position of a named SQL reference.

Source

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

Copy a scalar tree using admitted constructor frames instead of recursive scalar calls. The immutable result combines only destination reservations; temporary frame storage is released before return.

Source

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

Copy into a mutable scalar owner with independent direct and child reservations. Iterative constructors preserve field order, destination admission and query-arena identities in both ordinary and controlled modes.

Trait Implementations§

Source§

impl Debug for OwnedScalarExpr

Source§

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

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

impl Deref for OwnedScalarExpr

Source§

type Target = ScalarExpr

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

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.