1 /*-------------------------------------------------------------------------
4 * Definitions for internal planner nodes.
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: relation.h,v 1.2 1996/10/31 09:49:18 scrappy Exp $
11 *-------------------------------------------------------------------------
16 #include "nodes/pg_list.h"
17 #include "nodes/primnodes.h"
18 #include "nodes/parsenodes.h"
19 #include "nodes/nodes.h"
23 * List of relation identifiers (indexes into the rangetable).
30 * Per-base-relation information
32 * Parts of this data structure are specific to various scan and join
33 * mechanisms. It didn't seem worth creating new node types for them.
35 * relids - List of relation indentifiers
36 * indexed - true if the relation has secondary indices
37 * pages - number of pages in the relation
38 * tuples - number of tuples in the relation
39 * size - number of tuples in the relation after restrictions clauses
41 * width - number of bytes per tuple in the relation after the
42 * appropriate projections have been done
43 * targetlist - List of TargetList nodes
44 * pathlist - List of Path nodes, one for each possible method of
45 * generating the relation
46 * unorderedpath - a Path node generating this relation whose resulting
47 * tuples are unordered (this isn't necessarily a
48 * sequential scan path, e.g., scanning with a hash index
49 * leaves the tuples unordered)
50 * cheapestpath - least expensive Path (regardless of final order)
51 * pruneable - flag to let the planner know whether it can prune the plan
52 * space of this Rel or not. -- JMH, 11/11/92
54 * * If the relation is a (secondary) index it will have the following
57 * classlist - List of PG_AMOPCLASS OIDs for the index
58 * indexkeys - List of base-relation attribute numbers that are index keys
59 * ordering - List of PG_OPERATOR OIDs which order the indexscan result
60 * relam - the OID of the pg_am of the index
62 * * The presence of the remaining fields depends on the restrictions
63 * and joins which the relation participates in:
65 * clauseinfo - List of ClauseInfo nodes, containing info about each
66 * qualification clause in which this relation participates
67 * joininfo - List of JoinInfo nodes, containing info about each join
68 * clause in which this relation participates
69 * innerjoin - List of Path nodes that represent indices that may be used
70 * as inner paths of nestloop joins
72 * NB. the last element of the arrays classlist, indexkeys and ordering
73 * is always 0. 2/95 - ay
82 /* catalog statistics information */
89 /* materialization information */
92 struct Path *unorderedpath;
93 struct Path *cheapestpath;
96 /* used solely by indices: */
97 Oid *classlist; /* classes of AM operators */
98 int *indexkeys; /* keys over which we're indexing */
99 Oid relam; /* OID of the access method (in pg_am) */
104 /* used by various scans and joins: */
105 Oid *ordering; /* OID of operators in sort order */
106 List *clauseinfo; /* restriction clauses */
107 List *joininfo; /* join clauses */
112 extern Var *get_expr(TargetEntry *foo);
114 typedef struct MergeOrder {
123 typedef enum OrderType {
124 MERGE_ORDER, SORTOP_ORDER
127 typedef struct PathOrder {
135 typedef struct Path {
143 PathOrder p_ordering;
151 typedef struct IndexPath {
157 typedef struct JoinPath {
159 List *pathclauseinfo;
164 typedef struct MergePath {
166 List *path_mergeclauses;
171 typedef struct HashPath {
173 List *path_hashclauses;
182 typedef struct OrderKey {
184 int attribute_number;
188 typedef struct JoinKey {
198 typedef struct CInfo {
200 Expr *clause; /* should be an OP clause */
206 MergeOrder *mergesortorder;
209 Oid hashjoinoperator;
213 typedef struct JoinMethod {
219 typedef struct HInfo {
224 typedef struct MInfo {
226 MergeOrder *m_ordering;
229 typedef struct JInfo {
232 List *jinfoclauseinfo;
238 typedef struct Iter {
241 Oid itertype; /* type of the iter expr (use for type
247 ** A stream represents a root-to-leaf path in a plan tree (i.e. a tree of
248 ** JoinPaths and Paths). The stream includes pointers to all Path nodes,
249 ** as well as to any clauses that reside above Path nodes. This structure
250 ** is used to make Path nodes and clauses look similar, so that Predicate
251 ** Migration can run.
253 ** pathptr -- pointer to the current path node
254 ** cinfo -- if NULL, this stream node referes to the path node.
255 ** Otherwise this is a pointer to the current clause.
256 ** clausetype -- whether cinfo is in locclauseinfo or pathclauseinfo in the
258 ** upstream -- linked list pointer upwards
259 ** downstream -- ditto, downwards
260 ** groupup -- whether or not this node is in a group with the node upstream
261 ** groupcost -- total cost of the group that node is in
262 ** groupsel -- total selectivity of the group that node is in
264 typedef struct Stream *StreamPtr;
266 typedef struct Stream {
271 struct Stream *upstream;
272 struct Stream *downstream;
278 #endif /* RELATION_H */