Commit 26e03211 authored by Bruce Momjian's avatar Bruce Momjian

Move structure comments from the top block down to the line entries for

this file to match all the other files, and to be clearer.
parent 4c4f305b
...@@ -80,7 +80,7 @@ example, the WHERE clause "tab1.col1 = tab2.col1" generates a JoinInfo ...@@ -80,7 +80,7 @@ example, the WHERE clause "tab1.col1 = tab2.col1" generates a JoinInfo
for tab1 listing tab2 as an unjoined relation, and also one for tab2 for tab1 listing tab2 as an unjoined relation, and also one for tab2
showing tab1 as an unjoined relation. showing tab1 as an unjoined relation.
If we have only a single base relation in the query, we are done now. If we have only a single base relation in the query, we are done.
Otherwise we have to figure out how to join the base relations into a Otherwise we have to figure out how to join the base relations into a
single join relation. single join relation.
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: primnodes.h,v 1.49 2000/09/29 18:21:39 tgl Exp $ * $Id: primnodes.h,v 1.50 2001/01/17 06:41:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -29,17 +29,8 @@ typedef struct FunctionCache *FunctionCachePtr; ...@@ -29,17 +29,8 @@ typedef struct FunctionCache *FunctionCachePtr;
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
/* ---------------- /*
* Resdom (Result Domain) * Resdom (Result Domain)
* resno - attribute number
* restype - type of the value
* restypmod - type-specific modifier of the value
* resname - name of the resdom (could be NULL)
* ressortgroupref - nonzero if referenced by a sort/group clause
* reskey - order of key in a sort (for those > 0)
* reskeyop - sort operator's regproc Oid
* resjunk - set to true to eliminate the attribute
* from final target list
* *
* Notes: * Notes:
* ressortgroupref is the parse/plan-time representation of ORDER BY and * ressortgroupref is the parse/plan-time representation of ORDER BY and
...@@ -59,46 +50,48 @@ typedef struct FunctionCache *FunctionCachePtr; ...@@ -59,46 +50,48 @@ typedef struct FunctionCache *FunctionCachePtr;
* *
* Both reskey and reskeyop are typically zero during parse/plan stages. * Both reskey and reskeyop are typically zero during parse/plan stages.
* The executor does not pay any attention to ressortgroupref. * The executor does not pay any attention to ressortgroupref.
* ---------------- *
*/ */
typedef struct Resdom typedef struct Resdom
{ {
NodeTag type; NodeTag type;
AttrNumber resno; AttrNumber resno; /* attribute number */
Oid restype; Oid restype; /* type of the value */
int32 restypmod; int32 restypmod; /* type-specific modifier of the value */
char *resname; char *resname; /* name of the resdom (could be NULL) */
Index ressortgroupref; Index ressortgroupref;
Index reskey; /* nonzero if referenced by a sort/group clause */
Oid reskeyop; Index reskey; /* order of key in a sort (for those > 0) */
bool resjunk; Oid reskeyop; /* sort operator's regproc Oid */
bool resjunk; /* set to true to eliminate the attribute
* from final target list */
} Resdom; } Resdom;
/* ------------- /*
* Fjoin * Fjoin
* initialized - true if the Fjoin has already been initialized for
* the current target list evaluation
* nNodes - The number of Iter nodes returning sets that the
* node will flatten
* outerList - 1 or more Iter nodes
* inner - exactly one Iter node. We eval every node in the
* outerList once then eval the inner node to completion
* pair the outerList result vector with each inner
* result to form the full result. When the inner has
* been exhausted, we get the next outer result vector
* and reset the inner.
* results - The complete (flattened) result vector
* alwaysNull - a null vector to indicate sets with a cardinality of
* 0, we treat them as the set {NULL}.
*/ */
typedef struct Fjoin typedef struct Fjoin
{ {
NodeTag type; NodeTag type;
bool fj_initialized; bool fj_initialized; /* true if the Fjoin has already been
int fj_nNodes; * initialized for the current target
List *fj_innerNode; * list evaluation */
DatumPtr fj_results; int fj_nNodes; /* The number of Iter nodes returning
BoolPtr fj_alwaysDone; * sets that the node will flatten */
List *fj_innerNode; /* exactly one Iter node. We eval every
* node in the outerList once then eval
* the inner node to completion pair the
* outerList result vector with each inner
* result to form the full result. When
* the inner has been exhausted, we get
* the next outer result vector and reset
* the inner.
*/
DatumPtr fj_results; /* The complete (flattened) result vector */
BoolPtr fj_alwaysDone; /* a null vector to indicate sets with a
* cardinality of 0, we treat them as the
* set {NULL}.
*/
} Fjoin; } Fjoin;
...@@ -107,13 +100,8 @@ typedef struct Fjoin ...@@ -107,13 +100,8 @@ typedef struct Fjoin
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
/* ---------------- /*
* Expr * Expr
* typeOid - oid of the type of this expression
* opType - type of this expression
* oper - operator node if needed (Oper, Func, or SubPlan)
* args - arguments to this expression
* ----------------
*/ */
typedef enum OpType typedef enum OpType
{ {
...@@ -123,23 +111,15 @@ typedef enum OpType ...@@ -123,23 +111,15 @@ typedef enum OpType
typedef struct Expr typedef struct Expr
{ {
NodeTag type; NodeTag type;
Oid typeOid; /* oid of the type of this expr */ Oid typeOid; /* oid of the type of this expression */
OpType opType; /* type of the op */ OpType opType; /* type of this expression */
Node *oper; /* could be Oper or Func or SubPlan */ Node *oper; /* operator node if needed (Oper, Func, or
List *args; /* list of argument nodes */ * SubPlan) */
List *args; /* arguments to this expression */
} Expr; } Expr;
/* ---------------- /*
* Var * Var
* varno - index of this var's relation in the range table
* (could also be INNER or OUTER)
* varattno - attribute number of this var, or zero for all
* vartype - pg_type tuple OID for the type of this var
* vartypmod - pg_attribute typmod value
* varlevelsup - for subquery variables referencing outer relations;
* 0 in a normal var, >0 means N levels up
* varnoold - original value of varno
* varoattno - original value of varattno
* *
* Note: during parsing/planning, varnoold/varoattno are always just copies * Note: during parsing/planning, varnoold/varoattno are always just copies
* of varno/varattno. At the tail end of planning, Var nodes appearing in * of varno/varattno. At the tail end of planning, Var nodes appearing in
...@@ -160,23 +140,22 @@ typedef struct Expr ...@@ -160,23 +140,22 @@ typedef struct Expr
typedef struct Var typedef struct Var
{ {
NodeTag type; NodeTag type;
Index varno; Index varno; /* index of this var's relation in the range
AttrNumber varattno; * table (could also be INNER or OUTER) */
Oid vartype; AttrNumber varattno; /* attribute number of this var, or zero for all */
int32 vartypmod; Oid vartype; /* pg_type tuple OID for the type of this var */
int32 vartypmod; /* pg_attribute typmod value */
Index varlevelsup; Index varlevelsup;
Index varnoold; /* mainly for debugging --- see above */ /* for subquery variables referencing outer
AttrNumber varoattno; * 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 */
} Var; } Var;
/* ---------------- /*
* Oper * Oper
* opno - PG_OPERATOR OID of the operator
* opid - PG_PROC OID for the operator's underlying function
* opresulttype - PG_TYPE OID of the operator's return value
* op_fcache - runtime state while running the function
* *
* ----
* NOTE: in the good old days 'opno' used to be both (or either, or * NOTE: in the good old days 'opno' used to be both (or either, or
* neither) the pg_operator oid, and/or the pg_proc oid depending * neither) the pg_operator oid, and/or the pg_proc oid depending
* on the postgres module in question (parser->pg_operator, * on the postgres module in question (parser->pg_operator,
...@@ -190,43 +169,40 @@ typedef struct Var ...@@ -190,43 +169,40 @@ typedef struct Var
* Note also that opid is not necessarily filled in immediately on creation * Note also that opid is not necessarily filled in immediately on creation
* of the node. The planner makes sure it is valid before passing the node * of the node. The planner makes sure it is valid before passing the node
* tree to the executor, but during parsing/planning opid is typically 0. * tree to the executor, but during parsing/planning opid is typically 0.
* ---------------- *
*/ */
typedef struct Oper typedef struct Oper
{ {
NodeTag type; NodeTag type;
Oid opno; Oid opno; /* PG_OPERATOR OID of the operator */
Oid opid; Oid opid; /* PG_PROC OID for the operator's underlying
* function */
Oid opresulttype; Oid opresulttype;
/* PG_TYPE OID of the operator's return value */
FunctionCachePtr op_fcache; FunctionCachePtr op_fcache;
/* runtime state while running the function */
} Oper; } Oper;
/* ---------------- /*
* Const * Const
* consttype - PG_TYPE OID of the constant's value
* constlen - length in bytes of the constant's value
* constvalue - the constant's value
* constisnull - whether the constant is null
* (if true, the other fields are undefined)
* constbyval - whether the information in constvalue
* if passed by value. If true, then all the information
* is stored in the datum. If false, then the datum
* contains a pointer to the information.
* constisset - whether the const represents a set. The const
* value corresponding will be the query that defines
* the set.
* ----------------
*/ */
typedef struct Const typedef struct Const
{ {
NodeTag type; NodeTag type;
Oid consttype; Oid consttype; /* PG_TYPE OID of the constant's value */
int constlen; int constlen; /* length in bytes of the constant's value */
Datum constvalue; Datum constvalue; /* the constant's value */
bool constisnull; bool constisnull; /* whether the constant is null (if true,
bool constbyval; * the other fields are undefined) */
bool constisset; bool constbyval; /* whether the information in constvalue
* if passed by value. If true, then all
* the information is stored in the datum.
* If false, then the datum contains a pointer
* to the information. */
bool constisset; /* whether the const represents a set.
* The const value corresponding will be the
* query that defines the set. */
bool constiscast; bool constiscast;
} Const; } Const;
...@@ -250,38 +226,33 @@ typedef struct Const ...@@ -250,38 +226,33 @@ typedef struct Const
* *
* PARAM_OLD: Same as PARAM_NEW, but in this case we refer to * PARAM_OLD: Same as PARAM_NEW, but in this case we refer to
* the "OLD" tuple. * the "OLD" tuple.
*
* paramid - numeric identifier for literal-constant parameters ("$1")
* paramname - attribute name for tuple-substitution parameters ("$.foo")
* paramtype - PG_TYPE OID of the parameter's value
* ---------------- * ----------------
*/ */
typedef struct Param typedef struct Param
{ {
NodeTag type; NodeTag type;
int paramkind; int paramkind; /* specifies the kind of parameter. See above */
AttrNumber paramid; AttrNumber paramid; /* numeric identifier for literal-constant
char *paramname; * parameters ("$1") */
Oid paramtype; char *paramname; /* attribute name for tuple-substitution
* parameters ("$.foo") */
Oid paramtype; /* PG_TYPE OID of the parameter's value */
} Param; } Param;
/* ---------------- /*
* Func * Func
* funcid - PG_PROC OID of the function
* functype - PG_TYPE OID of the function's return value
* func_fcache - runtime state while running this function. Where
* we are in the execution of the function if it
* returns more than one value, etc.
* See utils/fcache.h
* ----------------
*/ */
typedef struct Func typedef struct Func
{ {
NodeTag type; NodeTag type;
Oid funcid; Oid funcid; /* PG_PROC OID of the function */
Oid functype; Oid functype; /* PG_TYPE OID of the function's return value */
FunctionCachePtr func_fcache; FunctionCachePtr func_fcache;
/* runtime state while running this function.
* Where we are in the execution of the function
* if it returns more than one value, etc.
* See utils/fcache.h */
} Func; } Func;
/* ---------------- /* ----------------
...@@ -298,36 +269,24 @@ typedef struct Iter ...@@ -298,36 +269,24 @@ typedef struct Iter
* checking) */ * checking) */
} Iter; } Iter;
/* ---------------- /*
* Aggref * Aggref
* aggname - name of the aggregate
* basetype - base type Oid of the aggregate (ie, input type)
* aggtype - type Oid of final result of the aggregate
* target - attribute or expression we are aggregating on
* aggstar - TRUE if argument was really '*'
* aggdistinct - TRUE if it's agg(DISTINCT ...)
* aggno - workspace for executor (see nodeAgg.c)
* ----------------
*/ */
typedef struct Aggref typedef struct Aggref
{ {
NodeTag type; NodeTag type;
char *aggname; char *aggname; /* name of the aggregate */
Oid basetype; Oid basetype; /* base type Oid of the aggregate
Oid aggtype; * (ie, input type) */
Node *target; Oid aggtype; /* type Oid of final result of the aggregate */
bool aggstar; Node *target; /* attribute or expression we are aggregating on */
bool aggdistinct; bool aggstar; /* TRUE if argument was really '*' */
int aggno; bool aggdistinct;/* TRUE if it's agg(DISTINCT ...) */
int aggno; /* workspace for executor (see nodeAgg.c) */
} Aggref; } Aggref;
/* ---------------- /* ----------------
* SubLink * SubLink
* subLinkType - EXISTS, ALL, ANY, MULTIEXPR, EXPR
* useor - TRUE to combine column results with "OR" not "AND"
* lefthand - list of outer-query expressions on the left
* oper - list of Oper nodes for combining operators
* subselect - subselect as Query* or parsetree
* *
* A SubLink represents a subselect appearing in an expression, and in some * A SubLink represents a subselect appearing in an expression, and in some
* cases also the combining operator(s) just above it. The subLinkType * cases also the combining operator(s) just above it. The subLinkType
...@@ -385,11 +344,12 @@ typedef enum SubLinkType ...@@ -385,11 +344,12 @@ typedef enum SubLinkType
typedef struct SubLink typedef struct SubLink
{ {
NodeTag type; NodeTag type;
SubLinkType subLinkType; SubLinkType subLinkType;/* EXISTS, ALL, ANY, MULTIEXPR, EXPR */
bool useor; bool useor; /* TRUE to combine column results with "OR"
List *lefthand; * not "AND" */
List *oper; List *lefthand; /* list of outer-query expressions on the left */
Node *subselect; List *oper; /* list of Oper nodes for combining operators */
Node *subselect; /* subselect as Query* or parsetree */
} SubLink; } SubLink;
/* ---------------- /* ----------------
...@@ -402,15 +362,6 @@ typedef struct SubLink ...@@ -402,15 +362,6 @@ typedef struct SubLink
* appropriate part of the array; the result of the operation is an * appropriate part of the array; the result of the operation is an
* entire new modified array value. * entire new modified array value.
* *
* refattrlength - typlen of array type
* refelemtype - type of the result of the ArrayRef operation
* refelemlength - typlen of the array element type
* refelembyval - is the element type pass-by-value?
* refupperindexpr - expressions that evaluate to upper array indexes
* reflowerindexpr - expressions that evaluate to lower array indexes
* refexpr - the expression that evaluates to an array value
* refassgnexpr - expression for the source value, or NULL if fetch
*
* If reflowerindexpr = NIL, then we are fetching or storing a single array * If reflowerindexpr = NIL, then we are fetching or storing a single array
* element at the subscripts given by refupperindexpr. Otherwise we are * element at the subscripts given by refupperindexpr. Otherwise we are
* fetching or storing an array slice, that is a rectangular subarray * fetching or storing an array slice, that is a rectangular subarray
...@@ -432,22 +383,23 @@ typedef struct SubLink ...@@ -432,22 +383,23 @@ typedef struct SubLink
typedef struct ArrayRef typedef struct ArrayRef
{ {
NodeTag type; NodeTag type;
int refattrlength; int refattrlength; /* typlen of array type */
int refelemlength; int refelemlength; /* typlen of the array element type */
Oid refelemtype; Oid refelemtype; /* type of the result of the ArrayRef
bool refelembyval; * operation */
List *refupperindexpr; bool refelembyval; /* is the element type pass-by-value? */
List *reflowerindexpr; List *refupperindexpr; /* expressions that evaluate to upper
Node *refexpr; * array indexes */
Node *refassgnexpr; List *reflowerindexpr; /* expressions that evaluate to lower
* array indexes */
Node *refexpr; /* the expression that evaluates to an
* array value */
Node *refassgnexpr; /* expression for the source value, or NULL
* if fetch */
} ArrayRef; } ArrayRef;
/* ---------------- /* ----------------
* FieldSelect * FieldSelect
* arg - input expression
* fieldnum - attribute number of field to extract
* resulttype - type of the field (result type of this node)
* resulttypmod - output typmod (usually -1)
* *
* FieldSelect represents the operation of extracting one field from a tuple * FieldSelect represents the operation of extracting one field from a tuple
* value. At runtime, the input expression is expected to yield a Datum * value. At runtime, the input expression is expected to yield a Datum
...@@ -459,17 +411,15 @@ typedef struct ArrayRef ...@@ -459,17 +411,15 @@ typedef struct ArrayRef
typedef struct FieldSelect typedef struct FieldSelect
{ {
NodeTag type; NodeTag type;
Node *arg; Node *arg; /* input expression */
AttrNumber fieldnum; AttrNumber fieldnum; /* attribute number of field to extract */
Oid resulttype; Oid resulttype; /* type of the field (result type of this
int32 resulttypmod; * node) */
int32 resulttypmod; /* output typmod (usually -1) */
} FieldSelect; } FieldSelect;
/* ---------------- /* ----------------
* RelabelType * RelabelType
* arg - input expression
* resulttype - output type of coercion expression
* resulttypmod - output typmod (usually -1)
* *
* RelabelType represents a "dummy" type coercion between two binary- * RelabelType represents a "dummy" type coercion between two binary-
* compatible datatypes, such as reinterpreting the result of an OID * compatible datatypes, such as reinterpreting the result of an OID
...@@ -484,9 +434,9 @@ typedef struct FieldSelect ...@@ -484,9 +434,9 @@ typedef struct FieldSelect
typedef struct RelabelType typedef struct RelabelType
{ {
NodeTag type; NodeTag type;
Node *arg; Node *arg; /* input expression */
Oid resulttype; Oid resulttype; /* output type of coercion expression */
int32 resulttypmod; int32 resulttypmod; /* output typmod (usually -1) */
} RelabelType; } RelabelType;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment