1 /*-------------------------------------------------------------------------
4 * Definitions for tagged nodes.
7 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: nodes.h,v 1.95 2001/10/28 06:26:07 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 number 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.
29 * TAGS FOR PLAN NODES (plannodes.h)
54 * TAGS FOR PRIMITIVE NODES (primnodes.h)
75 * TAGS FOR PLANNER NODES (relation.h)
92 * TAGS FOR EXECUTOR NODES (execnodes.h)
125 * TAGS FOR MEMORY NODES (memnodes.h)
127 T_MemoryContext = 400,
131 * TAGS FOR VALUE NODES (pg_list.h)
142 * TAGS FOR PARSE TREE NODES (parsenodes.h)
191 T_ConstraintsSetStmt,
227 * TAGS FOR FUNCTION-CALL CONTEXT AND RESULTINFO NODES (see fmgr.h)
229 T_TriggerData = 800, /* in commands/trigger.h */
230 T_ReturnSetInfo /* in nodes/execnodes.h */
235 * The first field of a node of any type is guaranteed to be the NodeTag.
236 * Hence the type of any node can be gotten by casting it to Node. Declaring
237 * a variable to be of Node * (instead of void *) can also facilitate
245 #define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
247 #define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
248 #define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
250 #define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_)
252 /* ----------------------------------------------------------------
253 * IsA functions (no inheritance any more)
254 * ----------------------------------------------------------------
256 #define IsA_JoinPath(jp) \
257 (IsA(jp, NestPath) || IsA(jp, MergePath) || IsA(jp, HashPath))
259 #define IsA_Join(jp) \
260 (IsA(jp, Join) || IsA(jp, NestLoop) || \
261 IsA(jp, MergeJoin) || IsA(jp, HashJoin))
263 /* ----------------------------------------------------------------
264 * extern declarations follow
265 * ----------------------------------------------------------------
271 extern Node *newNode(Size size, NodeTag tag);
274 * nodes/{outfuncs.c,print.c}
276 extern char *nodeToString(void *obj);
279 * nodes/{readfuncs.c,read.c}
281 extern void *stringToNode(char *str);
286 extern void *copyObject(void *obj);
291 extern bool equal(void *a, void *b);
295 * Typedefs for identifying qualifier selectivities and plan costs as such.
296 * These are just plain "double"s, but declaring a variable as Selectivity
297 * or Cost makes the intent more obvious.
299 * These could have gone into plannodes.h or some such, but many files
302 typedef double Selectivity; /* fraction of tuples a qualifier will
304 typedef double Cost; /* execution cost (in page-access units) */
309 * enums for type of operation represented by a Query
311 * ??? could have put this in parsenodes.h but many files not in the
312 * optimizer also need this...
317 CMD_SELECT, /* select stmt (formerly retrieve) */
318 CMD_UPDATE, /* update stmt (formerly replace) */
319 CMD_INSERT, /* insert stmt (formerly append) */
321 CMD_UTILITY, /* cmds like create, destroy, copy,
323 CMD_NOTHING /* dummy command for instead nothing rules
330 * enums for types of relation joins
332 * JoinType determines the exact semantics of joining two relations using
333 * a matching qualification. For example, it tells what to do with a tuple
334 * that has no match in the other relation.
336 * This is needed in both parsenodes.h and plannodes.h, so put it here...
338 typedef enum JoinType
341 * The canonical kinds of joins
343 JOIN_INNER, /* matching tuple pairs only */
344 JOIN_LEFT, /* pairs + unmatched outer tuples */
345 JOIN_FULL, /* pairs + unmatched outer + unmatched
347 JOIN_RIGHT, /* pairs + unmatched inner tuples */
350 * SQL92 considers UNION JOIN to be a kind of join, so list it here
351 * for parser convenience, even though it's not implemented like a
352 * join in the executor. (The planner must convert it to an Append
358 * Eventually we will have some additional join types for efficient
359 * support of queries like WHERE foo IN (SELECT bar FROM ...).
363 #define IS_OUTER_JOIN(jointype) \
364 ((jointype) == JOIN_LEFT || \
365 (jointype) == JOIN_FULL || \
366 (jointype) == JOIN_RIGHT)