OSDN Git Service

rebuid:
[eos/hostdependX86MAC64.git] / util / X86MAC64 / include / postgresql / server / nodes / nodes.h
1 /*-------------------------------------------------------------------------
2  *
3  * nodes.h
4  *        Definitions for tagged nodes.
5  *
6  *
7  * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/nodes/nodes.h
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 numbers 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  * (Since node tag numbers never exist outside backend memory, there's no
24  * real harm in renumbering, it just costs a full rebuild ...)
25  */
26 typedef enum NodeTag
27 {
28         T_Invalid = 0,
29
30         /*
31          * TAGS FOR EXECUTOR NODES (execnodes.h)
32          */
33         T_IndexInfo = 10,
34         T_ExprContext,
35         T_ProjectionInfo,
36         T_JunkFilter,
37         T_ResultRelInfo,
38         T_EState,
39         T_TupleTableSlot,
40
41         /*
42          * TAGS FOR PLAN NODES (plannodes.h)
43          */
44         T_Plan = 100,
45         T_Result,
46         T_ModifyTable,
47         T_Append,
48         T_MergeAppend,
49         T_RecursiveUnion,
50         T_BitmapAnd,
51         T_BitmapOr,
52         T_Scan,
53         T_SeqScan,
54         T_IndexScan,
55         T_IndexOnlyScan,
56         T_BitmapIndexScan,
57         T_BitmapHeapScan,
58         T_TidScan,
59         T_SubqueryScan,
60         T_FunctionScan,
61         T_ValuesScan,
62         T_CteScan,
63         T_WorkTableScan,
64         T_ForeignScan,
65         T_Join,
66         T_NestLoop,
67         T_MergeJoin,
68         T_HashJoin,
69         T_Material,
70         T_Sort,
71         T_Group,
72         T_Agg,
73         T_WindowAgg,
74         T_Unique,
75         T_Hash,
76         T_SetOp,
77         T_LockRows,
78         T_Limit,
79         /* these aren't subclasses of Plan: */
80         T_NestLoopParam,
81         T_PlanRowMark,
82         T_PlanInvalItem,
83
84         /*
85          * TAGS FOR PLAN STATE NODES (execnodes.h)
86          *
87          * These should correspond one-to-one with Plan node types.
88          */
89         T_PlanState = 200,
90         T_ResultState,
91         T_ModifyTableState,
92         T_AppendState,
93         T_MergeAppendState,
94         T_RecursiveUnionState,
95         T_BitmapAndState,
96         T_BitmapOrState,
97         T_ScanState,
98         T_SeqScanState,
99         T_IndexScanState,
100         T_IndexOnlyScanState,
101         T_BitmapIndexScanState,
102         T_BitmapHeapScanState,
103         T_TidScanState,
104         T_SubqueryScanState,
105         T_FunctionScanState,
106         T_ValuesScanState,
107         T_CteScanState,
108         T_WorkTableScanState,
109         T_ForeignScanState,
110         T_JoinState,
111         T_NestLoopState,
112         T_MergeJoinState,
113         T_HashJoinState,
114         T_MaterialState,
115         T_SortState,
116         T_GroupState,
117         T_AggState,
118         T_WindowAggState,
119         T_UniqueState,
120         T_HashState,
121         T_SetOpState,
122         T_LockRowsState,
123         T_LimitState,
124
125         /*
126          * TAGS FOR PRIMITIVE NODES (primnodes.h)
127          */
128         T_Alias = 300,
129         T_RangeVar,
130         T_Expr,
131         T_Var,
132         T_Const,
133         T_Param,
134         T_Aggref,
135         T_WindowFunc,
136         T_ArrayRef,
137         T_FuncExpr,
138         T_NamedArgExpr,
139         T_OpExpr,
140         T_DistinctExpr,
141         T_NullIfExpr,
142         T_ScalarArrayOpExpr,
143         T_BoolExpr,
144         T_SubLink,
145         T_SubPlan,
146         T_AlternativeSubPlan,
147         T_FieldSelect,
148         T_FieldStore,
149         T_RelabelType,
150         T_CoerceViaIO,
151         T_ArrayCoerceExpr,
152         T_ConvertRowtypeExpr,
153         T_CollateExpr,
154         T_CaseExpr,
155         T_CaseWhen,
156         T_CaseTestExpr,
157         T_ArrayExpr,
158         T_RowExpr,
159         T_RowCompareExpr,
160         T_CoalesceExpr,
161         T_MinMaxExpr,
162         T_XmlExpr,
163         T_NullTest,
164         T_BooleanTest,
165         T_CoerceToDomain,
166         T_CoerceToDomainValue,
167         T_SetToDefault,
168         T_CurrentOfExpr,
169         T_TargetEntry,
170         T_RangeTblRef,
171         T_JoinExpr,
172         T_FromExpr,
173         T_IntoClause,
174
175         /*
176          * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
177          *
178          * These correspond (not always one-for-one) to primitive nodes derived
179          * from Expr.
180          */
181         T_ExprState = 400,
182         T_GenericExprState,
183         T_WholeRowVarExprState,
184         T_AggrefExprState,
185         T_WindowFuncExprState,
186         T_ArrayRefExprState,
187         T_FuncExprState,
188         T_ScalarArrayOpExprState,
189         T_BoolExprState,
190         T_SubPlanState,
191         T_AlternativeSubPlanState,
192         T_FieldSelectState,
193         T_FieldStoreState,
194         T_CoerceViaIOState,
195         T_ArrayCoerceExprState,
196         T_ConvertRowtypeExprState,
197         T_CaseExprState,
198         T_CaseWhenState,
199         T_ArrayExprState,
200         T_RowExprState,
201         T_RowCompareExprState,
202         T_CoalesceExprState,
203         T_MinMaxExprState,
204         T_XmlExprState,
205         T_NullTestState,
206         T_CoerceToDomainState,
207         T_DomainConstraintState,
208
209         /*
210          * TAGS FOR PLANNER NODES (relation.h)
211          */
212         T_PlannerInfo = 500,
213         T_PlannerGlobal,
214         T_RelOptInfo,
215         T_IndexOptInfo,
216         T_ParamPathInfo,
217         T_Path,
218         T_IndexPath,
219         T_BitmapHeapPath,
220         T_BitmapAndPath,
221         T_BitmapOrPath,
222         T_NestPath,
223         T_MergePath,
224         T_HashPath,
225         T_TidPath,
226         T_ForeignPath,
227         T_AppendPath,
228         T_MergeAppendPath,
229         T_ResultPath,
230         T_MaterialPath,
231         T_UniquePath,
232         T_EquivalenceClass,
233         T_EquivalenceMember,
234         T_PathKey,
235         T_RestrictInfo,
236         T_PlaceHolderVar,
237         T_SpecialJoinInfo,
238         T_LateralJoinInfo,
239         T_AppendRelInfo,
240         T_PlaceHolderInfo,
241         T_MinMaxAggInfo,
242         T_PlannerParamItem,
243
244         /*
245          * TAGS FOR MEMORY NODES (memnodes.h)
246          */
247         T_MemoryContext = 600,
248         T_AllocSetContext,
249
250         /*
251          * TAGS FOR VALUE NODES (value.h)
252          */
253         T_Value = 650,
254         T_Integer,
255         T_Float,
256         T_String,
257         T_BitString,
258         T_Null,
259
260         /*
261          * TAGS FOR LIST NODES (pg_list.h)
262          */
263         T_List,
264         T_IntList,
265         T_OidList,
266
267         /*
268          * TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
269          */
270         T_Query = 700,
271         T_PlannedStmt,
272         T_InsertStmt,
273         T_DeleteStmt,
274         T_UpdateStmt,
275         T_SelectStmt,
276         T_AlterTableStmt,
277         T_AlterTableCmd,
278         T_AlterDomainStmt,
279         T_SetOperationStmt,
280         T_GrantStmt,
281         T_GrantRoleStmt,
282         T_AlterDefaultPrivilegesStmt,
283         T_ClosePortalStmt,
284         T_ClusterStmt,
285         T_CopyStmt,
286         T_CreateStmt,
287         T_DefineStmt,
288         T_DropStmt,
289         T_TruncateStmt,
290         T_CommentStmt,
291         T_FetchStmt,
292         T_IndexStmt,
293         T_CreateFunctionStmt,
294         T_AlterFunctionStmt,
295         T_DoStmt,
296         T_RenameStmt,
297         T_RuleStmt,
298         T_NotifyStmt,
299         T_ListenStmt,
300         T_UnlistenStmt,
301         T_TransactionStmt,
302         T_ViewStmt,
303         T_LoadStmt,
304         T_CreateDomainStmt,
305         T_CreatedbStmt,
306         T_DropdbStmt,
307         T_VacuumStmt,
308         T_ExplainStmt,
309         T_CreateTableAsStmt,
310         T_CreateSeqStmt,
311         T_AlterSeqStmt,
312         T_VariableSetStmt,
313         T_VariableShowStmt,
314         T_DiscardStmt,
315         T_CreateTrigStmt,
316         T_CreatePLangStmt,
317         T_CreateRoleStmt,
318         T_AlterRoleStmt,
319         T_DropRoleStmt,
320         T_LockStmt,
321         T_ConstraintsSetStmt,
322         T_ReindexStmt,
323         T_CheckPointStmt,
324         T_CreateSchemaStmt,
325         T_AlterDatabaseStmt,
326         T_AlterDatabaseSetStmt,
327         T_AlterRoleSetStmt,
328         T_CreateConversionStmt,
329         T_CreateCastStmt,
330         T_CreateOpClassStmt,
331         T_CreateOpFamilyStmt,
332         T_AlterOpFamilyStmt,
333         T_PrepareStmt,
334         T_ExecuteStmt,
335         T_DeallocateStmt,
336         T_DeclareCursorStmt,
337         T_CreateTableSpaceStmt,
338         T_DropTableSpaceStmt,
339         T_AlterObjectSchemaStmt,
340         T_AlterOwnerStmt,
341         T_DropOwnedStmt,
342         T_ReassignOwnedStmt,
343         T_CompositeTypeStmt,
344         T_CreateEnumStmt,
345         T_CreateRangeStmt,
346         T_AlterEnumStmt,
347         T_AlterTSDictionaryStmt,
348         T_AlterTSConfigurationStmt,
349         T_CreateFdwStmt,
350         T_AlterFdwStmt,
351         T_CreateForeignServerStmt,
352         T_AlterForeignServerStmt,
353         T_CreateUserMappingStmt,
354         T_AlterUserMappingStmt,
355         T_DropUserMappingStmt,
356         T_AlterTableSpaceOptionsStmt,
357         T_AlterTableMoveAllStmt,
358         T_SecLabelStmt,
359         T_CreateForeignTableStmt,
360         T_CreateExtensionStmt,
361         T_AlterExtensionStmt,
362         T_AlterExtensionContentsStmt,
363         T_CreateEventTrigStmt,
364         T_AlterEventTrigStmt,
365         T_RefreshMatViewStmt,
366         T_ReplicaIdentityStmt,
367         T_AlterSystemStmt,
368
369         /*
370          * TAGS FOR PARSE TREE NODES (parsenodes.h)
371          */
372         T_A_Expr = 900,
373         T_ColumnRef,
374         T_ParamRef,
375         T_A_Const,
376         T_FuncCall,
377         T_A_Star,
378         T_A_Indices,
379         T_A_Indirection,
380         T_A_ArrayExpr,
381         T_ResTarget,
382         T_TypeCast,
383         T_CollateClause,
384         T_SortBy,
385         T_WindowDef,
386         T_RangeSubselect,
387         T_RangeFunction,
388         T_TypeName,
389         T_ColumnDef,
390         T_IndexElem,
391         T_Constraint,
392         T_DefElem,
393         T_RangeTblEntry,
394         T_RangeTblFunction,
395         T_WithCheckOption,
396         T_SortGroupClause,
397         T_WindowClause,
398         T_PrivGrantee,
399         T_FuncWithArgs,
400         T_AccessPriv,
401         T_CreateOpClassItem,
402         T_TableLikeClause,
403         T_FunctionParameter,
404         T_LockingClause,
405         T_RowMarkClause,
406         T_XmlSerialize,
407         T_WithClause,
408         T_CommonTableExpr,
409
410         /*
411          * TAGS FOR REPLICATION GRAMMAR PARSE NODES (replnodes.h)
412          */
413         T_IdentifySystemCmd,
414         T_BaseBackupCmd,
415         T_CreateReplicationSlotCmd,
416         T_DropReplicationSlotCmd,
417         T_StartReplicationCmd,
418         T_TimeLineHistoryCmd,
419
420         /*
421          * TAGS FOR RANDOM OTHER STUFF
422          *
423          * These are objects that aren't part of parse/plan/execute node tree
424          * structures, but we give them NodeTags anyway for identification
425          * purposes (usually because they are involved in APIs where we want to
426          * pass multiple object types through the same pointer).
427          */
428         T_TriggerData = 950,            /* in commands/trigger.h */
429         T_EventTriggerData,                     /* in commands/event_trigger.h */
430         T_ReturnSetInfo,                        /* in nodes/execnodes.h */
431         T_WindowObjectData,                     /* private in nodeWindowAgg.c */
432         T_TIDBitmap,                            /* in nodes/tidbitmap.h */
433         T_InlineCodeBlock,                      /* in nodes/parsenodes.h */
434         T_FdwRoutine                            /* in foreign/fdwapi.h */
435 } NodeTag;
436
437 /*
438  * The first field of a node of any type is guaranteed to be the NodeTag.
439  * Hence the type of any node can be gotten by casting it to Node. Declaring
440  * a variable to be of Node * (instead of void *) can also facilitate
441  * debugging.
442  */
443 typedef struct Node
444 {
445         NodeTag         type;
446 } Node;
447
448 #define nodeTag(nodeptr)                (((const Node*)(nodeptr))->type)
449
450 /*
451  * newNode -
452  *        create a new node of the specified size and tag the node with the
453  *        specified tag.
454  *
455  * !WARNING!: Avoid using newNode directly. You should be using the
456  *        macro makeNode.  eg. to create a Query node, use makeNode(Query)
457  *
458  * Note: the size argument should always be a compile-time constant, so the
459  * apparent risk of multiple evaluation doesn't matter in practice.
460  */
461 #ifdef __GNUC__
462
463 /* With GCC, we can use a compound statement within an expression */
464 #define newNode(size, tag) \
465 ({      Node   *_result; \
466         AssertMacro((size) >= sizeof(Node));            /* need the tag, at least */ \
467         _result = (Node *) palloc0fast(size); \
468         _result->type = (tag); \
469         _result; \
470 })
471 #else
472
473 /*
474  *      There is no way to dereference the palloc'ed pointer to assign the
475  *      tag, and also return the pointer itself, so we need a holder variable.
476  *      Fortunately, this macro isn't recursive so we just define
477  *      a global variable for this purpose.
478  */
479 extern PGDLLIMPORT Node *newNodeMacroHolder;
480
481 #define newNode(size, tag) \
482 ( \
483         AssertMacro((size) >= sizeof(Node)),            /* need the tag, at least */ \
484         newNodeMacroHolder = (Node *) palloc0fast(size), \
485         newNodeMacroHolder->type = (tag), \
486         newNodeMacroHolder \
487 )
488 #endif   /* __GNUC__ */
489
490
491 #define makeNode(_type_)                ((_type_ *) newNode(sizeof(_type_),T_##_type_))
492 #define NodeSetTag(nodeptr,t)   (((Node*)(nodeptr))->type = (t))
493
494 #define IsA(nodeptr,_type_)             (nodeTag(nodeptr) == T_##_type_)
495
496 /* ----------------------------------------------------------------
497  *                                        extern declarations follow
498  * ----------------------------------------------------------------
499  */
500
501 /*
502  * nodes/{outfuncs.c,print.c}
503  */
504 extern char *nodeToString(const void *obj);
505
506 /*
507  * nodes/{readfuncs.c,read.c}
508  */
509 extern void *stringToNode(char *str);
510
511 /*
512  * nodes/copyfuncs.c
513  */
514 extern void *copyObject(const void *obj);
515
516 /*
517  * nodes/equalfuncs.c
518  */
519 extern bool equal(const void *a, const void *b);
520
521
522 /*
523  * Typedefs for identifying qualifier selectivities and plan costs as such.
524  * These are just plain "double"s, but declaring a variable as Selectivity
525  * or Cost makes the intent more obvious.
526  *
527  * These could have gone into plannodes.h or some such, but many files
528  * depend on them...
529  */
530 typedef double Selectivity;             /* fraction of tuples a qualifier will pass */
531 typedef double Cost;                    /* execution cost (in page-access units) */
532
533
534 /*
535  * CmdType -
536  *        enums for type of operation represented by a Query or PlannedStmt
537  *
538  * This is needed in both parsenodes.h and plannodes.h, so put it here...
539  */
540 typedef enum CmdType
541 {
542         CMD_UNKNOWN,
543         CMD_SELECT,                                     /* select stmt */
544         CMD_UPDATE,                                     /* update stmt */
545         CMD_INSERT,                                     /* insert stmt */
546         CMD_DELETE,
547         CMD_UTILITY,                            /* cmds like create, destroy, copy, vacuum,
548                                                                  * etc. */
549         CMD_NOTHING                                     /* dummy command for instead nothing rules
550                                                                  * with qual */
551 } CmdType;
552
553
554 /*
555  * JoinType -
556  *        enums for types of relation joins
557  *
558  * JoinType determines the exact semantics of joining two relations using
559  * a matching qualification.  For example, it tells what to do with a tuple
560  * that has no match in the other relation.
561  *
562  * This is needed in both parsenodes.h and plannodes.h, so put it here...
563  */
564 typedef enum JoinType
565 {
566         /*
567          * The canonical kinds of joins according to the SQL JOIN syntax. Only
568          * these codes can appear in parser output (e.g., JoinExpr nodes).
569          */
570         JOIN_INNER,                                     /* matching tuple pairs only */
571         JOIN_LEFT,                                      /* pairs + unmatched LHS tuples */
572         JOIN_FULL,                                      /* pairs + unmatched LHS + unmatched RHS */
573         JOIN_RIGHT,                                     /* pairs + unmatched RHS tuples */
574
575         /*
576          * Semijoins and anti-semijoins (as defined in relational theory) do not
577          * appear in the SQL JOIN syntax, but there are standard idioms for
578          * representing them (e.g., using EXISTS).  The planner recognizes these
579          * cases and converts them to joins.  So the planner and executor must
580          * support these codes.  NOTE: in JOIN_SEMI output, it is unspecified
581          * which matching RHS row is joined to.  In JOIN_ANTI output, the row is
582          * guaranteed to be null-extended.
583          */
584         JOIN_SEMI,                                      /* 1 copy of each LHS row that has match(es) */
585         JOIN_ANTI,                                      /* 1 copy of each LHS row that has no match */
586
587         /*
588          * These codes are used internally in the planner, but are not supported
589          * by the executor (nor, indeed, by most of the planner).
590          */
591         JOIN_UNIQUE_OUTER,                      /* LHS path must be made unique */
592         JOIN_UNIQUE_INNER                       /* RHS path must be made unique */
593
594         /*
595          * We might need additional join types someday.
596          */
597 } JoinType;
598
599 /*
600  * OUTER joins are those for which pushed-down quals must behave differently
601  * from the join's own quals.  This is in fact everything except INNER and
602  * SEMI joins.  However, this macro must also exclude the JOIN_UNIQUE symbols
603  * since those are temporary proxies for what will eventually be an INNER
604  * join.
605  *
606  * Note: semijoins are a hybrid case, but we choose to treat them as not
607  * being outer joins.  This is okay principally because the SQL syntax makes
608  * it impossible to have a pushed-down qual that refers to the inner relation
609  * of a semijoin; so there is no strong need to distinguish join quals from
610  * pushed-down quals.  This is convenient because for almost all purposes,
611  * quals attached to a semijoin can be treated the same as innerjoin quals.
612  */
613 #define IS_OUTER_JOIN(jointype) \
614         (((1 << (jointype)) & \
615           ((1 << JOIN_LEFT) | \
616            (1 << JOIN_FULL) | \
617            (1 << JOIN_RIGHT) | \
618            (1 << JOIN_ANTI))) != 0)
619
620 #endif   /* NODES_H */