1 /*-------------------------------------------------------------------------
4 * Definitions for tagged nodes.
7 * Portions Copyright (c) 1996-2006, 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.188 2006/09/28 20:51:42 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)
124 T_ConvertRowtypeExpr,
137 T_CoerceToDomainValue,
145 * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
147 * These correspond (not always one-for-one) to primitive nodes derived
155 T_ScalarArrayOpExprState,
160 T_ConvertRowtypeExprState,
165 T_RowCompareExprState,
169 T_CoerceToDomainState,
170 T_DomainConstraintState,
173 * TAGS FOR PLANNER NODES (relation.h)
193 T_InnerIndexscanInfo,
199 * TAGS FOR MEMORY NODES (memnodes.h)
201 T_MemoryContext = 600,
205 * TAGS FOR VALUE NODES (value.h)
215 * TAGS FOR LIST NODES (pg_list.h)
222 * TAGS FOR PARSE TREE NODES (parsenodes.h)
245 T_CreateFunctionStmt,
274 T_ConstraintsSetStmt,
279 T_AlterDatabaseSetStmt,
281 T_CreateConversionStmt,
290 T_CreateTableSpaceStmt,
291 T_DropTableSpaceStmt,
292 T_AlterObjectSchemaStmt,
329 * TAGS FOR RANDOM OTHER STUFF
331 * These are objects that aren't part of parse/plan/execute node tree
332 * structures, but we give them NodeTags anyway for identification
333 * purposes (usually because they are involved in APIs where we want to
334 * pass multiple object types through the same pointer).
336 T_TriggerData = 900, /* in commands/trigger.h */
337 T_ReturnSetInfo, /* in nodes/execnodes.h */
338 T_TIDBitmap /* in nodes/tidbitmap.h */
342 * The first field of a node of any type is guaranteed to be the NodeTag.
343 * Hence the type of any node can be gotten by casting it to Node. Declaring
344 * a variable to be of Node * (instead of void *) can also facilitate
352 #define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
356 * create a new node of the specified size and tag the node with the
359 * !WARNING!: Avoid using newNode directly. You should be using the
360 * macro makeNode. eg. to create a Query node, use makeNode(Query)
362 * There is no way to dereference the palloc'ed pointer to assign the
363 * tag, and also return the pointer itself, so we need a holder variable.
364 * Fortunately, this macro isn't recursive so we just define
365 * a global variable for this purpose.
367 extern DLLIMPORT Node *newNodeMacroHolder;
369 #define newNode(size, tag) \
371 AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
372 newNodeMacroHolder = (Node *) palloc0fast(size), \
373 newNodeMacroHolder->type = (tag), \
378 #define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
379 #define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
381 #define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_)
383 /* ----------------------------------------------------------------
384 * extern declarations follow
385 * ----------------------------------------------------------------
389 * nodes/{outfuncs.c,print.c}
391 extern char *nodeToString(void *obj);
394 * nodes/{readfuncs.c,read.c}
396 extern void *stringToNode(char *str);
401 extern void *copyObject(void *obj);
406 extern bool equal(void *a, void *b);
410 * Typedefs for identifying qualifier selectivities and plan costs as such.
411 * These are just plain "double"s, but declaring a variable as Selectivity
412 * or Cost makes the intent more obvious.
414 * These could have gone into plannodes.h or some such, but many files
417 typedef double Selectivity; /* fraction of tuples a qualifier will pass */
418 typedef double Cost; /* execution cost (in page-access units) */
423 * enums for type of operation represented by a Query
425 * ??? could have put this in parsenodes.h but many files not in the
426 * optimizer also need this...
431 CMD_SELECT, /* select stmt */
432 CMD_UPDATE, /* update stmt */
433 CMD_INSERT, /* insert stmt */
435 CMD_UTILITY, /* cmds like create, destroy, copy, vacuum,
437 CMD_NOTHING /* dummy command for instead nothing rules
444 * enums for types of relation joins
446 * JoinType determines the exact semantics of joining two relations using
447 * a matching qualification. For example, it tells what to do with a tuple
448 * that has no match in the other relation.
450 * This is needed in both parsenodes.h and plannodes.h, so put it here...
452 typedef enum JoinType
455 * The canonical kinds of joins
457 JOIN_INNER, /* matching tuple pairs only */
458 JOIN_LEFT, /* pairs + unmatched outer tuples */
459 JOIN_FULL, /* pairs + unmatched outer + unmatched inner */
460 JOIN_RIGHT, /* pairs + unmatched inner tuples */
463 * These are used for queries like WHERE foo IN (SELECT bar FROM ...).
464 * Only JOIN_IN is actually implemented in the executor; the others are
465 * defined for internal use in the planner.
467 JOIN_IN, /* at most one result per outer row */
468 JOIN_REVERSE_IN, /* at most one result per inner row */
469 JOIN_UNIQUE_OUTER, /* outer path must be made unique */
470 JOIN_UNIQUE_INNER /* inner path must be made unique */
473 * We might need additional join types someday.
477 #define IS_OUTER_JOIN(jointype) \
478 ((jointype) == JOIN_LEFT || \
479 (jointype) == JOIN_FULL || \
480 (jointype) == JOIN_RIGHT)