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.191 2007/01/05 22:19:55 momjian 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)
195 T_InnerIndexscanInfo,
201 * TAGS FOR MEMORY NODES (memnodes.h)
203 T_MemoryContext = 600,
207 * TAGS FOR VALUE NODES (value.h)
217 * TAGS FOR LIST NODES (pg_list.h)
224 * TAGS FOR PARSE TREE NODES (parsenodes.h)
247 T_CreateFunctionStmt,
276 T_ConstraintsSetStmt,
281 T_AlterDatabaseSetStmt,
283 T_CreateConversionStmt,
292 T_CreateTableSpaceStmt,
293 T_DropTableSpaceStmt,
294 T_AlterObjectSchemaStmt,
331 * TAGS FOR RANDOM OTHER STUFF
333 * These are objects that aren't part of parse/plan/execute node tree
334 * structures, but we give them NodeTags anyway for identification
335 * purposes (usually because they are involved in APIs where we want to
336 * pass multiple object types through the same pointer).
338 T_TriggerData = 900, /* in commands/trigger.h */
339 T_ReturnSetInfo, /* in nodes/execnodes.h */
340 T_TIDBitmap /* in nodes/tidbitmap.h */
344 * The first field of a node of any type is guaranteed to be the NodeTag.
345 * Hence the type of any node can be gotten by casting it to Node. Declaring
346 * a variable to be of Node * (instead of void *) can also facilitate
354 #define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
358 * create a new node of the specified size and tag the node with the
361 * !WARNING!: Avoid using newNode directly. You should be using the
362 * macro makeNode. eg. to create a Query node, use makeNode(Query)
364 * There is no way to dereference the palloc'ed pointer to assign the
365 * tag, and also return the pointer itself, so we need a holder variable.
366 * Fortunately, this macro isn't recursive so we just define
367 * a global variable for this purpose.
369 extern DLLIMPORT Node *newNodeMacroHolder;
371 #define newNode(size, tag) \
373 AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
374 newNodeMacroHolder = (Node *) palloc0fast(size), \
375 newNodeMacroHolder->type = (tag), \
380 #define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
381 #define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
383 #define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_)
385 /* ----------------------------------------------------------------
386 * extern declarations follow
387 * ----------------------------------------------------------------
391 * nodes/{outfuncs.c,print.c}
393 extern char *nodeToString(void *obj);
396 * nodes/{readfuncs.c,read.c}
398 extern void *stringToNode(char *str);
403 extern void *copyObject(void *obj);
408 extern bool equal(void *a, void *b);
412 * Typedefs for identifying qualifier selectivities and plan costs as such.
413 * These are just plain "double"s, but declaring a variable as Selectivity
414 * or Cost makes the intent more obvious.
416 * These could have gone into plannodes.h or some such, but many files
419 typedef double Selectivity; /* fraction of tuples a qualifier will pass */
420 typedef double Cost; /* execution cost (in page-access units) */
425 * enums for type of operation represented by a Query
427 * ??? could have put this in parsenodes.h but many files not in the
428 * optimizer also need this...
433 CMD_SELECT, /* select stmt */
434 CMD_UPDATE, /* update stmt */
435 CMD_INSERT, /* insert stmt */
437 CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
439 CMD_NOTHING /* dummy command for instead nothing rules
446 * enums for types of relation joins
448 * JoinType determines the exact semantics of joining two relations using
449 * a matching qualification. For example, it tells what to do with a tuple
450 * that has no match in the other relation.
452 * This is needed in both parsenodes.h and plannodes.h, so put it here...
454 typedef enum JoinType
457 * The canonical kinds of joins
459 JOIN_INNER, /* matching tuple pairs only */
460 JOIN_LEFT, /* pairs + unmatched outer tuples */
461 JOIN_FULL, /* pairs + unmatched outer + unmatched inner */
462 JOIN_RIGHT, /* pairs + unmatched inner tuples */
465 * These are used for queries like WHERE foo IN (SELECT bar FROM ...).
466 * Only JOIN_IN is actually implemented in the executor; the others are
467 * defined for internal use in the planner.
469 JOIN_IN, /* at most one result per outer row */
470 JOIN_REVERSE_IN, /* at most one result per inner row */
471 JOIN_UNIQUE_OUTER, /* outer path must be made unique */
472 JOIN_UNIQUE_INNER /* inner path must be made unique */
475 * We might need additional join types someday.
479 #define IS_OUTER_JOIN(jointype) \
480 ((jointype) == JOIN_LEFT || \
481 (jointype) == JOIN_FULL || \
482 (jointype) == JOIN_RIGHT)