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
10 * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.214 2008/10/21 20:42:53 tgl Exp $
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)
73 /* this one isn't a subclass of Plan: */
77 * TAGS FOR PLAN STATE NODES (execnodes.h)
79 * These should correspond one-to-one with Plan node types.
84 T_RecursiveUnionState,
90 T_BitmapIndexScanState,
91 T_BitmapHeapScanState,
112 * TAGS FOR PRIMITIVE NODES (primnodes.h)
129 T_AlternativeSubPlan,
135 T_ConvertRowtypeExpr,
149 T_CoerceToDomainValue,
159 * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
161 * These correspond (not always one-for-one) to primitive nodes derived
169 T_ScalarArrayOpExprState,
172 T_AlternativeSubPlanState,
176 T_ArrayCoerceExprState,
177 T_ConvertRowtypeExprState,
182 T_RowCompareExprState,
187 T_CoerceToDomainState,
188 T_DomainConstraintState,
191 * TAGS FOR PLANNER NODES (relation.h)
214 T_InnerIndexscanInfo,
223 * TAGS FOR MEMORY NODES (memnodes.h)
225 T_MemoryContext = 600,
229 * TAGS FOR VALUE NODES (value.h)
239 * TAGS FOR LIST NODES (pg_list.h)
246 * TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
270 T_CreateFunctionStmt,
299 T_ConstraintsSetStmt,
304 T_AlterDatabaseSetStmt,
306 T_CreateConversionStmt,
310 T_CreateOpFamilyStmt,
313 T_RemoveOpFamilyStmt,
318 T_CreateTableSpaceStmt,
319 T_DropTableSpaceStmt,
320 T_AlterObjectSchemaStmt,
326 T_AlterTSDictionaryStmt,
327 T_AlterTSConfigurationStmt,
330 * TAGS FOR PARSE TREE NODES (parsenodes.h)
367 * TAGS FOR RANDOM OTHER STUFF
369 * These are objects that aren't part of parse/plan/execute node tree
370 * structures, but we give them NodeTags anyway for identification
371 * purposes (usually because they are involved in APIs where we want to
372 * pass multiple object types through the same pointer).
374 T_TriggerData = 950, /* in commands/trigger.h */
375 T_ReturnSetInfo, /* in nodes/execnodes.h */
376 T_TIDBitmap /* in nodes/tidbitmap.h */
380 * The first field of a node of any type is guaranteed to be the NodeTag.
381 * Hence the type of any node can be gotten by casting it to Node. Declaring
382 * a variable to be of Node * (instead of void *) can also facilitate
390 #define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
394 * create a new node of the specified size and tag the node with the
397 * !WARNING!: Avoid using newNode directly. You should be using the
398 * macro makeNode. eg. to create a Query node, use makeNode(Query)
400 * Note: the size argument should always be a compile-time constant, so the
401 * apparent risk of multiple evaluation doesn't matter in practice.
405 /* With GCC, we can use a compound statement within an expression */
406 #define newNode(size, tag) \
408 AssertMacro((size) >= sizeof(Node)); /* need the tag, at least */ \
409 _result = (Node *) palloc0fast(size); \
410 _result->type = (tag); \
417 * There is no way to dereference the palloc'ed pointer to assign the
418 * tag, and also return the pointer itself, so we need a holder variable.
419 * Fortunately, this macro isn't recursive so we just define
420 * a global variable for this purpose.
422 extern PGDLLIMPORT Node *newNodeMacroHolder;
424 #define newNode(size, tag) \
426 AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
427 newNodeMacroHolder = (Node *) palloc0fast(size), \
428 newNodeMacroHolder->type = (tag), \
432 #endif /* __GNUC__ */
435 #define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
436 #define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
438 #define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_)
440 /* ----------------------------------------------------------------
441 * extern declarations follow
442 * ----------------------------------------------------------------
446 * nodes/{outfuncs.c,print.c}
448 extern char *nodeToString(void *obj);
451 * nodes/{readfuncs.c,read.c}
453 extern void *stringToNode(char *str);
458 extern void *copyObject(void *obj);
463 extern bool equal(void *a, void *b);
467 * Typedefs for identifying qualifier selectivities and plan costs as such.
468 * These are just plain "double"s, but declaring a variable as Selectivity
469 * or Cost makes the intent more obvious.
471 * These could have gone into plannodes.h or some such, but many files
474 typedef double Selectivity; /* fraction of tuples a qualifier will pass */
475 typedef double Cost; /* execution cost (in page-access units) */
480 * enums for type of operation represented by a Query or PlannedStmt
482 * This is needed in both parsenodes.h and plannodes.h, so put it here...
487 CMD_SELECT, /* select stmt */
488 CMD_UPDATE, /* update stmt */
489 CMD_INSERT, /* insert stmt */
491 CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
493 CMD_NOTHING /* dummy command for instead nothing rules
500 * enums for types of relation joins
502 * JoinType determines the exact semantics of joining two relations using
503 * a matching qualification. For example, it tells what to do with a tuple
504 * that has no match in the other relation.
506 * This is needed in both parsenodes.h and plannodes.h, so put it here...
508 typedef enum JoinType
511 * The canonical kinds of joins according to the SQL JOIN syntax.
512 * Only these codes can appear in parser output (e.g., JoinExpr nodes).
514 JOIN_INNER, /* matching tuple pairs only */
515 JOIN_LEFT, /* pairs + unmatched LHS tuples */
516 JOIN_FULL, /* pairs + unmatched LHS + unmatched RHS */
517 JOIN_RIGHT, /* pairs + unmatched RHS tuples */
520 * Semijoins and anti-semijoins (as defined in relational theory) do
521 * not appear in the SQL JOIN syntax, but there are standard idioms for
522 * representing them (e.g., using EXISTS). The planner recognizes these
523 * cases and converts them to joins. So the planner and executor must
524 * support these codes. NOTE: in JOIN_SEMI output, it is unspecified
525 * which matching RHS row is joined to. In JOIN_ANTI output, the row
526 * is guaranteed to be null-extended.
528 JOIN_SEMI, /* 1 copy of each LHS row that has match(es) */
529 JOIN_ANTI, /* 1 copy of each LHS row that has no match */
532 * These codes are used internally in the planner, but are not supported
533 * by the executor (nor, indeed, by most of the planner).
535 JOIN_UNIQUE_OUTER, /* LHS path must be made unique */
536 JOIN_UNIQUE_INNER /* RHS path must be made unique */
539 * We might need additional join types someday.
544 * OUTER joins are those for which pushed-down quals must behave differently
545 * from the join's own quals. This is in fact everything except INNER joins.
546 * However, this macro must also exclude the JOIN_UNIQUE symbols since those
547 * are temporary proxies for what will eventually be an INNER join.
549 * Note: in some places it is preferable to treat JOIN_SEMI as not being
550 * an outer join, since it doesn't produce null-extended rows. Be aware
551 * of that distinction when deciding whether to use this macro.
553 #define IS_OUTER_JOIN(jointype) \
554 ((jointype) > JOIN_INNER && (jointype) < JOIN_UNIQUE_OUTER)