* and join trees.
*
*
- * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.139 2008/08/22 00:16:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.148 2009/04/05 19:59:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* on children? */
bool istemp; /* is this a temp relation/sequence? */
Alias *alias; /* table alias & optional column aliases */
+ int location; /* token location, or -1 if unknown */
} RangeVar;
/*
* all */
Oid vartype; /* pg_type OID for the type of this var */
int32 vartypmod; /* pg_attribute typmod value */
- Index varlevelsup;
-
- /*
- * for subquery variables referencing outer relations; 0 in a normal var,
- * >0 means N levels up
- */
+ Index varlevelsup; /* for subquery variables referencing outer
+ * relations; 0 in a normal var, >0 means N
+ * levels up */
Index varnoold; /* original value of varno, for debugging */
AttrNumber varoattno; /* original value of varattno */
+ int location; /* token location, or -1 if unknown */
} Var;
/*
* If true, then all the information is stored
* in the Datum. If false, then the Datum
* contains a pointer to the information. */
+ int location; /* token location, or -1 if unknown */
} Const;
/* ----------------
int paramid; /* numeric ID for parameter */
Oid paramtype; /* pg_type OID of parameter's datatype */
int32 paramtypmod; /* typmod value, if known */
+ int location; /* token location, or -1 if unknown */
} Param;
/*
Index agglevelsup; /* > 0 if agg belongs to outer query */
bool aggstar; /* TRUE if argument list was really '*' */
bool aggdistinct; /* TRUE if it's agg(DISTINCT ...) */
+ int location; /* token location, or -1 if unknown */
} Aggref;
+/*
+ * WindowFunc
+ */
+typedef struct WindowFunc
+{
+ Expr xpr;
+ Oid winfnoid; /* pg_proc Oid of the function */
+ Oid wintype; /* type Oid of result of the window function */
+ List *args; /* arguments to the window function */
+ Index winref; /* index of associated WindowClause */
+ bool winstar; /* TRUE if argument list was really '*' */
+ bool winagg; /* is function a simple aggregate? */
+ int location; /* token location, or -1 if unknown */
+} WindowFunc;
+
/* ----------------
* ArrayRef: describes an array subscripting operation
*
bool funcretset; /* true if function returns set */
CoercionForm funcformat; /* how to display this function call */
List *args; /* arguments to the function */
+ int location; /* token location, or -1 if unknown */
} FuncExpr;
/*
Oid opresulttype; /* PG_TYPE OID of result value */
bool opretset; /* true if operator returns set */
List *args; /* arguments to the operator (1 or 2) */
+ int location; /* token location, or -1 if unknown */
} OpExpr;
/*
Oid opfuncid; /* PG_PROC OID of underlying function */
bool useOr; /* true for ANY, false for ALL */
List *args; /* the scalar and array operands */
+ int location; /* token location, or -1 if unknown */
} ScalarArrayOpExpr;
/*
*
* 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.
+ * handle any number of arguments. The parser generally treats AND and OR
+ * as binary and so it typically only produces two-element lists, but the
+ * optimizer will flatten trees of AND and OR nodes to produce longer lists
+ * when possible. There are also a few special cases where more arguments
+ * can appear before optimization.
*/
typedef enum BoolExprType
{
Expr xpr;
BoolExprType boolop;
List *args; /* arguments to this expression */
+ int location; /* token location, or -1 if unknown */
} BoolExpr;
/*
* ROWCOMPARE_SUBLINK (lefthand) op (SELECT ...)
* EXPR_SUBLINK (SELECT with single targetlist item ...)
* ARRAY_SUBLINK ARRAY(SELECT with single targetlist item ...)
+ * CTE_SUBLINK WITH query (never actually part of an expression)
* For ALL, ANY, and ROWCOMPARE, the lefthand is a list of expressions of the
* same length as the subselect's targetlist. ROWCOMPARE will *always* have
* a list with more than one entry; if the subselect has just one target
*
* In EXISTS, EXPR, and ARRAY SubLinks, testexpr and operName are unused and
* are always null.
+ *
+ * The CTE_SUBLINK case never occurs in actual SubLink nodes, but it is used
+ * in SubPlans generated for WITH subqueries.
*/
typedef enum SubLinkType
{
ANY_SUBLINK,
ROWCOMPARE_SUBLINK,
EXPR_SUBLINK,
- ARRAY_SUBLINK
+ ARRAY_SUBLINK,
+ CTE_SUBLINK /* for SubPlans only */
} SubLinkType;
Node *testexpr; /* outer-query test for ALL/ANY/ROWCOMPARE */
List *operName; /* originally specified operator name */
Node *subselect; /* subselect as Query* or parsetree */
+ int location; /* token location, or -1 if unknown */
} SubLink;
/*
List *paramIds; /* IDs of Params embedded in the above */
/* Identification of the Plan tree to use: */
int plan_id; /* Index (from 1) in PlannedStmt.subplans */
+ /* Identification of the SubPlan for EXPLAIN and debugging purposes: */
+ char *plan_name; /* A name assigned during planning */
/* Extra data useful for determining subplan's output type: */
Oid firstColType; /* Type of first column of subplan result */
+ int32 firstColTypmod; /* Typmod of first column of subplan result */
/* Information about execution strategy: */
bool useHashTable; /* TRUE to store subselect output in a hash
* table (implies we are doing "IN") */
Oid resulttype; /* output type of coercion expression */
int32 resulttypmod; /* output typmod (usually -1) */
CoercionForm relabelformat; /* how to display this node */
+ int location; /* token location, or -1 if unknown */
} RelabelType;
/* ----------------
Oid resulttype; /* output type of coercion */
/* output typmod is not stored, but is presumed -1 */
CoercionForm coerceformat; /* how to display this node */
+ int location; /* token location, or -1 if unknown */
} CoerceViaIO;
/* ----------------
int32 resulttypmod; /* output typmod (also element typmod) */
bool isExplicit; /* conversion semantics flag to pass to func */
CoercionForm coerceformat; /* how to display this node */
+ int location; /* token location, or -1 if unknown */
} ArrayCoerceExpr;
/* ----------------
Oid resulttype; /* output type (always a composite type) */
/* result typmod is not stored, but must be -1; see RowExpr comments */
CoercionForm convertformat; /* how to display this node */
+ int location; /* token location, or -1 if unknown */
} ConvertRowtypeExpr;
/*----------
Expr *arg; /* implicit equality comparison argument */
List *args; /* the arguments (list of WHEN clauses) */
Expr *defresult; /* the default result (ELSE clause) */
+ int location; /* token location, or -1 if unknown */
} CaseExpr;
/*
Expr xpr;
Expr *expr; /* condition expression */
Expr *result; /* substitution result */
+ int location; /* token location, or -1 if unknown */
} CaseWhen;
/*
Oid element_typeid; /* common type of array elements */
List *elements; /* the array elements or sub-arrays */
bool multidims; /* true if elements are sub-arrays */
+ int location; /* token location, or -1 if unknown */
} ArrayExpr;
/*
* not RECORD types, since those are built from the RowExpr itself rather
* than vice versa.) It is important not to assume that length(args) is
* the same as the number of columns logically present in the rowtype.
+ *
+ * colnames is NIL in a RowExpr built from an ordinary ROW() expression.
+ * It is provided in cases where we expand a whole-row Var into a RowExpr,
+ * to retain the column alias names of the RTE that the Var referenced
+ * (which would otherwise be very difficult to extract from the parsetree).
+ * Like the args list, it is one-for-one with physical fields of the rowtype.
*/
typedef struct RowExpr
{
* parsetrees. We must assume typmod -1 for a RowExpr node.
*/
CoercionForm row_format; /* how to display this node */
+ List *colnames; /* list of String, or NIL */
+ int location; /* token location, or -1 if unknown */
} RowExpr;
/*
Expr xpr;
Oid coalescetype; /* type of expression result */
List *args; /* the arguments */
+ int location; /* token location, or -1 if unknown */
} CoalesceExpr;
/*
Oid minmaxtype; /* common type of arguments and result */
MinMaxOp op; /* function to execute */
List *args; /* the arguments */
+ int location; /* token location, or -1 if unknown */
} MinMaxExpr;
/*
XmlOptionType xmloption; /* DOCUMENT or CONTENT */
Oid type; /* target type for XMLSERIALIZE */
int32 typmod;
+ int location; /* token location, or -1 if unknown */
} XmlExpr;
/*
Oid resulttype; /* domain type ID (result type) */
int32 resulttypmod; /* output typmod (currently always -1) */
CoercionForm coercionformat; /* how to display this node */
+ int location; /* token location, or -1 if unknown */
} CoerceToDomain;
/*
Expr xpr;
Oid typeId; /* type for substituted value */
int32 typeMod; /* typemod for substituted value */
+ int location; /* token location, or -1 if unknown */
} CoerceToDomainValue;
/*
Expr xpr;
Oid typeId; /* type for substituted value */
int32 typeMod; /* typemod for substituted value */
+ int location; /* token location, or -1 if unknown */
} SetToDefault;
/*
*
* 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.
+ * be created that refer to the outputs of the join. The planner sometimes
+ * generates JoinExprs internally; these can have rtindex = 0 if there are
+ * no join alias variables referencing such joins.
*----------
*/
typedef struct JoinExpr
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 */
+ int rtindex; /* RT index assigned for join, or 0 */
} JoinExpr;
/*----------