OSDN Git Service

Another pgindent run. Fixes enum indenting, and improves #endif
[pg-rex/syncrep.git] / src / include / nodes / nodes.h
1 /*-------------------------------------------------------------------------
2  *
3  * nodes.h
4  *        Definitions for tagged nodes.
5  *
6  *
7  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: nodes.h,v 1.95 2001/10/28 06:26:07 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef NODES_H
15 #define NODES_H
16
17 /*
18  * The first field of every node is NodeTag. Each node created (with makeNode)
19  * will have one of the following tags as the value of its first field.
20  *
21  * Note that the number of the node tags are not contiguous. We left holes
22  * here so that we can add more tags without changing the existing enum's.
23  */
24 typedef enum NodeTag
25 {
26         T_Invalid = 0,
27
28         /*
29          * TAGS FOR PLAN NODES (plannodes.h)
30          */
31         T_Plan = 10,
32         T_Result,
33         T_Append,
34         T_Scan,
35         T_SeqScan,
36         T_IndexScan,
37         T_Join,
38         T_NestLoop,
39         T_MergeJoin,
40         T_HashJoin,
41         T_Limit,
42         T_Material,
43         T_Sort,
44         T_Agg,
45         T_Unique,
46         T_Hash,
47         T_SetOp,
48         T_Group,
49         T_SubPlan,
50         T_TidScan,
51         T_SubqueryScan,
52
53         /*
54          * TAGS FOR PRIMITIVE NODES (primnodes.h)
55          */
56         T_Resdom = 100,
57         T_Fjoin,
58         T_Expr,
59         T_Var,
60         T_Oper,
61         T_Const,
62         T_Param,
63         T_Aggref,
64         T_SubLink,
65         T_Func,
66         T_FieldSelect,
67         T_ArrayRef,
68         T_Iter,
69         T_RelabelType,
70         T_RangeTblRef,
71         T_FromExpr,
72         T_JoinExpr,
73
74         /*
75          * TAGS FOR PLANNER NODES (relation.h)
76          */
77         T_RelOptInfo = 200,
78         T_Path,
79         T_IndexPath,
80         T_NestPath,
81         T_MergePath,
82         T_HashPath,
83         T_TidPath,
84         T_AppendPath,
85         T_PathKeyItem,
86         T_RestrictInfo,
87         T_JoinInfo,
88         T_Stream,
89         T_IndexOptInfo,
90
91         /*
92          * TAGS FOR EXECUTOR NODES (execnodes.h)
93          */
94         T_IndexInfo = 300,
95         T_ResultRelInfo,
96         T_TupleCount,
97         T_TupleTableSlot,
98         T_ExprContext,
99         T_ProjectionInfo,
100         T_JunkFilter,
101         T_EState,
102         T_BaseNode,
103         T_CommonState,
104         T_ResultState,
105         T_AppendState,
106         T_CommonScanState,
107         T_ScanState,
108         T_IndexScanState,
109         T_JoinState,
110         T_NestLoopState,
111         T_MergeJoinState,
112         T_HashJoinState,
113         T_MaterialState,
114         T_AggState,
115         T_GroupState,
116         T_SortState,
117         T_UniqueState,
118         T_HashState,
119         T_TidScanState,
120         T_SubqueryScanState,
121         T_SetOpState,
122         T_LimitState,
123
124         /*
125          * TAGS FOR MEMORY NODES (memnodes.h)
126          */
127         T_MemoryContext = 400,
128         T_AllocSetContext,
129
130         /*
131          * TAGS FOR VALUE NODES (pg_list.h)
132          */
133         T_Value = 500,
134         T_List,
135         T_Integer,
136         T_Float,
137         T_String,
138         T_BitString,
139         T_Null,
140
141         /*
142          * TAGS FOR PARSE TREE NODES (parsenodes.h)
143          */
144         T_Query = 600,
145         T_InsertStmt,
146         T_DeleteStmt,
147         T_UpdateStmt,
148         T_SelectStmt,
149         T_AlterTableStmt,
150         T_SetOperationStmt,
151         T_GrantStmt,
152         T_ClosePortalStmt,
153         T_ClusterStmt,
154         T_CopyStmt,
155         T_CreateStmt,
156         T_VersionStmt,
157         T_DefineStmt,
158         T_DropStmt,
159         T_TruncateStmt,
160         T_CommentStmt,
161         T_FetchStmt,
162         T_IndexStmt,
163         T_ProcedureStmt,
164         T_RemoveAggrStmt,
165         T_RemoveFuncStmt,
166         T_RemoveOperStmt,
167         T_RenameStmt,
168         T_RuleStmt,
169         T_NotifyStmt,
170         T_ListenStmt,
171         T_UnlistenStmt,
172         T_TransactionStmt,
173         T_ViewStmt,
174         T_LoadStmt,
175         T_CreatedbStmt,
176         T_DropdbStmt,
177         T_VacuumStmt,
178         T_ExplainStmt,
179         T_CreateSeqStmt,
180         T_VariableSetStmt,
181         T_VariableShowStmt,
182         T_VariableResetStmt,
183         T_CreateTrigStmt,
184         T_DropTrigStmt,
185         T_CreatePLangStmt,
186         T_DropPLangStmt,
187         T_CreateUserStmt,
188         T_AlterUserStmt,
189         T_DropUserStmt,
190         T_LockStmt,
191         T_ConstraintsSetStmt,
192         T_CreateGroupStmt,
193         T_AlterGroupStmt,
194         T_DropGroupStmt,
195         T_ReindexStmt,
196         T_CheckPointStmt,
197
198         T_A_Expr = 700,
199         T_Attr,
200         T_A_Const,
201         T_ParamNo,
202         T_Ident,
203         T_FuncCall,
204         T_A_Indices,
205         T_ResTarget,
206         T_TypeCast,
207         T_RangeSubselect,
208         T_SortGroupBy,
209         T_RangeVar,
210         T_TypeName,
211         T_IndexElem,
212         T_ColumnDef,
213         T_Constraint,
214         T_DefElem,
215         T_TargetEntry,
216         T_RangeTblEntry,
217         T_SortClause,
218         T_GroupClause,
219         T_NullTest,
220         T_BooleanTest,
221         T_CaseExpr,
222         T_CaseWhen,
223         T_FkConstraint,
224         T_PrivGrantee,
225
226         /*
227          * TAGS FOR FUNCTION-CALL CONTEXT AND RESULTINFO NODES (see fmgr.h)
228          */
229         T_TriggerData = 800,            /* in commands/trigger.h */
230         T_ReturnSetInfo                         /* in nodes/execnodes.h */
231
232 } NodeTag;
233
234 /*
235  * The first field of a node of any type is guaranteed to be the NodeTag.
236  * Hence the type of any node can be gotten by casting it to Node. Declaring
237  * a variable to be of Node * (instead of void *) can also facilitate
238  * debugging.
239  */
240 typedef struct Node
241 {
242         NodeTag         type;
243 } Node;
244
245 #define nodeTag(nodeptr)                (((Node*)(nodeptr))->type)
246
247 #define makeNode(_type_)                ((_type_ *) newNode(sizeof(_type_),T_##_type_))
248 #define NodeSetTag(nodeptr,t)   (((Node*)(nodeptr))->type = (t))
249
250 #define IsA(nodeptr,_type_)             (nodeTag(nodeptr) == T_##_type_)
251
252 /* ----------------------------------------------------------------
253  *                                        IsA functions (no inheritance any more)
254  * ----------------------------------------------------------------
255  */
256 #define IsA_JoinPath(jp) \
257         (IsA(jp, NestPath) || IsA(jp, MergePath) || IsA(jp, HashPath))
258
259 #define IsA_Join(jp) \
260         (IsA(jp, Join) || IsA(jp, NestLoop) || \
261          IsA(jp, MergeJoin) || IsA(jp, HashJoin))
262
263 /* ----------------------------------------------------------------
264  *                                        extern declarations follow
265  * ----------------------------------------------------------------
266  */
267
268 /*
269  * nodes/nodes.c
270  */
271 extern Node *newNode(Size size, NodeTag tag);
272
273 /*
274  * nodes/{outfuncs.c,print.c}
275  */
276 extern char *nodeToString(void *obj);
277
278 /*
279  * nodes/{readfuncs.c,read.c}
280  */
281 extern void *stringToNode(char *str);
282
283 /*
284  * nodes/copyfuncs.c
285  */
286 extern void *copyObject(void *obj);
287
288 /*
289  * nodes/equalfuncs.c
290  */
291 extern bool equal(void *a, void *b);
292
293
294 /*
295  * Typedefs for identifying qualifier selectivities and plan costs as such.
296  * These are just plain "double"s, but declaring a variable as Selectivity
297  * or Cost makes the intent more obvious.
298  *
299  * These could have gone into plannodes.h or some such, but many files
300  * depend on them...
301  */
302 typedef double Selectivity;             /* fraction of tuples a qualifier will
303                                                                  * pass */
304 typedef double Cost;                    /* execution cost (in page-access units) */
305
306
307 /*
308  * CmdType -
309  *        enums for type of operation represented by a Query
310  *
311  * ??? could have put this in parsenodes.h but many files not in the
312  *        optimizer also need this...
313  */
314 typedef enum CmdType
315 {
316         CMD_UNKNOWN,
317         CMD_SELECT,                                     /* select stmt (formerly retrieve) */
318         CMD_UPDATE,                                     /* update stmt (formerly replace) */
319         CMD_INSERT,                                     /* insert stmt (formerly append) */
320         CMD_DELETE,
321         CMD_UTILITY,                            /* cmds like create, destroy, copy,
322                                                                  * vacuum, etc. */
323         CMD_NOTHING                                     /* dummy command for instead nothing rules
324                                                                  * with qual */
325 } CmdType;
326
327
328 /*
329  * JoinType -
330  *        enums for types of relation joins
331  *
332  * JoinType determines the exact semantics of joining two relations using
333  * a matching qualification.  For example, it tells what to do with a tuple
334  * that has no match in the other relation.
335  *
336  * This is needed in both parsenodes.h and plannodes.h, so put it here...
337  */
338 typedef enum JoinType
339 {
340         /*
341          * The canonical kinds of joins
342          */
343         JOIN_INNER,                                     /* matching tuple pairs only */
344         JOIN_LEFT,                                      /* pairs + unmatched outer tuples */
345         JOIN_FULL,                                      /* pairs + unmatched outer + unmatched
346                                                                  * inner */
347         JOIN_RIGHT,                                     /* pairs + unmatched inner tuples */
348
349         /*
350          * SQL92 considers UNION JOIN to be a kind of join, so list it here
351          * for parser convenience, even though it's not implemented like a
352          * join in the executor.  (The planner must convert it to an Append
353          * plan.)
354          */
355         JOIN_UNION
356
357         /*
358          * Eventually we will have some additional join types for efficient
359          * support of queries like WHERE foo IN (SELECT bar FROM ...).
360          */
361 } JoinType;
362
363 #define IS_OUTER_JOIN(jointype) \
364         ((jointype) == JOIN_LEFT || \
365          (jointype) == JOIN_FULL || \
366          (jointype) == JOIN_RIGHT)
367
368 #endif   /* NODES_H */