[][src]Struct postgres_parser::sys::TargetEntry

#[repr(C)]pub struct TargetEntry {
    pub xpr: Expr,
    pub expr: *mut Expr,
    pub resno: AttrNumber,
    pub resname: *mut c_char,
    pub ressortgroupref: Index,
    pub resorigtbl: Oid,
    pub resorigcol: AttrNumber,
    pub resjunk: bool,
}

TargetEntry a target entry (used in query target lists)

Strictly speaking, a TargetEntry isn't an expression node (since it can't be evaluated by ExecEvalExpr). But we treat it as one anyway, since in very many places it's convenient to process a whole query targetlist as a single expression tree.

In a SELECT's targetlist, resno should always be equal to the item's ordinal position (counting from 1). However, in an INSERT or UPDATE targetlist, resno represents the attribute number of the destination column for the item; so there may be missing or outoforder resnos. It is even legal to have duplicated resnos; consider UPDATE table SET arraycol[1] = ..., arraycol[2] = ..., ... The two meanings come together in the executor, because the planner transforms INSERT/UPDATE tlists into a normalized form with exactly one entry for each column of the destination table. Before that's happened, however, it is risky to assume that resno == position. Generally get_tle_by_resno() should be used rather than list_nth() to fetch tlist entries by resno, and only in SELECT should you assume that resno is a unique identifier.

resname is required to represent the correct column name in nonresjunk entries of toplevel SELECT targetlists, since it will be used as the column title sent to the frontend. In most other contexts it is only a debugging aid, and may be wrong or even NULL. (In particular, it may be wrong in a tlist from a stored rule, if the referenced column has been renamed by ALTER TABLE since the rule was made. Also, the planner tends to store NULL rather than look up a valid name for tlist entries in nontoplevel plan nodes.) In resjunk entries, resname should be either a specific systemgenerated name (such as "ctid") or NULL; anything else risks confusing ExecGetJunkAttribute!

ressortgroupref is used in the representation of ORDER BY, GROUP BY, and DISTINCT items. Targetlist entries with ressortgroupref=0 are not sort/group items. If ressortgroupref>0, then this item is an ORDER BY, GROUP BY, and/or DISTINCT target value. No two entries in a targetlist may have the same nonzero ressortgroupref but there is no particular meaning to the nonzero values, except as tags. (For example, one must not assume that lower ressortgroupref means a more significant sort key.) The order of the associated SortGroupClause lists determine the semantics.

resorigtbl/resorigcol identify the source of the column, if it is a simple reference to a column of a base table (or view). If it is not a simple reference, these fields are zeroes.

If resjunk is true then the column is a working column (such as a sort key) that should be removed from the final output of the query. Resjunk columns must have resnos that cannot duplicate any regular column's resno. Also note that there are places that assume resjunk columns come after nonjunk columns.

Fields

xpr: Exprexpr: *mut Exprresno: AttrNumber

expression to evaluate

resname: *mut c_char

attribute number (see notes above)

ressortgroupref: Index

name of the column (could be NULL)

resorigtbl: Oid

nonzero if referenced by a sort/group clause

resorigcol: AttrNumber

OID of column's source table

resjunk: bool

column's number in source table

Trait Implementations

impl Debug for TargetEntry[src]

impl Default for TargetEntry[src]

impl Eq for TargetEntry[src]

impl Hash for TargetEntry[src]

impl PartialEq<TargetEntry> for TargetEntry[src]

impl StructuralEq for TargetEntry[src]

impl StructuralPartialEq for TargetEntry[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.