primnodes.h
来自「PostgreSQL7.4.6 for Linux」· C头文件 代码 · 共 832 行 · 第 1/3 页
H
832 行
* array indexes */ List *reflowerindexpr;/* expressions that evaluate to lower * array indexes */ Expr *refexpr; /* the expression that evaluates to an * array value */ Expr *refassgnexpr; /* expression for the source value, or * NULL if fetch */} ArrayRef;/* * CoercionContext - distinguishes the allowed set of type casts * * NB: ordering of the alternatives is significant; later (larger) values * allow more casts than earlier ones. */typedef enum CoercionContext{ COERCION_IMPLICIT, /* coercion in context of expression */ COERCION_ASSIGNMENT, /* coercion in context of assignment */ COERCION_EXPLICIT /* explicit cast operation */} CoercionContext;/* * CoercionForm - information showing how to display a function-call node */typedef enum CoercionForm{ COERCE_EXPLICIT_CALL, /* display as a function call */ COERCE_EXPLICIT_CAST, /* display as an explicit cast */ COERCE_IMPLICIT_CAST, /* implicit cast, so hide it */ COERCE_DONTCARE /* special case for pathkeys */} CoercionForm;/* * FuncExpr - expression node for a function call */typedef struct FuncExpr{ Expr xpr; Oid funcid; /* PG_PROC OID of the function */ Oid funcresulttype; /* PG_TYPE OID of result value */ bool funcretset; /* true if function returns set */ CoercionForm funcformat; /* how to display this function call */ List *args; /* arguments to the function */} FuncExpr;/* * OpExpr - expression node for an operator invocation * * Semantically, this is essentially the same as a function call. * * Note that opfuncid is not necessarily filled in immediately on creation * of the node. The planner makes sure it is valid before passing the node * tree to the executor, but during parsing/planning opfuncid is typically 0. */typedef struct OpExpr{ Expr xpr; Oid opno; /* PG_OPERATOR OID of the operator */ Oid opfuncid; /* PG_PROC OID of underlying function */ Oid opresulttype; /* PG_TYPE OID of result value */ bool opretset; /* true if operator returns set */ List *args; /* arguments to the operator (1 or 2) */} OpExpr;/* * DistinctExpr - expression node for "x IS DISTINCT FROM y" * * Except for the nodetag, this is represented identically to an OpExpr * referencing the "=" operator for x and y. * We use "=", not the more obvious "<>", because more datatypes have "=" * than "<>". This means the executor must invert the operator result. * Note that the operator function won't be called at all if either input * is NULL, since then the result can be determined directly. */typedef OpExpr DistinctExpr;/* * ScalarArrayOpExpr - expression node for "scalar op ANY/ALL (array)" * * The operator must yield boolean. It is applied to the left operand * and each element of the righthand array, and the results are combined * with OR or AND (for ANY or ALL respectively). The node representation * is almost the same as for the underlying operator, but we need a useOr * flag to remember whether it's ANY or ALL, and we don't have to store * the result type because it must be boolean. */typedef struct ScalarArrayOpExpr{ Expr xpr; Oid opno; /* PG_OPERATOR OID of the operator */ Oid opfuncid; /* PG_PROC OID of underlying function */ bool useOr; /* true for ANY, false for ALL */ List *args; /* the scalar and array operands */} ScalarArrayOpExpr;/* * BoolExpr - expression node for the basic Boolean operators AND, OR, NOT * * Notice the arguments are given as a List. For NOT, of course the list * must always have exactly one element. For AND and OR, the executor can * handle any number of arguments. The parser treats AND and OR as binary * and so it only produces two-element lists, but the optimizer will flatten * trees of AND and OR nodes to produce longer lists when possible. */typedef enum BoolExprType{ AND_EXPR, OR_EXPR, NOT_EXPR} BoolExprType;typedef struct BoolExpr{ Expr xpr; BoolExprType boolop; List *args; /* arguments to this expression */} BoolExpr;/* ---------------- * SubLink * * A SubLink represents a subselect appearing in an expression, and in some * cases also the combining operator(s) just above it. The subLinkType * indicates the form of the expression represented: * EXISTS_SUBLINK EXISTS(SELECT ...) * ALL_SUBLINK (lefthand) op ALL (SELECT ...) * ANY_SUBLINK (lefthand) op ANY (SELECT ...) * MULTIEXPR_SUBLINK (lefthand) op (SELECT ...) * EXPR_SUBLINK (SELECT with single targetlist item ...) * ARRAY_SUBLINK ARRAY(SELECT with single targetlist item ...) * For ALL, ANY, and MULTIEXPR, the lefthand is a list of expressions of the * same length as the subselect's targetlist. MULTIEXPR will *always* have * a list with more than one entry; if the subselect has just one target * then the parser will create an EXPR_SUBLINK instead (and any operator * above the subselect will be represented separately). Note that both * MULTIEXPR and EXPR require the subselect to deliver only one row. * ARRAY requires just one target column, and creates an array of the target * column's type using one or more rows resulting from the subselect. * ALL, ANY, and MULTIEXPR require the combining operators to deliver boolean * results. These are reduced to one result per row using OR or AND semantics * depending on the "useOr" flag. ALL and ANY combine the per-row results * using AND and OR semantics respectively. * * SubLink is classed as an Expr node, but it is not actually executable; * it must be replaced in the expression tree by a SubPlan node during * planning. * * NOTE: in the raw output of gram.y, lefthand contains a list of raw * expressions; useOr and operOids are not filled in yet. Also, subselect * is a raw parsetree. During parse analysis, the parser transforms the * lefthand expression list using normal expression transformation rules. * It fills operOids with the OIDs representing the specific operator(s) * to apply to each pair of lefthand and targetlist expressions. * And subselect is transformed to a Query. This is the representation * seen in saved rules and in the rewriter. * * In EXISTS, EXPR, and ARRAY SubLinks, lefthand, operName, and operOids are * unused and are always NIL. useOr is not significant either for these * sublink types. * ---------------- */typedef enum SubLinkType{ EXISTS_SUBLINK, ALL_SUBLINK, ANY_SUBLINK, MULTIEXPR_SUBLINK, EXPR_SUBLINK, ARRAY_SUBLINK} SubLinkType;typedef struct SubLink{ Expr xpr; SubLinkType subLinkType; /* EXISTS, ALL, ANY, MULTIEXPR, EXPR */ bool useOr; /* TRUE to combine column results with * "OR" not "AND" */ List *lefthand; /* list of outer-query expressions on the * left */ List *operName; /* originally specified operator name */ List *operOids; /* OIDs of actual combining operators */ Node *subselect; /* subselect as Query* or parsetree */} SubLink;/* * SubPlan - executable expression node for a subplan (sub-SELECT) * * The planner replaces SubLink nodes in expression trees with SubPlan * nodes after it has finished planning the subquery. SubPlan contains * a sub-plantree and rtable instead of a sub-Query. * * In an ordinary subplan, "exprs" points to a list of executable expressions * (OpExpr trees) for the combining operators; their left-hand arguments are * the original lefthand expressions, and their right-hand arguments are * PARAM_EXEC Param nodes representing the outputs of the sub-select. * (NOTE: runtime coercion functions may be inserted as well.) But if the * sub-select becomes an initplan rather than a subplan, these executable * expressions are part of the outer plan's expression tree (and the SubPlan * node itself is not). In this case "exprs" is NIL to avoid duplication. * * The planner also derives lists of the values that need to be passed into * and out of the subplan. Input values are represented as a list "args" of * expressions to be evaluated in the outer-query context (currently these * args are always just Vars, but in principle they could be any expression). * The values are assigned to the global PARAM_EXEC params indexed by parParam * (the parParam and args lists must have the same ordering). setParam is a * list of the PARAM_EXEC params that are computed by the sub-select, if it * is an initplan; they are listed in order by sub-select output column * position. (parParam and setParam are integer Lists, not Bitmapsets, * because their ordering is significant.) */typedef struct SubPlan{ Expr xpr; /* Fields copied from original SubLink: */ SubLinkType subLinkType; /* EXISTS, ALL, ANY, MULTIEXPR, EXPR */ bool useOr; /* TRUE to combine column results with * "OR" not "AND" */ /* The combining operators, transformed to executable expressions: */ List *exprs; /* list of OpExpr expression trees */ List *paramIds; /* IDs of Params embedded in the above */ /* Note: paramIds has a one-to-one correspondence to the exprs list */ /* The subselect, transformed to a Plan: */ struct Plan *plan; /* subselect plan itself */ int plan_id; /* dummy thing because of we haven't equal * funcs for plan nodes... actually, we * could put *plan itself somewhere else * (TopPlan node ?)... */ List *rtable; /* range table for subselect */ /* Information about execution strategy: */ bool useHashTable; /* TRUE to store subselect output in a * hash table (implies we are doing "IN") */ bool unknownEqFalse; /* TRUE if it's okay to return FALSE when * the spec result is UNKNOWN; this allows * much simpler handling of null values */ /* Information for passing params into and out of the subselect: */ /* setParam and parParam are lists of integers (param IDs) */ List *setParam; /* initplan subqueries have to set these * Params for parent plan */ List *parParam; /* indices of input Params from parent * plan */ List *args; /* exprs to pass as parParam values */} SubPlan;/* ---------------- * FieldSelect * * FieldSelect represents the operation of extracting one field from a tuple * value. At runtime, the input expression is expected to yield a Datum * that contains a pointer-to-TupleTableSlot. The specified field number * is extracted and returned as a Datum. * ---------------- */typedef struct FieldSelect{ Expr xpr; Expr *arg; /* input expression */ AttrNumber fieldnum; /* attribute number of field to extract */ Oid resulttype; /* type of the field (result type of this * node) */ int32 resulttypmod; /* output typmod (usually -1) */} FieldSelect;/* ---------------- * RelabelType * * RelabelType represents a "dummy" type coercion between two binary- * compatible datatypes, such as reinterpreting the result of an OID * expression as an int4. It is a no-op at runtime; we only need it * to provide a place to store the correct type to be attributed to * the expression result during type resolution. (We can't get away * with just overwriting the type field of the input expression node, * so we need a separate node to show the coercion's result type.) * ---------------- */typedef struct RelabelType
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?