Struct sql::plan::scope::ScopeItem [−][src]
pub struct ScopeItem {
pub table_name: Option<PartialName>,
pub column_name: ColumnName,
pub exprs: HashSet<Expr<Aug>>,
pub from_single_column_function: bool,
pub allow_unqualified_references: bool,
pub lateral_error_if_referenced: bool,
pub is_exists_column_for_a_table_function_that_was_in_the_target_list: bool,
_private: (),
}
Fields
table_name: Option<PartialName>
The name of the table that produced this scope item, if any.
column_name: ColumnName
The name of the column.
exprs: HashSet<Expr<Aug>>
The expressions from which this scope item is derived. Used by GROUP BY
.
from_single_column_function: bool
Whether the column is the return value of a function that produces only a single column. This accounts for a strange PostgreSQL special case around whole-row expansion.
allow_unqualified_references: bool
Controls whether the column is only accessible via a table-qualified
reference. When false, the scope item is also excluded from SELECT *
.
This should be true for almost all scope items. It is set to false for
join columns in USING constraints. For exmaple, in t1 FULL JOIN t2 USING a
, t1.a
and t2.a
are still available by fully-qualified
reference, but a bare a
refers to a new column whose value is
coalesce(t1.a, t2.a)
. This is a big special case because normally
having three columns in scope named a
would result in “ambiguous
column reference” errors.
lateral_error_if_referenced: bool
Whether reference the item should produce an error about the item being on the wrong side of a lateral join.
Per PostgreSQL (and apparently SQL:2008), we can’t simply make these items unnameable. These items need to exist because they might shadow variables in outer scopes that would otherwise be valid to reference, but accessing them needs to produce an error.
is_exists_column_for_a_table_function_that_was_in_the_target_list: bool
For table functions in scalar positions, this flag is true for the
ordinality column. If true, then this column represents an “exists” flag
for the entire row of the table function. In that case, this column must
be excluded from *
expansion. If the corresponding datum is NULL
, then
*
expansion should yield a single NULL
instead of a record with various
datums.
_private: ()
Implementations
Constructs a new scope item from an unqualified column name.
pub fn from_name<N>(
table_name: Option<PartialName>,
column_name: N
) -> ScopeItem where
N: Into<ColumnName>,
pub fn from_name<N>(
table_name: Option<PartialName>,
column_name: N
) -> ScopeItem where
N: Into<ColumnName>,
Constructs a new scope item from a name.
Constructs a new scope item with no name from an expression.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ScopeItem
impl UnwindSafe for ScopeItem
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