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.208 2008/08/14 18:48:00 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)
72 * TAGS FOR PLAN STATE NODES (execnodes.h)
74 * These should correspond one-to-one with Plan node types.
84 T_BitmapIndexScanState,
85 T_BitmapHeapScanState,
104 * TAGS FOR PRIMITIVE NODES (primnodes.h)
126 T_ConvertRowtypeExpr,
140 T_CoerceToDomainValue,
150 * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
152 * These correspond (not always one-for-one) to primitive nodes derived
160 T_ScalarArrayOpExprState,
166 T_ArrayCoerceExprState,
167 T_ConvertRowtypeExprState,
172 T_RowCompareExprState,
177 T_CoerceToDomainState,
178 T_DomainConstraintState,
181 * TAGS FOR PLANNER NODES (relation.h)
204 T_InnerIndexscanInfo,
211 * TAGS FOR MEMORY NODES (memnodes.h)
213 T_MemoryContext = 600,
217 * TAGS FOR VALUE NODES (value.h)
227 * TAGS FOR LIST NODES (pg_list.h)
234 * TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
258 T_CreateFunctionStmt,
287 T_ConstraintsSetStmt,
292 T_AlterDatabaseSetStmt,
294 T_CreateConversionStmt,
298 T_CreateOpFamilyStmt,
301 T_RemoveOpFamilyStmt,
306 T_CreateTableSpaceStmt,
307 T_DropTableSpaceStmt,
308 T_AlterObjectSchemaStmt,
314 T_AlterTSDictionaryStmt,
315 T_AlterTSConfigurationStmt,
318 * TAGS FOR PARSE TREE NODES (parsenodes.h)
352 * TAGS FOR RANDOM OTHER STUFF
354 * These are objects that aren't part of parse/plan/execute node tree
355 * structures, but we give them NodeTags anyway for identification
356 * purposes (usually because they are involved in APIs where we want to
357 * pass multiple object types through the same pointer).
359 T_TriggerData = 950, /* in commands/trigger.h */
360 T_ReturnSetInfo, /* in nodes/execnodes.h */
361 T_TIDBitmap /* in nodes/tidbitmap.h */
365 * The first field of a node of any type is guaranteed to be the NodeTag.
366 * Hence the type of any node can be gotten by casting it to Node. Declaring
367 * a variable to be of Node * (instead of void *) can also facilitate
375 #define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
379 * create a new node of the specified size and tag the node with the
382 * !WARNING!: Avoid using newNode directly. You should be using the
383 * macro makeNode. eg. to create a Query node, use makeNode(Query)
385 * There is no way to dereference the palloc'ed pointer to assign the
386 * tag, and also return the pointer itself, so we need a holder variable.
387 * Fortunately, this macro isn't recursive so we just define
388 * a global variable for this purpose.
390 extern PGDLLIMPORT Node *newNodeMacroHolder;
392 #define newNode(size, tag) \
394 AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
395 newNodeMacroHolder = (Node *) palloc0fast(size), \
396 newNodeMacroHolder->type = (tag), \
401 #define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
402 #define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
404 #define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_)
406 /* ----------------------------------------------------------------
407 * extern declarations follow
408 * ----------------------------------------------------------------
412 * nodes/{outfuncs.c,print.c}
414 extern char *nodeToString(void *obj);
417 * nodes/{readfuncs.c,read.c}
419 extern void *stringToNode(char *str);
424 extern void *copyObject(void *obj);
429 extern bool equal(void *a, void *b);
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.
437 * These could have gone into plannodes.h or some such, but many files
440 typedef double Selectivity; /* fraction of tuples a qualifier will pass */
441 typedef double Cost; /* execution cost (in page-access units) */
446 * enums for type of operation represented by a Query or PlannedStmt
448 * This is needed in both parsenodes.h and plannodes.h, so put it here...
453 CMD_SELECT, /* select stmt */
454 CMD_UPDATE, /* update stmt */
455 CMD_INSERT, /* insert stmt */
457 CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
459 CMD_NOTHING /* dummy command for instead nothing rules
466 * enums for types of relation joins
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.
472 * This is needed in both parsenodes.h and plannodes.h, so put it here...
474 typedef enum JoinType
477 * The canonical kinds of joins according to the SQL JOIN syntax.
478 * Only these codes can appear in parser output (e.g., JoinExpr nodes).
480 JOIN_INNER, /* matching tuple pairs only */
481 JOIN_LEFT, /* pairs + unmatched LHS tuples */
482 JOIN_FULL, /* pairs + unmatched LHS + unmatched RHS */
483 JOIN_RIGHT, /* pairs + unmatched RHS tuples */
486 * Semijoins and anti-semijoins (as defined in relational theory) do
487 * not appear in the SQL JOIN syntax, but there are standard idioms for
488 * representing them (e.g., using EXISTS). The planner recognizes these
489 * cases and converts them to joins. So the planner and executor must
490 * support these codes. NOTE: in JOIN_SEMI output, it is unspecified
491 * which matching RHS row is joined to. In JOIN_ANTI output, the row
492 * is guaranteed to be null-extended.
494 JOIN_SEMI, /* 1 copy of each LHS row that has match(es) */
495 JOIN_ANTI, /* 1 copy of each LHS row that has no match */
498 * These codes are used internally in the planner, but are not supported
499 * by the executor (nor, indeed, by most of the planner).
501 JOIN_UNIQUE_OUTER, /* LHS path must be made unique */
502 JOIN_UNIQUE_INNER /* RHS path must be made unique */
505 * We might need additional join types someday.
510 * OUTER joins are those for which pushed-down quals must behave differently
511 * from the join's own quals. This is in fact everything except INNER joins.
512 * However, this macro must also exclude the JOIN_UNIQUE symbols since those
513 * are temporary proxies for what will eventually be an INNER join.
515 * Note: in some places it is preferable to treat JOIN_SEMI as not being
516 * an outer join, since it doesn't produce null-extended rows. Be aware
517 * of that distinction when deciding whether to use this macro.
519 #define IS_OUTER_JOIN(jointype) \
520 ((jointype) > JOIN_INNER && (jointype) < JOIN_UNIQUE_OUTER)