Struct sql::plan::scope::Scope [−][src]
Fields
items: Vec<ScopeItem>
lateral_barrier: bool
Implementations
pub fn from_source<I, N>(
table_name: Option<PartialName>,
column_names: I
) -> Self where
I: IntoIterator<Item = N>,
N: Into<ColumnName>,
Constructs an iterator over the canonical name for each column.
Returns all items in the scope.
Items are returned in order of preference, where the innermost scope has
the highest preference. For example, given scopes A(B(C))
, items are
presented in the order C
, B
, A
.
Items are returned alongside the column reference that targets that item
and the item’s “lateral level”. The latter bears explaining. The lateral
level is the number of lateral barriers between this scope and the item.
See Scope::lateral_barrier
for a diagram. Roughly speaking, items from
different levels but the same lateral level are items from different
joins in the same subquery, while items in different lateral levels are
items from different queries entirely. Rules about ambiguity apply
within an entire lateral level, not just within a single scope level.
NOTE(benesch): Scopereally shows its weaknesses here. Ideally we'd have separate types like
QueryScopeand
JoinScope` that more
naturally encode the concept of a “lateral level”, or at least something
along those lines.
Returns all items from the given table name in the closest scope.
If no tables with the given name are in scope, returns an empty iterator.
NOTE(benesch): This is wrong for zero-arity relations, because we can’t distinguish between “no such table” and a table that exists but has no columns. The current design of scope makes this difficult to fix, unfortunately.
fn resolve_internal<'a, M>(
&'a self,
outer_scopes: &[Scope],
matches: M,
table_name: Option<&PartialName>,
column_name: &ColumnName
) -> Result<ColumnRef, PlanError> where
M: FnMut(ColumnRef, usize, &ScopeItem) -> bool,
pub fn resolve_column<'a>(
&'a self,
outer_scopes: &[Scope],
column_name: &ColumnName
) -> Result<ColumnRef, PlanError>
pub fn resolve_column<'a>(
&'a self,
outer_scopes: &[Scope],
column_name: &ColumnName
) -> Result<ColumnRef, PlanError>
Resolves references to a column name to a single column, or errors if multiple columns are equally valid references.
pub fn resolve_using_column(
&self,
column_name: &ColumnName,
join_side: JoinSide
) -> Result<ColumnRef, PlanError>
pub fn resolve_using_column(
&self,
column_name: &ColumnName,
join_side: JoinSide
) -> Result<ColumnRef, PlanError>
Resolves a column name in a USING
clause.
pub fn resolve_table_column<'a>(
&'a self,
outer_scopes: &[Scope],
table_name: &PartialName,
column_name: &ColumnName
) -> Result<ColumnRef, PlanError>
pub fn resolve<'a>(
&'a self,
outer_scopes: &[Scope],
table_name: Option<&PartialName>,
column_name: &ColumnName
) -> Result<ColumnRef, PlanError>
Look to see if there is an already-calculated instance of this expr. Failing to find one is not an error, so this just returns Option
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Scope
impl UnwindSafe for Scope
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more