1 /*-------------------------------------------------------------------------
4 * Definitions for internal planner nodes.
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: relation.h,v 1.4 1997/03/18 18:41:37 scrappy 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 Rel or not. -- JMH, 11/11/92
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 * clauseinfo - List of ClauseInfo 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
80 /* catalog statistics information */
87 /* materialization information */
90 struct Path *unorderedpath;
91 struct Path *cheapestpath;
94 /* used solely by indices: */
95 Oid *classlist; /* classes of AM operators */
96 int *indexkeys; /* keys over which we're indexing */
97 Oid relam; /* OID of the access method (in pg_am) */
102 /* used by various scans and joins: */
103 Oid *ordering; /* OID of operators in sort order */
104 List *clauseinfo; /* restriction clauses */
105 List *joininfo; /* join clauses */
110 extern Var *get_expr(TargetEntry *foo);
112 typedef struct MergeOrder {
121 typedef enum OrderType {
122 MERGE_ORDER, SORTOP_ORDER
125 typedef struct PathOrder {
133 typedef struct Path {
141 PathOrder p_ordering;
149 typedef struct IndexPath {
153 int *indexkeys; /* to transform heap attnos into index ones */
156 typedef struct JoinPath {
158 List *pathclauseinfo;
163 typedef struct MergePath {
165 List *path_mergeclauses;
170 typedef struct HashPath {
172 List *path_hashclauses;
181 typedef struct OrderKey {
183 int attribute_number;
187 typedef struct JoinKey {
197 typedef struct CInfo {
199 Expr *clause; /* should be an OP clause */
205 MergeOrder *mergesortorder;
208 Oid hashjoinoperator;
212 typedef struct JoinMethod {
218 typedef struct HInfo {
223 typedef struct MInfo {
225 MergeOrder *m_ordering;
228 typedef struct JInfo {
231 List *jinfoclauseinfo;
237 typedef struct Iter {
240 Oid itertype; /* type of the iter expr (use for type
246 ** A stream represents a root-to-leaf path in a plan tree (i.e. a tree of
247 ** JoinPaths and Paths). The stream includes pointers to all Path nodes,
248 ** as well as to any clauses that reside above Path nodes. This structure
249 ** is used to make Path nodes and clauses look similar, so that Predicate
250 ** Migration can run.
252 ** pathptr -- pointer to the current path node
253 ** cinfo -- if NULL, this stream node referes to the path node.
254 ** Otherwise this is a pointer to the current clause.
255 ** clausetype -- whether cinfo is in locclauseinfo or pathclauseinfo in the
257 ** upstream -- linked list pointer upwards
258 ** downstream -- ditto, downwards
259 ** groupup -- whether or not this node is in a group with the node upstream
260 ** groupcost -- total cost of the group that node is in
261 ** groupsel -- total selectivity of the group that node is in
263 typedef struct Stream *StreamPtr;
265 typedef struct Stream {
270 struct Stream *upstream;
271 struct Stream *downstream;
277 #endif /* RELATION_H */