Skip to main content

CteScope

Struct CteScope 

Source
pub struct CteScope<S: Clone = ()> {
    pub rows: CteRowsMap,
    pub non_returning_ctes: BindingNameSet,
    pub scalar_subqueries: RetainedQueryArena,
    pub lock_identities: LockIdentityOptions,
    /* private fields */
}

Fields§

§rows: CteRowsMap§non_returning_ctes: BindingNameSet§scalar_subqueries: RetainedQueryArena§lock_identities: LockIdentityOptions

Implementations§

Source§

impl<S: Clone> CteScope<S>

Source

pub fn command_cte_snapshot(&self) -> Option<Arc<S>>

Source

pub fn set_command_cte_snapshot(&mut self, snapshot: Option<Arc<S>>)

Source

pub fn set_statement_commands(&mut self, commands: Arc<StatementCommands>)

Make this scope part of the statement whose commands commands holds.

Source

pub fn statement_commands(&self) -> Option<&Arc<StatementCommands>>

The commands of the statement this scope belongs to.

Source

pub fn statement_wrote(&self, row: &PhysicalDocumentIdentity) -> bool

Whether a command of the statement this scope belongs to wrote row. A later command finds the row’s earlier version in its snapshot, which PostgreSQL reports as TM_SelfModified because the statement’s command id already modified it.

Source

pub fn statement_triggered_write(&self, row: &PhysicalDocumentIdentity) -> bool

Whether a statement that the statement this scope belongs to started wrote row, which PostgreSQL finds modified under a later command id.

Source

pub fn inherit_cte_bindings(&mut self, parent: &Self)

Source

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

Admit every private lexical destination before replacing any part of the child scope. Statement and immutable definition owners remain shared with the parent.

Source

pub fn enter_privilege_subject( &mut self, subject: RoleReference, ) -> PrivilegeSubjectScope<'_, S>

Override only relation privilege checks while preserving SQL-visible current_user and the caller’s namespace.

Source

