1 /*-------------------------------------------------------------------------
4 * Definitions for tagged nodes.
7 * Portions Copyright (c) 1996-2007, 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.194 2007/02/03 14:06:55 petere 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)
124 T_ConvertRowtypeExpr,
138 T_CoerceToDomainValue,
146 * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
148 * These correspond (not always one-for-one) to primitive nodes derived
156 T_ScalarArrayOpExprState,
161 T_ConvertRowtypeExprState,
166 T_RowCompareExprState,
171 T_CoerceToDomainState,
172 T_DomainConstraintState,
175 * TAGS FOR PLANNER NODES (relation.h)
197 T_InnerIndexscanInfo,
203 * TAGS FOR MEMORY NODES (memnodes.h)
205 T_MemoryContext = 600,
209 * TAGS FOR VALUE NODES (value.h)
219 * TAGS FOR LIST NODES (pg_list.h)
226 * TAGS FOR PARSE TREE NODES (parsenodes.h)
249 T_CreateFunctionStmt,
278 T_ConstraintsSetStmt,
283 T_AlterDatabaseSetStmt,
285 T_CreateConversionStmt,
289 T_CreateOpFamilyStmt,
292 T_RemoveOpFamilyStmt,
297 T_CreateTableSpaceStmt,
298 T_DropTableSpaceStmt,
299 T_AlterObjectSchemaStmt,
337 * TAGS FOR RANDOM OTHER STUFF
339 * These are objects that aren't part of parse/plan/execute node tree
340 * structures, but we give them NodeTags anyway for identification
341 * purposes (usually because they are involved in APIs where we want to
342 * pass multiple object types through the same pointer).
344 T_TriggerData = 900, /* in commands/trigger.h */
345 T_ReturnSetInfo, /* in nodes/execnodes.h */
346 T_TIDBitmap /* in nodes/tidbitmap.h */
350 * The first field of a node of any type is guaranteed to be the NodeTag.
351 * Hence the type of any node can be gotten by casting it to Node. Declaring
352 * a variable to be of Node * (instead of void *) can also facilitate
360 #define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
364 * create a new node of the specified size and tag the node with the
367 * !WARNING!: Avoid using newNode directly. You should be using the
368 * macro makeNode. eg. to create a Query node, use makeNode(Query)
370 * There is no way to dereference the palloc'ed pointer to assign the
371 * tag, and also return the pointer itself, so we need a holder variable.
372 * Fortunately, this macro isn't recursive so we just define
373 * a global variable for this purpose.
375 extern DLLIMPORT Node *newNodeMacroHolder;
377 #define newNode(size, tag) \
379 AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
380 newNodeMacroHolder = (Node *) palloc0fast(size), \
381 newNodeMacroHolder->type = (tag), \
386 #define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
387 #define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
389 #define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_)
391 /* ----------------------------------------------------------------
392 * extern declarations follow
393 * ----------------------------------------------------------------
397 * nodes/{outfuncs.c,print.c}
399 extern char *nodeToString(void *obj);
402 * nodes/{readfuncs.c,read.c}
404 extern void *stringToNode(char *str);
409 extern void *copyObject(void *obj);
414 extern bool equal(void *a, void *b);
418 * Typedefs for identifying qualifier selectivities and plan costs as such.
419 * These are just plain "double"s, but declaring a variable as Selectivity
420 * or Cost makes the intent more obvious.
422 * These could have gone into plannodes.h or some such, but many files
425 typedef double Selectivity; /* fraction of tuples a qualifier will pass */
426 typedef double Cost; /* execution cost (in page-access units) */
431 * enums for type of operation represented by a Query
433 * ??? could have put this in parsenodes.h but many files not in the
434 * optimizer also need this...
439 CMD_SELECT, /* select stmt */
440 CMD_UPDATE, /* update stmt */
441 CMD_INSERT, /* insert stmt */
443 CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
445 CMD_NOTHING /* dummy command for instead nothing rules
452 * enums for types of relation joins
454 * JoinType determines the exact semantics of joining two relations using
455 * a matching qualification. For example, it tells what to do with a tuple
456 * that has no match in the other relation.
458 * This is needed in both parsenodes.h and plannodes.h, so put it here...
460 typedef enum JoinType
463 * The canonical kinds of joins
465 JOIN_INNER, /* matching tuple pairs only */
466 JOIN_LEFT, /* pairs + unmatched outer tuples */
467 JOIN_FULL, /* pairs + unmatched outer + unmatched inner */
468 JOIN_RIGHT, /* pairs + unmatched inner tuples */
471 * These are used for queries like WHERE foo IN (SELECT bar FROM ...).
472 * Only JOIN_IN is actually implemented in the executor; the others are
473 * defined for internal use in the planner.
475 JOIN_IN, /* at most one result per outer row */
476 JOIN_REVERSE_IN, /* at most one result per inner row */
477 JOIN_UNIQUE_OUTER, /* outer path must be made unique */
478 JOIN_UNIQUE_INNER /* inner path must be made unique */
481 * We might need additional join types someday.
485 #define IS_OUTER_JOIN(jointype) \
486 ((jointype) == JOIN_LEFT || \
487 (jointype) == JOIN_FULL || \
488 (jointype) == JOIN_RIGHT)