1 /*-------------------------------------------------------------------------
4 * Definitions for tagged nodes.
7 * Portions Copyright (c) 2003-2008, PgPool Global Development Group
8 * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
9 * Portions Copyright (c) 1994, Regents of the University of California
11 * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.204 2007/09/03 18:46:30 tgl Exp $
13 *-------------------------------------------------------------------------
19 * The first field of every node is NodeTag. Each node created (with makeNode)
20 * will have one of the following tags as the value of its first field.
22 * Note that the numbers of the node tags are not contiguous. We left holes
23 * here so that we can add more tags without changing the existing enum's.
24 * (Since node tag numbers never exist outside backend memory, there's no
25 * real harm in renumbering, it just costs a full rebuild ...)
32 * TAGS FOR EXECUTOR NODES (execnodes.h)
43 * TAGS FOR PLAN NODES (plannodes.h)
73 * TAGS FOR PLAN STATE NODES (execnodes.h)
75 * These should correspond one-to-one with Plan node types.
85 T_BitmapIndexScanState,
86 T_BitmapHeapScanState,
105 * TAGS FOR PRIMITIVE NODES (primnodes.h)
127 T_ConvertRowtypeExpr,
141 T_CoerceToDomainValue,
151 * TAGS FOR EXPRESSION STATE NODES (execnodes.h)
153 * These correspond (not always one-for-one) to primitive nodes derived
161 T_ScalarArrayOpExprState,
167 T_ArrayCoerceExprState,
168 T_ConvertRowtypeExprState,
173 T_RowCompareExprState,
178 T_CoerceToDomainState,
179 T_DomainConstraintState,
182 * TAGS FOR PLANNER NODES (relation.h)
205 T_InnerIndexscanInfo,
212 * TAGS FOR MEMORY NODES (memnodes.h)
214 T_MemoryContext = 600,
218 * TAGS FOR VALUE NODES (value.h)
228 * TAGS FOR LIST NODES (pg_list.h)
235 * TAGS FOR STATEMENT NODES (mostly in parsenodes.h)
259 T_CreateFunctionStmt,
288 T_ConstraintsSetStmt,
293 T_AlterDatabaseSetStmt,
295 T_CreateConversionStmt,
299 T_CreateOpFamilyStmt,
302 T_RemoveOpFamilyStmt,
307 T_CreateTableSpaceStmt,
308 T_DropTableSpaceStmt,
309 T_AlterObjectSchemaStmt,
315 T_AlterTSDictionaryStmt,
316 T_AlterTSConfigurationStmt,
319 * TAGS FOR PARSE TREE NODES (parsenodes.h)
353 * TAGS FOR RANDOM OTHER STUFF
355 * These are objects that aren't part of parse/plan/execute node tree
356 * structures, but we give them NodeTags anyway for identification
357 * purposes (usually because they are involved in APIs where we want to
358 * pass multiple object types through the same pointer).
360 T_TriggerData = 950, /* in commands/trigger.h */
361 T_ReturnSetInfo, /* in nodes/execnodes.h */
362 T_TIDBitmap /* in nodes/tidbitmap.h */
366 * The first field of a node of any type is guaranteed to be the NodeTag.
367 * Hence the type of any node can be gotten by casting it to Node. Declaring
368 * a variable to be of Node * (instead of void *) can also facilitate
376 #define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
380 * create a new node of the specified size and tag the node with the
383 * !WARNING!: Avoid using newNode directly. You should be using the
384 * macro makeNode. eg. to create a Query node, use makeNode(Query)
386 * There is no way to dereference the palloc'ed pointer to assign the
387 * tag, and also return the pointer itself, so we need a holder variable.
388 * Fortunately, this macro isn't recursive so we just define
389 * a global variable for this purpose.
391 extern Node *newNodeMacroHolder;
393 #define newNode(size, tag) \
395 newNodeMacroHolder = (Node *) palloc0(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 int 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
479 JOIN_INNER, /* matching tuple pairs only */
480 JOIN_LEFT, /* pairs + unmatched outer tuples */
481 JOIN_FULL, /* pairs + unmatched outer + unmatched inner */
482 JOIN_RIGHT, /* pairs + unmatched inner tuples */
485 * These are used for queries like WHERE foo IN (SELECT bar FROM ...).
486 * Only JOIN_IN is actually implemented in the executor; the others are
487 * defined for internal use in the planner.
489 JOIN_IN, /* at most one result per outer row */
490 JOIN_REVERSE_IN, /* at most one result per inner row */
491 JOIN_UNIQUE_OUTER, /* outer path must be made unique */
492 JOIN_UNIQUE_INNER /* inner path must be made unique */
495 * We might need additional join types someday.
499 #define IS_OUTER_JOIN(jointype) \
500 ((jointype) == JOIN_LEFT || \
501 (jointype) == JOIN_FULL || \
502 (jointype) == JOIN_RIGHT)