pub fn enter_privilege_subject_with_control( &mut self, subject: Produced<RoleReference>, control: &ProductionControl<'_>, ) -> Result<PrivilegeSubjectScope<'_, S>, SQLError>

Transfer an admitted authority reference with its original lease before publishing the override. Child scopes share that owner after this guard restores its parent.

Source

pub fn enter_relation_lookup_mode( &mut self, relations_bound: bool, ) -> Result<RelationLookupScope<'_, S>, SQLError>

Select the namespace semantics owned by one query plan and restore the parent plan’s mode on every exit path.

Source

pub fn enter_query_plan_scope( &mut self, plan: &QueryPlan, ) -> Result<QueryPlanScope<'_, S>, SQLError>

Enter the namespace and relation authority retained by one query, including rewritten inputs nested under a different statement owner.

Source

pub fn enter_query_plan_scope_with_control( &mut self, plan: &QueryPlan, control: &ProductionControl<'_>, ) -> Result<QueryPlanScope<'_, S>, SQLError>

Source

pub fn insert_shared(&mut self, name: String, rows: SharedSpill)

Source

pub fn insert_rows(&mut self, name: String, rows: CteRows)

Source

pub fn insert_deferred(&mut self, plan: RetainedCtePlan)

Source

pub fn remove_deferred(&mut self, name: &str) -> Option<RetainedCtePlan>

Source

pub fn deferred_for_scan(&self, name: &str) -> Option<RetainedCtePlan>

Return a folded definition without consuming its lexical binding. A single syntactic reference can be built again by a recursive working-table iteration or a correlated consumer. Materialized producers replace the definition explicitly when installed.

Source

pub fn materialized_for_scan(&self, reference: &str) -> Option<CteRows>

Source

pub fn deferred_reference(&self, reference: &str) -> Option<&CtePlan>

Source

pub fn deferred_ctes(&self) -> &BindingMap<RetainedCtePlan>

Source

pub fn recursive_control_width(&self, name: &str) -> Option<usize>

Source

pub fn set_recursive_control_width( &mut self, name: String, width: usize, ) -> Option<usize>

Source

pub fn restore_recursive_control_width( &mut self, name: &str, previous: Option<usize>, )

Source

pub fn remove_materialized(&mut self, name: &str) -> Option<CteRows>

Source

pub fn enter_query_block( &mut self, block: &QueryBlockPlan, ) -> ScalarSubqueryScope<'_, S>

Enter a query block’s scalar arena and the outer substitutions owned by its FROM expressions.

Source

pub fn enter_query_block_with_control( &mut self, block: &QueryBlockPlan, control: &ProductionControl<'_>, ) -> Result<ScalarSubqueryScope<'_, S>, SQLError>

Construct both private destinations before installing either, so admission failure leaves the complete parent namespace intact.

Source

pub fn enter_scalar_subqueries( &mut self, subqueries: &[QueryPlan], ) -> ScalarSubqueryScope<'_, S>

Bind the scalar-subquery arena owned by one query block. The guard restores the parent arena and correlated row binding on success, error, or panic so nested and lateral query execution cannot resolve a child slot in its parent.

Source

pub fn enter_scalar_subqueries_with_control( &mut self, subqueries: &[QueryPlan], control: &ProductionControl<'_>, ) -> Result<ScalarSubqueryScope<'_, S>, SQLError>

Source

pub fn enter_visible_ctes<'a, 'n>( &'a mut self, names: impl IntoIterator<Item = &'n str>, ) -> VisibleCteScope<'a, S>

Source

pub fn enter_visible_ctes_with_control<'a, 'n>( &'a mut self, names: impl IntoIterator<Item = &'n str>, control: &ProductionControl<'_>, ) -> Result<VisibleCteScope<'a, S>, SQLError>

Build the complete name set before publication. The guard restores its exact previous owner without allocation on error or unwind.

Source

pub fn is_visible_cte(&self, name: &str) -> bool

Whether name resolves to a CTE in this scope: a name declared by an enclosing query’s WITH list, or one whose rows or deferred plan are bound in the scope, which is how a DML statement’s own WITH list reaches the query it drives.

Source

pub fn contains_cte_name(&self, name: &str) -> bool

Test an already decoded, unqualified identifier without applying SQL name parsing a second time.

Source

pub fn returning_statement_snapshot_scope(&self) -> Self

Source

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

Source

pub fn reads_command_overlay(&self) -> bool

Source

pub fn enable_command_progress_streaming(&mut self)

Source

pub fn streams_command_progress(&self) -> bool

Source

pub fn enable_backwards_scanning(&mut self)

Source

pub fn scans_backwards(&self) -> bool

Source§

impl<S: Clone> CteScope<S>

Source

pub fn definition_scope(&self, reference: &str) -> Option<Self>

Prepare a definition in its original lexical bindings while retaining the invoking statement’s catalog, row locks, scalar arena and transaction controls.

Source

pub fn definition_scope_with_control( &self, reference: &str, control: &ProductionControl<'_>, ) -> Result<Option<Self>, SQLError>

Source

pub fn insert_deferred_with_control( &mut self, plan: RetainedCtePlan, control: &ProductionControl<'_>, ) -> Result<(), SQLError>

Source§

impl<S: Clone> CteScope<S>

Source

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

Construct a complete independent lexical destination before exposing it. Plan, catalog, command and immutable row-lock metadata retain their existing owners; producer references remain weak, as in the original reader scopes.

Source§

impl<S: Clone> CteScope<S>

Source

pub fn materialized_for_scan_with_control( &self, reference: &str, control: &ProductionControl<'_>, ) -> Result<Option<CteRows>, SQLError>

Source

pub fn deferred_reference_with_control( &self, reference: &str, control: &ProductionControl<'_>, ) -> Result<Option<&CtePlan>, SQLError>

Source

pub fn is_visible_cte_with_control( &self, reference: &str, control: &ProductionControl<'_>, ) -> Result<bool, SQLError>

Source§

impl<S: Clone> CteScope<S>

Source

pub fn with_catalog_with_control( catalog: CatalogReadView, resolution: Produced<RelationNameResolution>, control: &ProductionControl<'_>, ) -> Result<Self, SQLError>

Capture the current routine’s immutable statement inputs. The catalog already owns its generation; new namespace and execution-state payloads keep their own shared leases.

Source

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

Replace relation authority only after its complete private reference has been admitted. SQL-visible current_user and namespace stay in their original owner.

Source

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

Source

pub fn insert_shared_with_control( &mut self, name: &str, rows: SharedSpill, control: &ProductionControl<'_>, ) -> Result<(), SQLError>

Retain a preexisting transition materialization, admitting only its new lexical name and map node. Replacing the same name reuses its existing identity allocation.

Source

pub fn insert_materialized_with_control( &mut self, name: &str, rows: SharedSpill, returns_rows: bool, control: &ProductionControl<'_>, ) -> Result<(), SQLError>

Publish materialized rows and their command visibility together after all new name storage is admitted.

Source§

impl<S: Clone> CteScope<S>

Source

pub fn enter_recursive_cte_with_control<'a, 'n>( &'a mut self, name: &'n str, rows: SharedSpill, width: Option<usize>, control: &ProductionControl<'_>, ) -> Result<RecursiveCteScope<'a, 'n, S>, SQLError>

Complete both destinations before changing the scope. Saved nodes restore the parent on success, error and unwind without consuming more allowance.

Source§

impl<S: Clone> CteScope<S>

Source

pub fn activate_row_lock_recheck(&mut self, pins: Arc<RowLockRecheckPins>)

Enter one tuple-local recheck execution: base scans of pinned lock targets emit only the candidate’s tuples and every nested LockRows is suppressed while lock identities keep flowing.

Source

pub fn row_lock_recheck_active(&self) -> bool

Source

pub fn set_row_lock_outer_row(&mut self, row: OwnedPhysicalRow)

Preserve the complete correlated outer row for a tuple-local locking recheck. The rebuilt inner query must receive the same scope overlay as its original lateral execution or its correlation predicate would see NULL after a lock wait and incorrectly discard the refreshed tuple.

Source

pub fn row_lock_outer_row(&self) -> Option<&OwnedPhysicalRow>

Source

pub fn clear_row_lock_outer_row(&mut self)

Source

pub fn recheck_docs_for_scan( &self, qualifier: &str, storage_name: &str, ) -> Option<Arc<Vec<RecheckDoc>>>

Pinned tuples one base scan must emit during an active recheck.

Source

pub fn recheck_source_row(&self, path: &[u8]) -> Option<RecheckSourceRow>

Exact copy-row mark for one top-level FROM leaf in the active tuple recheck. Paths use 0/1 for left/right join descent and are scoped to the original LockRows source, so nested query aliases cannot collide.

Source

pub fn enter_recheck_storage_pins( &mut self, qualifier: &str, ) -> RecheckStoragePinScope<'_, S>

Enter the build of one identity-source lock target’s subtree so every base scan of its storage inside the derived table or view is pinned. Pins already active from an enclosing target stay active: the target’s base scans may sit below further derived-table boundaries.

Source

pub fn enter_lock_identity_emission( &mut self, enabled: bool, ) -> LockIdentityEmissionScope<'_, S>

Source

pub fn enter_source_row_locks( &mut self, locks: Vec<ResolvedRowLock>, ) -> SourceRowLockScope<'_, S>

Source

pub fn enter_source_row_locks_with_control( &mut self, locks: Produced<Vec<ResolvedRowLock>>, control: &ProductionControl<'_>, ) -> Result<SourceRowLockScope<'_, S>, SQLError>

Construct the complete shared owner before publishing a new binding; failure leaves the enclosing scope intact.

Source

pub fn source_row_lock_for_view( &self, qualifier: &str, storage_name: &str, ) -> Option<SelectedRowLock>

Source§

impl<S: Clone> CteScope<S>

Source

pub fn enter_cte_bindings_with_control<'a, 'n>( &'a mut self, names: impl IntoIterator<Item = &'n str>, control: &ProductionControl<'_>, ) -> Result<CteBindingScope<'a, S>, SQLError>

Restore only the selected names on every exit, preserving progress of unrelated materialized inputs.

Source§

impl<S: Clone> CteScope<S>

Source

pub fn with_catalog( catalog: CatalogReadView, resolution: RelationNameResolution, privilege_subject: Option<RoleReference>, ) -> Self

Bind immutable statement metadata while keeping the snapshot payload owned by the caller.

Source

pub fn set_reads_command_overlay(&mut self, enabled: bool)

Source

pub fn set_relation_lookup_mode( &mut self, mode: RelationLookupMode, ) -> Result<(), SQLError>

Source

pub fn cached_subquery(&self, slot: usize) -> Option<ScalarSubqueryCacheEntry>

Source

pub fn cache_subquery(&self, slot: usize, entry: ScalarSubqueryCacheEntry)

Source

pub fn new() -> Self

Source

pub fn catalog_read_view(&self) -> Result<CatalogReadView, SQLError>

Source

pub fn set_catalog_revision(&mut self, source: u64, revision: u64)

Record the caller’s source identity and invalidation revision when it captures the catalog, independently of the immutable binding view.

Source

pub fn catalog_revision(&self) -> Option<(u64, u64)>

Source

pub fn relation_name_resolution( &self, ) -> Result<RelationNameResolution, SQLError>

Source

pub fn privilege_subject(&self) -> Result<&RoleReference, SQLError>

Source

pub fn invoking_role(&self) -> Result<&RoleReference, SQLError>

The statement’s invoking identity is independent of relation-owner overrides in enclosing views.

Trait Implementations§

Source§

impl<S: Clone + Clone> Clone for CteScope<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Clone> CorrelationRelations for CteScope<S>

Source§

fn columns(&self, relation: &str) -> Option<&[String]>

Source§

impl<S: Clone> Default for CteScope<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<S: Clone> PrivilegeCteCatalog for CteScope<S>

Source§

impl<S: Clone> ReturningScope for CteScope<S>

Source§

impl<S: Clone> StatementBindingScope for CteScope<S>

Auto Trait Implementations§

§

impl<S = ()> !RefUnwindSafe for CteScope<S>

§

impl<S = ()> !UnwindSafe for CteScope<S>

§

impl<S> Freeze for CteScope<S>
where Option<Arc<S>>: Freeze,

§

impl<S> Send for CteScope<S>
where Option<Arc<S>>: Send,

§

impl<S> Sync for CteScope<S>
where Option<Arc<S>>: Sync,

§

impl<S> Unpin for CteScope<S>
where Option<Arc<S>>: Unpin,

§

impl<S> UnsafeUnpin for CteScope<S>
where Option<Arc<S>>: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.