1 /*-------------------------------------------------------------------------
4 * Definitions for internal planner nodes.
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: relation.h,v 1.16 1999/02/08 04:29:25 momjian Exp $
11 *-------------------------------------------------------------------------
16 #include <nodes/parsenodes.h>
17 #include <nodes/primnodes.h>
21 * List of relation identifiers (indexes into the rangetable).
28 * Per-base-relation information
30 * Parts of this data structure are specific to various scan and join
31 * mechanisms. It didn't seem worth creating new node types for them.
33 * relids - List of relation indentifiers
34 * indexed - true if the relation has secondary indices
35 * pages - number of pages in the relation
36 * tuples - number of tuples in the relation
37 * size - number of tuples in the relation after restrictions clauses
39 * width - number of bytes per tuple in the relation after the
40 * appropriate projections have been done
41 * targetlist - List of TargetList nodes
42 * pathlist - List of Path nodes, one for each possible method of
43 * generating the relation
44 * unorderedpath - a Path node generating this relation whose resulting
45 * tuples are unordered (this isn't necessarily a
46 * sequential scan path, e.g., scanning with a hash index
47 * leaves the tuples unordered)
48 * cheapestpath - least expensive Path (regardless of final order)
49 * pruneable - flag to let the planner know whether it can prune the plan
50 * space of this RelOptInfo or not.
52 * * If the relation is a (secondary) index it will have the following
55 * classlist - List of PG_AMOPCLASS OIDs for the index
56 * indexkeys - List of base-relation attribute numbers that are index keys
57 * ordering - List of PG_OPERATOR OIDs which order the indexscan result
58 * relam - the OID of the pg_am of the index
60 * * The presence of the remaining fields depends on the restrictions
61 * and joins which the relation participates in:
63 * restrictinfo - List of RestrictInfo nodes, containing info about each
64 * qualification clause in which this relation participates
65 * joininfo - List of JoinInfo nodes, containing info about each join
66 * clause in which this relation participates
67 * innerjoin - List of Path nodes that represent indices that may be used
68 * as inner paths of nestloop joins
70 * NB. the last element of the arrays classlist, indexkeys and ordering
71 * is always 0. 2/95 - ay
74 typedef struct RelOptInfo
81 /* catalog statistics information */
88 /* materialization information */
90 List *pathlist; /* Path structures */
91 struct Path *unorderedpath;
92 struct Path *cheapestpath;
95 /* used solely by indices: */
96 Oid *classlist; /* classes of AM operators */
97 int *indexkeys; /* keys over which we're indexing */
98 Oid relam; /* OID of the access method (in pg_am) */
103 /* used by various scans and joins: */
104 Oid *ordering; /* OID of operators in sort order */
105 List *restrictinfo; /* RestrictInfo structures */
106 List *joininfo; /* JoinInfo structures */
111 extern Var *get_expr(TargetEntry *foo);
113 typedef struct MergeOrder
123 typedef enum OrderType
125 MERGE_ORDER, SORTOP_ORDER
128 typedef struct PathOrder
147 PathOrder path_order;
152 List *loc_restrictinfo;
155 typedef struct IndexPath
160 int *indexkeys; /* to transform heap attnos into index ones */
163 typedef struct JoinPath
171 typedef struct MergePath
174 List *path_mergeclauses;
179 typedef struct HashPath
182 List *path_hashclauses;
191 typedef struct OrderKey
194 int attribute_number;
198 typedef struct JoinKey
209 typedef struct RestrictInfo
212 Expr *clause; /* should be an OP clause */
218 MergeOrder *mergejoinorder;
221 Oid hashjoinoperator;
222 Relid restrictinfojoinid;
225 typedef struct JoinMethod
232 typedef struct HashInfo
238 typedef struct MergeInfo
241 MergeOrder *m_ordering;
244 typedef struct JoinInfo
248 List *jinfo_restrictinfo;
258 Oid itertype; /* type of the iter expr (use for type
264 ** A stream represents a root-to-leaf path in a plan tree (i.e. a tree of
265 ** JoinPaths and Paths). The stream includes pointers to all Path nodes,
266 ** as well as to any clauses that reside above Path nodes. This structure
267 ** is used to make Path nodes and clauses look similar, so that Predicate
268 ** Migration can run.
270 ** pathptr -- pointer to the current path node
271 ** cinfo -- if NULL, this stream node referes to the path node.
272 ** Otherwise this is a pointer to the current clause.
273 ** clausetype -- whether cinfo is in loc_restrictinfo or pathinfo in the
275 ** upstream -- linked list pointer upwards
276 ** downstream -- ditto, downwards
277 ** groupup -- whether or not this node is in a group with the node upstream
278 ** groupcost -- total cost of the group that node is in
279 ** groupsel -- total selectivity of the group that node is in
281 typedef struct Stream *StreamPtr;
283 typedef struct Stream
289 struct Stream *upstream;
290 struct Stream *downstream;
296 #endif /* RELATION_H */