Eneboo - Documentación para desarrolladores
|
00001 /*------------------------------------------------------------------------- 00002 * 00003 * nodes.h 00004 * Definitions for tagged nodes. 00005 * 00006 * 00007 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group 00008 * Portions Copyright (c) 1994, Regents of the University of California 00009 * 00010 * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.176.2.1 2005/11/22 18:23:28 momjian Exp $ 00011 * 00012 *------------------------------------------------------------------------- 00013 */ 00014 #ifndef NODES_H 00015 #define NODES_H 00016 00017 /* 00018 * The first field of every node is NodeTag. Each node created (with makeNode) 00019 * will have one of the following tags as the value of its first field. 00020 * 00021 * Note that the numbers of the node tags are not contiguous. We left holes 00022 * here so that we can add more tags without changing the existing enum's. 00023 * (Since node tag numbers never exist outside backend memory, there's no 00024 * real harm in renumbering, it just costs a full rebuild ...) 00025 */ 00026 typedef enum NodeTag 00027 { 00028 T_Invalid = 0, 00029 00030 /* 00031 * TAGS FOR EXECUTOR NODES (execnodes.h) 00032 */ 00033 T_IndexInfo = 10, 00034 T_ExprContext, 00035 T_ProjectionInfo, 00036 T_JunkFilter, 00037 T_ResultRelInfo, 00038 T_EState, 00039 T_TupleTableSlot, 00040 00041 /* 00042 * TAGS FOR PLAN NODES (plannodes.h) 00043 */ 00044 T_Plan = 100, 00045 T_Result, 00046 T_Append, 00047 T_BitmapAnd, 00048 T_BitmapOr, 00049 T_Scan, 00050 T_SeqScan, 00051 T_IndexScan, 00052 T_BitmapIndexScan, 00053 T_BitmapHeapScan, 00054 T_TidScan, 00055 T_SubqueryScan, 00056 T_FunctionScan, 00057 T_Join, 00058 T_NestLoop, 00059 T_MergeJoin, 00060 T_HashJoin, 00061 T_Material, 00062 T_Sort, 00063 T_Group, 00064 T_Agg, 00065 T_Unique, 00066 T_Hash, 00067 T_SetOp, 00068 T_Limit, 00069 00070 /* 00071 * TAGS FOR PLAN STATE NODES (execnodes.h) 00072 * 00073 * These should correspond one-to-one with Plan node types. 00074 */ 00075 T_PlanState = 200, 00076 T_ResultState, 00077 T_AppendState, 00078 T_BitmapAndState, 00079 T_BitmapOrState, 00080 T_ScanState, 00081 T_SeqScanState, 00082 T_IndexScanState, 00083 T_BitmapIndexScanState, 00084 T_BitmapHeapScanState, 00085 T_TidScanState, 00086 T_SubqueryScanState, 00087 T_FunctionScanState, 00088 T_JoinState, 00089 T_NestLoopState, 00090 T_MergeJoinState, 00091 T_HashJoinState, 00092 T_MaterialState, 00093 T_SortState, 00094 T_GroupState, 00095 T_AggState, 00096 T_UniqueState, 00097 T_HashState, 00098 T_SetOpState, 00099 T_LimitState, 00100 00101 /* 00102 * TAGS FOR PRIMITIVE NODES (primnodes.h) 00103 */ 00104 T_Alias = 300, 00105 T_RangeVar, 00106 T_Expr, 00107 T_Var, 00108 T_Const, 00109 T_Param, 00110 T_Aggref, 00111 T_ArrayRef, 00112 T_FuncExpr, 00113 T_OpExpr, 00114 T_DistinctExpr, 00115 T_ScalarArrayOpExpr, 00116 T_BoolExpr, 00117 T_SubLink, 00118 T_SubPlan, 00119 T_FieldSelect, 00120 T_FieldStore, 00121 T_RelabelType, 00122 T_ConvertRowtypeExpr, 00123 T_CaseExpr, 00124 T_CaseWhen, 00125 T_CaseTestExpr, 00126 T_ArrayExpr, 00127 T_RowExpr, 00128 T_CoalesceExpr, 00129 T_MinMaxExpr, 00130 T_NullIfExpr, 00131 T_NullTest, 00132 T_BooleanTest, 00133 T_CoerceToDomain, 00134 T_CoerceToDomainValue, 00135 T_SetToDefault, 00136 T_TargetEntry, 00137 T_RangeTblRef, 00138 T_JoinExpr, 00139 T_FromExpr, 00140 00141 /* 00142 * TAGS FOR EXPRESSION STATE NODES (execnodes.h) 00143 * 00144 * These correspond (not always one-for-one) to primitive nodes derived 00145 * from Expr. 00146 */ 00147 T_ExprState = 400, 00148 T_GenericExprState, 00149 T_AggrefExprState, 00150 T_ArrayRefExprState, 00151 T_FuncExprState, 00152 T_ScalarArrayOpExprState, 00153 T_BoolExprState, 00154 T_SubPlanState, 00155 T_FieldSelectState, 00156 T_FieldStoreState, 00157 T_ConvertRowtypeExprState, 00158 T_CaseExprState, 00159 T_CaseWhenState, 00160 T_ArrayExprState, 00161 T_RowExprState, 00162 T_CoalesceExprState, 00163 T_MinMaxExprState, 00164 T_CoerceToDomainState, 00165 T_DomainConstraintState, 00166 00167 /* 00168 * TAGS FOR PLANNER NODES (relation.h) 00169 */ 00170 T_PlannerInfo = 500, 00171 T_RelOptInfo, 00172 T_IndexOptInfo, 00173 T_Path, 00174 T_IndexPath, 00175 T_BitmapHeapPath, 00176 T_BitmapAndPath, 00177 T_BitmapOrPath, 00178 T_NestPath, 00179 T_MergePath, 00180 T_HashPath, 00181 T_TidPath, 00182 T_AppendPath, 00183 T_ResultPath, 00184 T_MaterialPath, 00185 T_UniquePath, 00186 T_PathKeyItem, 00187 T_RestrictInfo, 00188 T_InnerIndexscanInfo, 00189 T_InClauseInfo, 00190 00191 /* 00192 * TAGS FOR MEMORY NODES (memnodes.h) 00193 */ 00194 T_MemoryContext = 600, 00195 T_AllocSetContext, 00196 00197 /* 00198 * TAGS FOR VALUE NODES (value.h) 00199 */ 00200 T_Value = 650, 00201 T_Integer, 00202 T_Float, 00203 T_String, 00204 T_BitString, 00205 T_Null, 00206 00207 /* 00208 * TAGS FOR LIST NODES (pg_list.h) 00209 */ 00210 T_List, 00211 T_IntList, 00212 T_OidList, 00213 00214 /* 00215 * TAGS FOR PARSE TREE NODES (parsenodes.h) 00216 */ 00217 T_Query = 700, 00218 T_InsertStmt, 00219 T_DeleteStmt, 00220 T_UpdateStmt, 00221 T_SelectStmt, 00222 T_AlterTableStmt, 00223 T_AlterTableCmd, 00224 T_AlterDomainStmt, 00225 T_SetOperationStmt, 00226 T_GrantStmt, 00227 T_GrantRoleStmt, 00228 T_ClosePortalStmt, 00229 T_ClusterStmt, 00230 T_CopyStmt, 00231 T_CreateStmt, 00232 T_DefineStmt, 00233 T_DropStmt, 00234 T_TruncateStmt, 00235 T_CommentStmt, 00236 T_FetchStmt, 00237 T_IndexStmt, 00238 T_CreateFunctionStmt, 00239 T_AlterFunctionStmt, 00240 T_RemoveAggrStmt, 00241 T_RemoveFuncStmt, 00242 T_RemoveOperStmt, 00243 T_RenameStmt, 00244 T_RuleStmt, 00245 T_NotifyStmt, 00246 T_ListenStmt, 00247 T_UnlistenStmt, 00248 T_TransactionStmt, 00249 T_ViewStmt, 00250 T_LoadStmt, 00251 T_CreateDomainStmt, 00252 T_CreatedbStmt, 00253 T_DropdbStmt, 00254 T_VacuumStmt, 00255 T_ExplainStmt, 00256 T_CreateSeqStmt, 00257 T_AlterSeqStmt, 00258 T_VariableSetStmt, 00259 T_VariableShowStmt, 00260 T_VariableResetStmt, 00261 T_CreateTrigStmt, 00262 T_DropPropertyStmt, 00263 T_CreatePLangStmt, 00264 T_DropPLangStmt, 00265 T_CreateRoleStmt, 00266 T_AlterRoleStmt, 00267 T_DropRoleStmt, 00268 T_LockStmt, 00269 T_ConstraintsSetStmt, 00270 T_ReindexStmt, 00271 T_CheckPointStmt, 00272 T_CreateSchemaStmt, 00273 T_AlterDatabaseStmt, 00274 T_AlterDatabaseSetStmt, 00275 T_AlterRoleSetStmt, 00276 T_CreateConversionStmt, 00277 T_CreateCastStmt, 00278 T_DropCastStmt, 00279 T_CreateOpClassStmt, 00280 T_RemoveOpClassStmt, 00281 T_PrepareStmt, 00282 T_ExecuteStmt, 00283 T_DeallocateStmt, 00284 T_DeclareCursorStmt, 00285 T_CreateTableSpaceStmt, 00286 T_DropTableSpaceStmt, 00287 T_AlterObjectSchemaStmt, 00288 T_AlterOwnerStmt, 00289 00290 T_A_Expr = 800, 00291 T_ColumnRef, 00292 T_ParamRef, 00293 T_A_Const, 00294 T_FuncCall, 00295 T_A_Indices, 00296 T_A_Indirection, 00297 T_ResTarget, 00298 T_TypeCast, 00299 T_SortBy, 00300 T_RangeSubselect, 00301 T_RangeFunction, 00302 T_TypeName, 00303 T_ColumnDef, 00304 T_IndexElem, 00305 T_Constraint, 00306 T_DefElem, 00307 T_RangeTblEntry, 00308 T_SortClause, 00309 T_GroupClause, 00310 T_FkConstraint, 00311 T_PrivGrantee, 00312 T_FuncWithArgs, 00313 T_PrivTarget, 00314 T_CreateOpClassItem, 00315 T_CompositeTypeStmt, 00316 T_InhRelation, 00317 T_FunctionParameter, 00318 T_LockingClause, 00319 00320 /* 00321 * TAGS FOR RANDOM OTHER STUFF 00322 * 00323 * These are objects that aren't part of parse/plan/execute node tree 00324 * structures, but we give them NodeTags anyway for identification 00325 * purposes (usually because they are involved in APIs where we want to 00326 * pass multiple object types through the same pointer). 00327 */ 00328 T_TriggerData = 900, /* in commands/trigger.h */ 00329 T_ReturnSetInfo, /* in nodes/execnodes.h */ 00330 T_TIDBitmap /* in nodes/tidbitmap.h */ 00331 } NodeTag; 00332 00333 /* 00334 * The first field of a node of any type is guaranteed to be the NodeTag. 00335 * Hence the type of any node can be gotten by casting it to Node. Declaring 00336 * a variable to be of Node * (instead of void *) can also facilitate 00337 * debugging. 00338 */ 00339 typedef struct Node 00340 { 00341 NodeTag type; 00342 } Node; 00343 00344 #define nodeTag(nodeptr) (((Node*)(nodeptr))->type) 00345 00346 /* 00347 * newNode - 00348 * create a new node of the specified size and tag the node with the 00349 * specified tag. 00350 * 00351 * !WARNING!: Avoid using newNode directly. You should be using the 00352 * macro makeNode. eg. to create a Query node, use makeNode(Query) 00353 * 00354 * There is no way to dereference the palloc'ed pointer to assign the 00355 * tag, and also return the pointer itself, so we need a holder variable. 00356 * Fortunately, this macro isn't recursive so we just define 00357 * a global variable for this purpose. 00358 */ 00359 extern DLLIMPORT Node *newNodeMacroHolder; 00360 00361 #define newNode(size, tag) \ 00362 ( \ 00363 AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \ 00364 newNodeMacroHolder = (Node *) palloc0fast(size), \ 00365 newNodeMacroHolder->type = (tag), \ 00366 newNodeMacroHolder \ 00367 ) 00368 00369 00370 #define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_)) 00371 #define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t)) 00372 00373 #define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_) 00374 00375 /* ---------------------------------------------------------------- 00376 * extern declarations follow 00377 * ---------------------------------------------------------------- 00378 */ 00379 00380 /* 00381 * nodes/{outfuncs.c,print.c} 00382 */ 00383 extern char *nodeToString(void *obj); 00384 00385 /* 00386 * nodes/{readfuncs.c,read.c} 00387 */ 00388 extern void *stringToNode(char *str); 00389 00390 /* 00391 * nodes/copyfuncs.c 00392 */ 00393 extern void *copyObject(void *obj); 00394 00395 /* 00396 * nodes/equalfuncs.c 00397 */ 00398 extern bool equal(void *a, void *b); 00399 00400 00401 /* 00402 * Typedefs for identifying qualifier selectivities and plan costs as such. 00403 * These are just plain "double"s, but declaring a variable as Selectivity 00404 * or Cost makes the intent more obvious. 00405 * 00406 * These could have gone into plannodes.h or some such, but many files 00407 * depend on them... 00408 */ 00409 typedef double Selectivity; /* fraction of tuples a qualifier will pass */ 00410 typedef double Cost; /* execution cost (in page-access units) */ 00411 00412 00413 /* 00414 * CmdType - 00415 * enums for type of operation represented by a Query 00416 * 00417 * ??? could have put this in parsenodes.h but many files not in the 00418 * optimizer also need this... 00419 */ 00420 typedef enum CmdType 00421 { 00422 CMD_UNKNOWN, 00423 CMD_SELECT, /* select stmt (formerly retrieve) */ 00424 CMD_UPDATE, /* update stmt (formerly replace) */ 00425 CMD_INSERT, /* insert stmt (formerly append) */ 00426 CMD_DELETE, 00427 CMD_UTILITY, /* cmds like create, destroy, copy, vacuum, 00428 * etc. */ 00429 CMD_NOTHING /* dummy command for instead nothing rules 00430 * with qual */ 00431 } CmdType; 00432 00433 00434 /* 00435 * JoinType - 00436 * enums for types of relation joins 00437 * 00438 * JoinType determines the exact semantics of joining two relations using 00439 * a matching qualification. For example, it tells what to do with a tuple 00440 * that has no match in the other relation. 00441 * 00442 * This is needed in both parsenodes.h and plannodes.h, so put it here... 00443 */ 00444 typedef enum JoinType 00445 { 00446 /* 00447 * The canonical kinds of joins 00448 */ 00449 JOIN_INNER, /* matching tuple pairs only */ 00450 JOIN_LEFT, /* pairs + unmatched outer tuples */ 00451 JOIN_FULL, /* pairs + unmatched outer + unmatched inner */ 00452 JOIN_RIGHT, /* pairs + unmatched inner tuples */ 00453 00454 /* 00455 * SQL92 considers UNION JOIN to be a kind of join, so list it here for 00456 * parser convenience, even though it's not implemented like a join in the 00457 * executor. (The planner must convert it to an Append plan.) 00458 */ 00459 JOIN_UNION, 00460 00461 /* 00462 * These are used for queries like WHERE foo IN (SELECT bar FROM ...). 00463 * Only JOIN_IN is actually implemented in the executor; the others are 00464 * defined for internal use in the planner. 00465 */ 00466 JOIN_IN, /* at most one result per outer row */ 00467 JOIN_REVERSE_IN, /* at most one result per inner row */ 00468 JOIN_UNIQUE_OUTER, /* outer path must be made unique */ 00469 JOIN_UNIQUE_INNER /* inner path must be made unique */ 00470 00471 /* 00472 * We might need additional join types someday. 00473 */ 00474 } JoinType; 00475 00476 #define IS_OUTER_JOIN(jointype) \ 00477 ((jointype) == JOIN_LEFT || \ 00478 (jointype) == JOIN_FULL || \ 00479 (jointype) == JOIN_RIGHT) 00480 00481 #endif /* NODES_H */