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