1 /*-------------------------------------------------------------------------
4 * Definitions for tagged nodes.
7 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
12 *-------------------------------------------------------------------------
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 ...)
31 * TAGS FOR EXECUTOR NODES (execnodes.h)
42 * TAGS FOR PLAN NODES (plannodes.h)
70 /* this one isn't a subclass of Plan: */
74 * TAGS FOR PLAN STATE NODES (execnodes.h)
76 * These should correspond one-to-one with Plan node types.
86 T_BitmapIndexScanState
,
87 T_BitmapHeapScanState
,
106 * TAGS FOR PRIMITIVE NODES (primnodes.h)
123 T_AlternativeSubPlan
,
129 T_ConvertRowtypeExpr
,
143 T_CoerceToDomainValue
,
153 * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
155 * These correspond (not always one-for-one) to primitive nodes derived
163 T_ScalarArrayOpExprState
,
166 T_AlternativeSubPlanState
,
170 T_ArrayCoerceExprState
,
171 T_ConvertRowtypeExprState
,
176 T_RowCompareExprState
,
181 T_CoerceToDomainState
,
182 T_DomainConstraintState
,
185 * TAGS FOR PLANNER NODES (relation.h)
208 T_InnerIndexscanInfo
,
215 * TAGS FOR MEMORY NODES (memnodes.h)
217 T_MemoryContext
= 600,
221 * TAGS FOR VALUE NODES (value.h)
231 * TAGS FOR LIST NODES (pg_list.h)
238 * TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
262 T_CreateFunctionStmt
,
291 T_ConstraintsSetStmt
,
296 T_AlterDatabaseSetStmt
,
298 T_CreateConversionStmt
,
302 T_CreateOpFamilyStmt
,
305 T_RemoveOpFamilyStmt
,
310 T_CreateTableSpaceStmt
,
311 T_DropTableSpaceStmt
,
312 T_AlterObjectSchemaStmt
,
318 T_AlterTSDictionaryStmt
,
319 T_AlterTSConfigurationStmt
,
322 * TAGS FOR PARSE TREE NODES (parsenodes.h)
357 * TAGS FOR RANDOM OTHER STUFF
359 * These are objects that aren't part of parse/plan/execute node tree
360 * structures, but we give them NodeTags anyway for identification
361 * purposes (usually because they are involved in APIs where we want to
362 * pass multiple object types through the same pointer).
364 T_TriggerData
= 950, /* in commands/trigger.h */
365 T_ReturnSetInfo
, /* in nodes/execnodes.h */
366 T_TIDBitmap
/* in nodes/tidbitmap.h */
370 * The first field of a node of any type is guaranteed to be the NodeTag.
371 * Hence the type of any node can be gotten by casting it to Node. Declaring
372 * a variable to be of Node * (instead of void *) can also facilitate
380 #define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
384 * create a new node of the specified size and tag the node with the
387 * !WARNING!: Avoid using newNode directly. You should be using the
388 * macro makeNode. eg. to create a Query node, use makeNode(Query)
390 * Note: the size argument should always be a compile-time constant, so the
391 * apparent risk of multiple evaluation doesn't matter in practice.
395 /* With GCC, we can use a compound statement within an expression */
396 #define newNode(size, tag) \
398 AssertMacro((size) >= sizeof(Node)); /* need the tag, at least */ \
399 _result = (Node *) palloc0fast(size); \
400 _result->type = (tag); \
407 * There is no way to dereference the palloc'ed pointer to assign the
408 * tag, and also return the pointer itself, so we need a holder variable.
409 * Fortunately, this macro isn't recursive so we just define
410 * a global variable for this purpose.
412 extern PGDLLIMPORT Node
*newNodeMacroHolder
;
414 #define newNode(size, tag) \
416 AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
417 newNodeMacroHolder = (Node *) palloc0fast(size), \
418 newNodeMacroHolder->type = (tag), \
422 #endif /* __GNUC__ */
425 #define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
426 #define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
428 #define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_)
430 /* ----------------------------------------------------------------
431 * extern declarations follow
432 * ----------------------------------------------------------------
436 * nodes/{outfuncs.c,print.c}
438 extern char *nodeToString(void *obj
);
441 * nodes/{readfuncs.c,read.c}
443 extern void *stringToNode(char *str
);
448 extern void *copyObject(void *obj
);
453 extern bool equal(void *a
, void *b
);
457 * Typedefs for identifying qualifier selectivities and plan costs as such.
458 * These are just plain "double"s, but declaring a variable as Selectivity
459 * or Cost makes the intent more obvious.
461 * These could have gone into plannodes.h or some such, but many files
464 typedef double Selectivity
; /* fraction of tuples a qualifier will pass */
465 typedef double Cost
; /* execution cost (in page-access units) */
470 * enums for type of operation represented by a Query or PlannedStmt
472 * This is needed in both parsenodes.h and plannodes.h, so put it here...
477 CMD_SELECT
, /* select stmt */
478 CMD_UPDATE
, /* update stmt */
479 CMD_INSERT
, /* insert stmt */
481 CMD_UTILITY
, /* cmds like create, destroy, copy, vacuum,
483 CMD_NOTHING
/* dummy command for instead nothing rules
490 * enums for types of relation joins
492 * JoinType determines the exact semantics of joining two relations using
493 * a matching qualification. For example, it tells what to do with a tuple
494 * that has no match in the other relation.
496 * This is needed in both parsenodes.h and plannodes.h, so put it here...
498 typedef enum JoinType
501 * The canonical kinds of joins according to the SQL JOIN syntax.
502 * Only these codes can appear in parser output (e.g., JoinExpr nodes).
504 JOIN_INNER
, /* matching tuple pairs only */
505 JOIN_LEFT
, /* pairs + unmatched LHS tuples */
506 JOIN_FULL
, /* pairs + unmatched LHS + unmatched RHS */
507 JOIN_RIGHT
, /* pairs + unmatched RHS tuples */
510 * Semijoins and anti-semijoins (as defined in relational theory) do
511 * not appear in the SQL JOIN syntax, but there are standard idioms for
512 * representing them (e.g., using EXISTS). The planner recognizes these
513 * cases and converts them to joins. So the planner and executor must
514 * support these codes. NOTE: in JOIN_SEMI output, it is unspecified
515 * which matching RHS row is joined to. In JOIN_ANTI output, the row
516 * is guaranteed to be null-extended.
518 JOIN_SEMI
, /* 1 copy of each LHS row that has match(es) */
519 JOIN_ANTI
, /* 1 copy of each LHS row that has no match */
522 * These codes are used internally in the planner, but are not supported
523 * by the executor (nor, indeed, by most of the planner).
525 JOIN_UNIQUE_OUTER
, /* LHS path must be made unique */
526 JOIN_UNIQUE_INNER
/* RHS path must be made unique */
529 * We might need additional join types someday.
534 * OUTER joins are those for which pushed-down quals must behave differently
535 * from the join's own quals. This is in fact everything except INNER joins.
536 * However, this macro must also exclude the JOIN_UNIQUE symbols since those
537 * are temporary proxies for what will eventually be an INNER join.
539 * Note: in some places it is preferable to treat JOIN_SEMI as not being
540 * an outer join, since it doesn't produce null-extended rows. Be aware
541 * of that distinction when deciding whether to use this macro.
543 #define IS_OUTER_JOIN(jointype) \
544 ((jointype) > JOIN_INNER && (jointype) < JOIN_UNIQUE_OUTER)