primnodes.h
来自「PostgreSQL7.4.6 for Linux」· C头文件 代码 · 共 832 行 · 第 1/3 页
H
832 行
{ Expr xpr; Expr *arg; /* input expression */ Oid resulttype; /* output type of coercion expression */ int32 resulttypmod; /* output typmod (usually -1) */ CoercionForm relabelformat; /* how to display this node */} RelabelType;/* * CaseExpr - a CASE expression */typedef struct CaseExpr{ Expr xpr; Oid casetype; /* type of expression result */ Expr *arg; /* implicit equality comparison argument */ List *args; /* the arguments (list of WHEN clauses) */ Expr *defresult; /* the default result (ELSE clause) */} CaseExpr;/* * CaseWhen - an argument to a CASE expression */typedef struct CaseWhen{ Expr xpr; Expr *expr; /* condition expression */ Expr *result; /* substitution result */} CaseWhen;/* * ArrayExpr - an ARRAY[] expression * * Note: if multidims is false, the constituent expressions all yield the * scalar type identified by element_typeid. If multidims is true, the * constituent expressions all yield arrays of element_typeid (ie, the same * type as array_typeid); at runtime we must check for compatible subscripts. */typedef struct ArrayExpr{ Expr xpr; Oid array_typeid; /* type of expression result */ Oid element_typeid; /* common type of array elements */ List *elements; /* the array elements or sub-arrays */ bool multidims; /* true if elements are sub-arrays */} ArrayExpr;/* * CoalesceExpr - a COALESCE expression */typedef struct CoalesceExpr{ Expr xpr; Oid coalescetype; /* type of expression result */ List *args; /* the arguments */} CoalesceExpr;/* * NullIfExpr - a NULLIF expression * * Like DistinctExpr, this is represented the same as an OpExpr referencing * the "=" operator for x and y. */typedef OpExpr NullIfExpr;/* ---------------- * NullTest * * NullTest represents the operation of testing a value for NULLness. * Currently, we only support scalar input values, but eventually a * row-constructor input should be supported. * The appropriate test is performed and returned as a boolean Datum. * ---------------- */typedef enum NullTestType{ IS_NULL, IS_NOT_NULL} NullTestType;typedef struct NullTest{ Expr xpr; Expr *arg; /* input expression */ NullTestType nulltesttype; /* IS NULL, IS NOT NULL */} NullTest;/* * BooleanTest * * BooleanTest represents the operation of determining whether a boolean * is TRUE, FALSE, or UNKNOWN (ie, NULL). All six meaningful combinations * are supported. Note that a NULL input does *not* cause a NULL result. * The appropriate test is performed and returned as a boolean Datum. */typedef enum BoolTestType{ IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN} BoolTestType;typedef struct BooleanTest{ Expr xpr; Expr *arg; /* input expression */ BoolTestType booltesttype; /* test type */} BooleanTest;/* * CoerceToDomain * * CoerceToDomain represents the operation of coercing a value to a domain * type. At runtime (and not before) the precise set of constraints to be * checked will be determined. If the value passes, it is returned as the * result; if not, an error is raised. Note that this is equivalent to * RelabelType in the scenario where no constraints are applied. */typedef struct CoerceToDomain{ Expr xpr; Expr *arg; /* input expression */ Oid resulttype; /* domain type ID (result type) */ int32 resulttypmod; /* output typmod (currently always -1) */ CoercionForm coercionformat; /* how to display this node */} CoerceToDomain;/* * Placeholder node for the value to be processed by a domain's check * constraint. This is effectively like a Param, but can be implemented more * simply since we need only one replacement value at a time. * * Note: the typeId/typeMod will be set from the domain's base type, not * the domain itself. This is because we shouldn't consider the value to * be a member of the domain if we haven't yet checked its constraints. */typedef struct CoerceToDomainValue{ Expr xpr; Oid typeId; /* type for substituted value */ int32 typeMod; /* typemod for substituted value */} CoerceToDomainValue;/* * Placeholder node for a DEFAULT marker in an INSERT or UPDATE command. * * This is not an executable expression: it must be replaced by the actual * column default expression during rewriting. But it is convenient to * treat it as an expression node during parsing and rewriting. */typedef struct SetToDefault{ Expr xpr; Oid typeId; /* type for substituted value */ int32 typeMod; /* typemod for substituted value */} SetToDefault;/* * 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. * * The separation between TargetEntry and Resdom is historical. One of these * days, Resdom should probably get folded into TargetEntry. */typedef struct TargetEntry{ Expr xpr; Resdom *resdom; /* descriptor for targetlist item */ Expr *expr; /* expression to evaluate */} TargetEntry;/* ---------------------------------------------------------------- * node types for join trees * * The leaves of a join tree structure are RangeTblRef nodes. Above * these, JoinExpr nodes can appear to denote a specific kind of join * or qualified join. Also, FromExpr nodes can appear to denote an * ordinary cross-product join ("FROM foo, bar, baz WHERE ..."). * FromExpr is like a JoinExpr of jointype JOIN_INNER, except that it * may have any number of child nodes, not just two. Also, there is an * implementation-defined difference: the planner is allowed to join the * children of a FromExpr using whatever join order seems good to it. * At present, JoinExpr nodes are always joined in exactly the order * implied by the jointree structure (except the planner may choose to * swap inner and outer members of a join pair). * * NOTE: the top level of a Query's jointree is always a FromExpr. * Even if the jointree contains no rels, there will be a FromExpr. * * NOTE: the qualification expressions present in JoinExpr nodes are * *in addition to* the query's main WHERE clause, which appears as the * qual of the top-level FromExpr. The reason for associating quals with * specific nodes in the jointree is that the position of a qual is critical * when outer joins are present. (If we enforce a qual too soon or too late, * that may cause the outer join to produce the wrong set of NULL-extended * rows.) If all joins are inner joins then all the qual positions are * semantically interchangeable. * * NOTE: in the raw output of gram.y, a join tree contains RangeVar, * RangeSubselect, and RangeFunction nodes, which are all replaced by * RangeTblRef nodes during the parse analysis phase. Also, the top-level * FromExpr is added during parse analysis; the grammar regards FROM and * WHERE as separate. * ---------------------------------------------------------------- *//* * RangeTblRef - reference to an entry in the query's rangetable * * We could use direct pointers to the RT entries and skip having these * nodes, but multiple pointers to the same node in a querytree cause * lots of headaches, so it seems better to store an index into the RT. */typedef struct RangeTblRef{ NodeTag type; int rtindex;} RangeTblRef;/*---------- * JoinExpr - for SQL JOIN expressions * * isNatural, using, and quals are interdependent. The user can write only * one of NATURAL, USING(), or ON() (this is enforced by the grammar). * If he writes NATURAL then parse analysis generates the equivalent USING() * list, and from that fills in "quals" with the right equality comparisons. * If he writes USING() then "quals" is filled with equality comparisons. * If he writes ON() then only "quals" is set. Note that NATURAL/USING * are not equivalent to ON() since they also affect the output column list. * * alias is an Alias node representing the AS alias-clause attached to the * join expression, or NULL if no clause. NB: presence or absence of the * alias has a critical impact on semantics, because a join with an alias * restricts visibility of the tables/columns inside it. * * During parse analysis, an RTE is created for the Join, and its index * is filled into rtindex. This RTE is present mainly so that Vars can * be created that refer to the outputs of the join. *---------- */typedef struct JoinExpr{ NodeTag type; JoinType jointype; /* type of join */ bool isNatural; /* Natural join? Will need to shape table */ Node *larg; /* left subtree */ Node *rarg; /* right subtree */ List *using; /* USING clause, if any (list of String) */ Node *quals; /* qualifiers on join, if any */ Alias *alias; /* user-written alias clause, if any */ int rtindex; /* RT index assigned for join */} JoinExpr;/*---------- * FromExpr - represents a FROM ... WHERE ... construct * * This is both more flexible than a JoinExpr (it can have any number of * children, including zero) and less so --- we don't need to deal with * aliases and so on. The output column set is implicitly just the union * of the outputs of the children. *---------- */typedef struct FromExpr{ NodeTag type; List *fromlist; /* List of join subtrees */ Node *quals; /* qualifiers on join, if any */} FromExpr;#endif /* PRIMNODES_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?