]> git.8kb.co.uk Git - pgpool-ii/pgpool-ii_2.2.5/blob - parser/nodes.h
Attempt to send a proper failure message to frontend when authentication
[pgpool-ii/pgpool-ii_2.2.5] / parser / nodes.h
1 /*-------------------------------------------------------------------------
2  *
3  * nodes.h
4  *        Definitions for tagged nodes.
5  *
6  *
7  * Portions Copyright (c) 2003-2008, PgPool Global Development Group
8  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.204 2007/09/03 18:46:30 tgl Exp $
12  *
13  *-------------------------------------------------------------------------
14  */
15 #ifndef NODES_H
16 #define NODES_H
17
18 /*
19  * The first field of every node is NodeTag. Each node created (with makeNode)
20  * will have one of the following tags as the value of its first field.
21  *
22  * Note that the numbers of the node tags are not contiguous. We left holes
23  * here so that we can add more tags without changing the existing enum's.
24  * (Since node tag numbers never exist outside backend memory, there's no
25  * real harm in renumbering, it just costs a full rebuild ...)
26  */
27 typedef enum NodeTag
28 {
29         T_Invalid = 0,
30
31         /*
32          * TAGS FOR EXECUTOR NODES (execnodes.h)
33          */
34         T_IndexInfo = 10,
35         T_ExprContext,
36         T_ProjectionInfo,
37         T_JunkFilter,
38         T_ResultRelInfo,
39         T_EState,
40         T_TupleTableSlot,
41
42         /*
43          * TAGS FOR PLAN NODES (plannodes.h)
44          */
45         T_Plan = 100,
46         T_Result,
47         T_Append,
48         T_BitmapAnd,
49         T_BitmapOr,
50         T_Scan,
51         T_SeqScan,
52         T_IndexScan,
53         T_BitmapIndexScan,
54         T_BitmapHeapScan,
55         T_TidScan,
56         T_SubqueryScan,
57         T_FunctionScan,
58         T_ValuesScan,
59         T_Join,
60         T_NestLoop,
61         T_MergeJoin,
62         T_HashJoin,
63         T_Material,
64         T_Sort,
65         T_Group,
66         T_Agg,
67         T_Unique,
68         T_Hash,
69         T_SetOp,
70         T_Limit,
71
72         /*
73          * TAGS FOR PLAN STATE NODES (execnodes.h)
74          *
75          * These should correspond one-to-one with Plan node types.
76          */
77         T_PlanState = 200,
78         T_ResultState,
79         T_AppendState,
80         T_BitmapAndState,
81         T_BitmapOrState,
82         T_ScanState,
83         T_SeqScanState,
84         T_IndexScanState,
85         T_BitmapIndexScanState,
86         T_BitmapHeapScanState,
87         T_TidScanState,
88         T_SubqueryScanState,
89         T_FunctionScanState,
90         T_ValuesScanState,
91         T_JoinState,
92         T_NestLoopState,
93         T_MergeJoinState,
94         T_HashJoinState,
95         T_MaterialState,
96         T_SortState,
97         T_GroupState,
98         T_AggState,
99         T_UniqueState,
100         T_HashState,
101         T_SetOpState,
102         T_LimitState,
103
104         /*
105          * TAGS FOR PRIMITIVE NODES (primnodes.h)
106          */
107         T_Alias = 300,
108         T_RangeVar,
109         T_Expr,
110         T_Var,
111         T_Const,
112         T_Param,
113         T_Aggref,
114         T_ArrayRef,
115         T_FuncExpr,
116         T_OpExpr,
117         T_DistinctExpr,
118         T_ScalarArrayOpExpr,
119         T_BoolExpr,
120         T_SubLink,
121         T_SubPlan,
122         T_FieldSelect,
123         T_FieldStore,
124         T_RelabelType,
125         T_CoerceViaIO,
126         T_ArrayCoerceExpr,
127         T_ConvertRowtypeExpr,
128         T_CaseExpr,
129         T_CaseWhen,
130         T_CaseTestExpr,
131         T_ArrayExpr,
132         T_RowExpr,
133         T_RowCompareExpr,
134         T_CoalesceExpr,
135         T_MinMaxExpr,
136         T_XmlExpr,
137         T_NullIfExpr,
138         T_NullTest,
139         T_BooleanTest,
140         T_CoerceToDomain,
141         T_CoerceToDomainValue,
142         T_SetToDefault,
143         T_CurrentOfExpr,
144         T_TargetEntry,
145         T_RangeTblRef,
146         T_JoinExpr,
147         T_FromExpr,
148         T_IntoClause,
149
150         /*
151          * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
152          *
153          * These correspond (not always one-for-one) to primitive nodes derived
154          * from Expr.
155          */
156         T_ExprState = 400,
157         T_GenericExprState,
158         T_AggrefExprState,
159         T_ArrayRefExprState,
160         T_FuncExprState,
161         T_ScalarArrayOpExprState,
162         T_BoolExprState,
163         T_SubPlanState,
164         T_FieldSelectState,
165         T_FieldStoreState,
166         T_CoerceViaIOState,
167         T_ArrayCoerceExprState,
168         T_ConvertRowtypeExprState,
169         T_CaseExprState,
170         T_CaseWhenState,
171         T_ArrayExprState,
172         T_RowExprState,
173         T_RowCompareExprState,
174         T_CoalesceExprState,
175         T_MinMaxExprState,
176         T_XmlExprState,
177         T_NullTestState,
178         T_CoerceToDomainState,
179         T_DomainConstraintState,
180
181         /*
182          * TAGS FOR PLANNER NODES (relation.h)
183          */
184         T_PlannerInfo = 500,
185         T_PlannerGlobal,
186         T_RelOptInfo,
187         T_IndexOptInfo,
188         T_Path,
189         T_IndexPath,
190         T_BitmapHeapPath,
191         T_BitmapAndPath,
192         T_BitmapOrPath,
193         T_NestPath,
194         T_MergePath,
195         T_HashPath,
196         T_TidPath,
197         T_AppendPath,
198         T_ResultPath,
199         T_MaterialPath,
200         T_UniquePath,
201         T_EquivalenceClass,
202         T_EquivalenceMember,
203         T_PathKey,
204         T_RestrictInfo,
205         T_InnerIndexscanInfo,
206         T_OuterJoinInfo,
207         T_InClauseInfo,
208         T_AppendRelInfo,
209         T_PlannerParamItem,
210
211         /*
212          * TAGS FOR MEMORY NODES (memnodes.h)
213          */
214         T_MemoryContext = 600,
215         T_AllocSetContext,
216
217         /*
218          * TAGS FOR VALUE NODES (value.h)
219          */
220         T_Value = 650,
221         T_Integer,
222         T_Float,
223         T_String,
224         T_BitString,
225         T_Null,
226
227         /*
228          * TAGS FOR LIST NODES (pg_list.h)
229          */
230         T_List,
231         T_IntList,
232         T_OidList,
233
234         /*
235          * TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
236          */
237         T_Query = 700,
238         T_PlannedStmt,
239         T_InsertStmt,
240         T_DeleteStmt,
241         T_UpdateStmt,
242         T_SelectStmt,
243         T_AlterTableStmt,
244         T_AlterTableCmd,
245         T_AlterDomainStmt,
246         T_SetOperationStmt,
247         T_GrantStmt,
248         T_GrantRoleStmt,
249         T_ClosePortalStmt,
250         T_ClusterStmt,
251         T_CopyStmt,
252         T_CreateStmt,
253         T_DefineStmt,
254         T_DropStmt,
255         T_TruncateStmt,
256         T_CommentStmt,
257         T_FetchStmt,
258         T_IndexStmt,
259         T_CreateFunctionStmt,
260         T_AlterFunctionStmt,
261         T_RemoveFuncStmt,
262         T_RenameStmt,
263         T_RuleStmt,
264         T_NotifyStmt,
265         T_ListenStmt,
266         T_UnlistenStmt,
267         T_TransactionStmt,
268         T_ViewStmt,
269         T_LoadStmt,
270         T_CreateDomainStmt,
271         T_CreatedbStmt,
272         T_DropdbStmt,
273         T_VacuumStmt,
274         T_ExplainStmt,
275         T_CreateSeqStmt,
276         T_AlterSeqStmt,
277         T_VariableSetStmt,
278         T_VariableShowStmt,
279         T_DiscardStmt,
280         T_CreateTrigStmt,
281         T_DropPropertyStmt,
282         T_CreatePLangStmt,
283         T_DropPLangStmt,
284         T_CreateRoleStmt,
285         T_AlterRoleStmt,
286         T_DropRoleStmt,
287         T_LockStmt,
288         T_ConstraintsSetStmt,
289         T_ReindexStmt,
290         T_CheckPointStmt,
291         T_CreateSchemaStmt,
292         T_AlterDatabaseStmt,
293         T_AlterDatabaseSetStmt,
294         T_AlterRoleSetStmt,
295         T_CreateConversionStmt,
296         T_CreateCastStmt,
297         T_DropCastStmt,
298         T_CreateOpClassStmt,
299         T_CreateOpFamilyStmt,
300         T_AlterOpFamilyStmt,
301         T_RemoveOpClassStmt,
302         T_RemoveOpFamilyStmt,
303         T_PrepareStmt,
304         T_ExecuteStmt,
305         T_DeallocateStmt,
306         T_DeclareCursorStmt,
307         T_CreateTableSpaceStmt,
308         T_DropTableSpaceStmt,
309         T_AlterObjectSchemaStmt,
310         T_AlterOwnerStmt,
311         T_DropOwnedStmt,
312         T_ReassignOwnedStmt,
313         T_CompositeTypeStmt,
314         T_CreateEnumStmt,
315         T_AlterTSDictionaryStmt,
316         T_AlterTSConfigurationStmt,
317
318         /*
319          * TAGS FOR PARSE TREE NODES (parsenodes.h)
320          */
321         T_A_Expr = 900,
322         T_ColumnRef,
323         T_ParamRef,
324         T_A_Const,
325         T_FuncCall,
326         T_A_Indices,
327         T_A_Indirection,
328         T_ResTarget,
329         T_TypeCast,
330         T_SortBy,
331         T_RangeSubselect,
332         T_RangeFunction,
333         T_TypeName,
334         T_ColumnDef,
335         T_IndexElem,
336         T_Constraint,
337         T_DefElem,
338         T_RangeTblEntry,
339         T_SortClause,
340         T_GroupClause,
341         T_FkConstraint,
342         T_PrivGrantee,
343         T_FuncWithArgs,
344         T_PrivTarget,
345         T_CreateOpClassItem,
346         T_InhRelation,
347         T_FunctionParameter,
348         T_LockingClause,
349         T_RowMarkClause,
350         T_XmlSerialize,
351
352         /*
353          * TAGS FOR RANDOM OTHER STUFF
354          *
355          * These are objects that aren't part of parse/plan/execute node tree
356          * structures, but we give them NodeTags anyway for identification
357          * purposes (usually because they are involved in APIs where we want to
358          * pass multiple object types through the same pointer).
359          */
360         T_TriggerData = 950,            /* in commands/trigger.h */
361         T_ReturnSetInfo,                        /* in nodes/execnodes.h */
362         T_TIDBitmap                                     /* in nodes/tidbitmap.h */
363 } NodeTag;
364
365 /*
366  * The first field of a node of any type is guaranteed to be the NodeTag.
367  * Hence the type of any node can be gotten by casting it to Node. Declaring
368  * a variable to be of Node * (instead of void *) can also facilitate
369  * debugging.
370  */
371 typedef struct Node
372 {
373         NodeTag         type;
374 } Node;
375
376 #define nodeTag(nodeptr)                (((Node*)(nodeptr))->type)
377
378 /*
379  * newNode -
380  *        create a new node of the specified size and tag the node with the
381  *        specified tag.
382  *
383  * !WARNING!: Avoid using newNode directly. You should be using the
384  *        macro makeNode.  eg. to create a Query node, use makeNode(Query)
385  *
386  *      There is no way to dereference the palloc'ed pointer to assign the
387  *      tag, and also return the pointer itself, so we need a holder variable.
388  *      Fortunately, this macro isn't recursive so we just define
389  *      a global variable for this purpose.
390  */
391 extern Node *newNodeMacroHolder;
392
393 #define newNode(size, tag) \
394 ( \
395         newNodeMacroHolder = (Node *) palloc0(size), \
396         newNodeMacroHolder->type = (tag), \
397         newNodeMacroHolder \
398 )
399
400
401 #define makeNode(_type_)                ((_type_ *) newNode(sizeof(_type_),T_##_type_))
402 #define NodeSetTag(nodeptr,t)   (((Node*)(nodeptr))->type = (t))
403
404 #define IsA(nodeptr,_type_)             (nodeTag(nodeptr) == T_##_type_)
405
406 /* ----------------------------------------------------------------
407  *                                        extern declarations follow
408  * ----------------------------------------------------------------
409  */
410
411 /*
412  * nodes/{outfuncs.c,print.c}
413  */
414 extern char *nodeToString(void *obj);
415
416 /*
417  * nodes/{readfuncs.c,read.c}
418  */
419 extern void *stringToNode(char *str);
420
421 /*
422  * nodes/copyfuncs.c
423  */
424 extern void *copyObject(void *obj);
425
426 /*
427  * nodes/equalfuncs.c
428  */
429 extern int equal(void *a, void *b);
430
431
432 /*
433  * Typedefs for identifying qualifier selectivities and plan costs as such.
434  * These are just plain "double"s, but declaring a variable as Selectivity
435  * or Cost makes the intent more obvious.
436  *
437  * These could have gone into plannodes.h or some such, but many files
438  * depend on them...
439  */
440 typedef double Selectivity;             /* fraction of tuples a qualifier will pass */
441 typedef double Cost;                    /* execution cost (in page-access units) */
442
443
444 /*
445  * CmdType -
446  *        enums for type of operation represented by a Query or PlannedStmt
447  *
448  * This is needed in both parsenodes.h and plannodes.h, so put it here...
449  */
450 typedef enum CmdType
451 {
452         CMD_UNKNOWN,
453         CMD_SELECT,                                     /* select stmt */
454         CMD_UPDATE,                                     /* update stmt */
455         CMD_INSERT,                                     /* insert stmt */
456         CMD_DELETE,
457         CMD_UTILITY,                            /* cmds like create, destroy, copy, vacuum,
458                                                                  * etc. */
459         CMD_NOTHING                                     /* dummy command for instead nothing rules
460                                                                  * with qual */
461 } CmdType;
462
463
464 /*
465  * JoinType -
466  *        enums for types of relation joins
467  *
468  * JoinType determines the exact semantics of joining two relations using
469  * a matching qualification.  For example, it tells what to do with a tuple
470  * that has no match in the other relation.
471  *
472  * This is needed in both parsenodes.h and plannodes.h, so put it here...
473  */
474 typedef enum JoinType
475 {
476         /*
477          * The canonical kinds of joins
478          */
479         JOIN_INNER,                                     /* matching tuple pairs only */
480         JOIN_LEFT,                                      /* pairs + unmatched outer tuples */
481         JOIN_FULL,                                      /* pairs + unmatched outer + unmatched inner */
482         JOIN_RIGHT,                                     /* pairs + unmatched inner tuples */
483
484         /*
485          * These are used for queries like WHERE foo IN (SELECT bar FROM ...).
486          * Only JOIN_IN is actually implemented in the executor; the others are
487          * defined for internal use in the planner.
488          */
489         JOIN_IN,                                        /* at most one result per outer row */
490         JOIN_REVERSE_IN,                        /* at most one result per inner row */
491         JOIN_UNIQUE_OUTER,                      /* outer path must be made unique */
492         JOIN_UNIQUE_INNER                       /* inner path must be made unique */
493
494         /*
495          * We might need additional join types someday.
496          */
497 } JoinType;
498
499 #define IS_OUTER_JOIN(jointype) \
500         ((jointype) == JOIN_LEFT || \
501          (jointype) == JOIN_FULL || \
502          (jointype) == JOIN_RIGHT)
503
504 #endif   /* NODES_H */