📄 readfuncs.c
字号:
return local_node;}/* ---------------- * _readParam * * Param is a subclass of Expr * ---------------- */static Param *_readParam(){ Param *local_node; char *token; int length; local_node = makeNode(Param); token = lsptok(NULL, &length); /* get :paramkind */ token = lsptok(NULL, &length); /* now read it */ local_node->paramkind = atoi(token); token = lsptok(NULL, &length); /* get :paramid */ token = lsptok(NULL, &length); /* now read it */ local_node->paramid = atol(token); token = lsptok(NULL, &length); /* get :paramname */ token = lsptok(NULL, &length); /* now read it */ if (length == 0) local_node->paramname = NULL; else { local_node->paramname = (char *) palloc(length + 1); StrNCpy(local_node->paramname, token, length + 1); } token = lsptok(NULL, &length); /* get :paramtype */ token = lsptok(NULL, &length); /* now read it */ local_node->paramtype = atol(token); token = lsptok(NULL, &length); /* get :param_tlist */ local_node->param_tlist = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readAggref * * Aggref is a subclass of Node * ---------------- */static Aggref *_readAggref(){ Aggref *local_node; char *token; int length; local_node = makeNode(Aggref); token = lsptok(NULL, &length); /* eat :aggname */ token = lsptok(NULL, &length); /* get aggname */ local_node->aggname = (char *) palloc(length + 1); StrNCpy(local_node->aggname, token, length + 1); token = lsptok(NULL, &length); /* eat :basetype */ token = lsptok(NULL, &length); /* get basetype */ local_node->basetype = (Oid) atol(token); token = lsptok(NULL, &length); /* eat :aggtype */ token = lsptok(NULL, &length); /* get aggtype */ local_node->aggtype = (Oid) atol(token); token = lsptok(NULL, &length); /* eat :target */ local_node->target = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* eat :aggno */ token = lsptok(NULL, &length); /* get aggno */ local_node->aggno = atoi(token); token = lsptok(NULL, &length); /* eat :usenulls */ token = lsptok(NULL, &length); /* get usenulls */ local_node->usenulls = (token[0] == 't') ? true : false; return local_node;}/* ---------------- * _readSubLink * * SubLink is a subclass of Node * ---------------- */static SubLink *_readSubLink(){ SubLink *local_node; char *token; int length; local_node = makeNode(SubLink); token = lsptok(NULL, &length); /* eat :subLinkType */ token = lsptok(NULL, &length); /* get subLinkType */ local_node->subLinkType = atoi(token); token = lsptok(NULL, &length); /* eat :useor */ token = lsptok(NULL, &length); /* get useor */ local_node->useor = (token[0] == 't') ? true : false; token = lsptok(NULL, &length); /* eat :lefthand */ local_node->lefthand = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* eat :oper */ local_node->oper = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* eat :subselect */ local_node->subselect = nodeRead(true); /* now read it */ return local_node;}/* * Stuff from execnodes.h *//* ---------------- * _readEState * * EState is a subclass of Node. * ---------------- */static EState *_readEState(){ EState *local_node; char *token; int length; local_node = makeNode(EState); token = lsptok(NULL, &length); /* get :direction */ token = lsptok(NULL, &length); /* now read it */ local_node->es_direction = atoi(token); token = lsptok(NULL, &length); /* get :range_table */ local_node->es_range_table = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :result_relation_info */ token = lsptok(NULL, &length); /* get @ */ token = lsptok(NULL, &length); /* now read it */ sscanf(token, "%x", (unsigned int *) &local_node->es_result_relation_info); return local_node;}/* * Stuff from relation.h *//* ---------------- * _readRelOptInfo * ---------------- */static RelOptInfo *_readRelOptInfo(){ RelOptInfo *local_node; char *token; int length; local_node = makeNode(RelOptInfo); token = lsptok(NULL, &length); /* get :relids */ local_node->relids = toIntList(nodeRead(true)); /* now read it */ token = lsptok(NULL, &length); /* get :indexed */ token = lsptok(NULL, &length); /* now read it */ if (!strncmp(token, "true", 4)) local_node->indexed = true; else local_node->indexed = false; token = lsptok(NULL, &length); /* get :pages */ token = lsptok(NULL, &length); /* now read it */ local_node->pages = (unsigned int) atoi(token); token = lsptok(NULL, &length); /* get :tuples */ token = lsptok(NULL, &length); /* now read it */ local_node->tuples = (unsigned int) atoi(token); token = lsptok(NULL, &length); /* get :size */ token = lsptok(NULL, &length); /* now read it */ local_node->size = (unsigned int) atoi(token); token = lsptok(NULL, &length); /* get :width */ token = lsptok(NULL, &length); /* now read it */ local_node->width = (unsigned int) atoi(token); token = lsptok(NULL, &length); /* get :targetlist */ local_node->targetlist = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathlist */ local_node->pathlist = nodeRead(true); /* now read it */ /* * Not sure if these are nodes or not. They're declared as struct * Path *. Since i don't know, i'll just print the addresses for now. * This can be changed later, if necessary. */ token = lsptok(NULL, &length); /* get :cheapestpath */ token = lsptok(NULL, &length); /* get @ */ token = lsptok(NULL, &length); /* now read it */ sscanf(token, "%x", (unsigned int *) &local_node->cheapestpath); token = lsptok(NULL, &length); /* get :restrictinfo */ local_node->restrictinfo = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :joininfo */ local_node->joininfo = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :innerjoin */ local_node->innerjoin = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readTargetEntry * ---------------- */static TargetEntry *_readTargetEntry(){ TargetEntry *local_node; char *token; int length; local_node = makeNode(TargetEntry); token = lsptok(NULL, &length); /* get :resdom */ local_node->resdom = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :expr */ local_node->expr = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readRangeTblEntry * ---------------- */static RangeTblEntry *_readRangeTblEntry(){ RangeTblEntry *local_node; char *token; int length; local_node = makeNode(RangeTblEntry); token = lsptok(NULL, &length); /* eat :relname */ token = lsptok(NULL, &length); /* get :relname */ if (length == 0) local_node->relname = NULL; else { local_node->relname = (char *) palloc(length + 1); StrNCpy(local_node->relname, token, length + 1); } token = lsptok(NULL, &length); /* eat :refname */ token = lsptok(NULL, &length); /* get :refname */ if (length == 0) local_node->refname = NULL; else { local_node->refname = (char *) palloc(length + 1); StrNCpy(local_node->refname, token, length + 1); } token = lsptok(NULL, &length); /* eat :relid */ token = lsptok(NULL, &length); /* get :relid */ local_node->relid = strtoul(token, NULL, 10); token = lsptok(NULL, &length); /* eat :inh */ token = lsptok(NULL, &length); /* get :inh */ local_node->inh = (token[0] == 't') ? true : false; token = lsptok(NULL, &length); /* eat :inFromCl */ token = lsptok(NULL, &length); /* get :inFromCl */ local_node->inFromCl = (token[0] == 't') ? true : false; token = lsptok(NULL, &length); /* eat :skipAcl */ token = lsptok(NULL, &length); /* get :skipAcl */ local_node->skipAcl = (token[0] == 't') ? true : false; return local_node;}static RowMark *_readRowMark(){ RowMark *local_node = makeNode(RowMark); char *token; int length; token = lsptok(NULL, &length); /* eat :rti */ token = lsptok(NULL, &length); /* get :rti */ local_node->rti = strtoul(token, NULL, 10); token = lsptok(NULL, &length); /* eat :info */ token = lsptok(NULL, &length); /* get :info */ local_node->info = strtoul(token, NULL, 10); return local_node;}/* ---------------- * _readPathOrder * * PathOrder is part of Path and it's subclasses. * ---------------- */static PathOrder *_readPathOrder(){ PathOrder *local_node; char *token; int length; local_node = makeNode(PathOrder); token = lsptok(NULL, &length); /* get :ordtype */ token = lsptok(NULL, &length); /* now read it */ local_node->ordtype = atol(token); if (local_node->ordtype == SORTOP_ORDER) { token = lsptok(NULL, &length); /* get :sortop */ if (length == 0) local_node->ord.sortop = NULL; else { int i = -1; local_node->ord.sortop = palloc(sizeof(Oid) * (INDEX_MAX_KEYS + 1)); do { i++; Assert(i <= INDEX_MAX_KEYS); token = lsptok(NULL, &length); /* now read it */ local_node->ord.sortop[i] = strtoul(token, NULL, 10); } while (local_node->ord.sortop[i] != 0); } } else { token = lsptok(NULL, &length); /* get :merge */ local_node->ord.merge = nodeRead(true); /* now read it */ } return local_node;}/* ---------------- * _readPath * * Path is a subclass of Node. * ---------------- */static Path *_readPath(){ Path *local_node; char *token; int length; local_node = makeNode(Path); token = lsptok(NULL, &length); /* get :pathtype */ token = lsptok(NULL, &length); /* now read it */ local_node->pathtype = atol(token); token = lsptok(NULL, &length); /* get :cost */ token = lsptok(NULL, &length); /* now read it */ local_node->path_cost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :pathorder */ local_node->pathorder = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathkeys */ local_node->pathkeys = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readIndexPath * * IndexPath is a subclass of Path. * ---------------- */static IndexPath *_readIndexPath(){ IndexPath *local_node; char *token; int length; local_node = makeNode(IndexPath); token = lsptok(NULL, &length); /* get :pathtype */ token = lsptok(NULL, &length); /* now read it */ local_node->path.pathtype = atol(token); token = lsptok(NULL, &length); /* get :cost */ token = lsptok(NULL, &length); /* now read it */ local_node->path.path_cost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :pathorder */ local_node->path.pathorder = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathkeys */ local_node->path.pathkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :indexid */ local_node->indexid = toIntList(nodeRead(true)); token = lsptok(NULL, &length); /* get :indexqual */ local_node->indexqual = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readNestPath * * NestPath is a subclass of Path * ---------------- */static NestPath *_readNestPath(){ NestPath *local_node; char *token; int length; local_node = makeNode(NestPath); token = lsptok(NULL, &length); /* get :pathtype */ token = lsptok(NULL, &length); /* now read it */ local_node->path.pathtype = atol(token); token = lsptok(NULL, &length); /* get :cost */ token = lsptok(NULL, &length); /* now read it */ local_node->path.path_cost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :pathorder */ local_node->path.pathorder = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathkeys */ local_node->path.pathkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathinfo */ local_node->pathinfo = nodeRead(true); /* now read it */ /* * Not sure if these are nodes; they're declared as "struct path *". * For now, i'll just print the addresses. * * GJK: Since I am parsing this stuff, I'll just ignore the addresses, * and initialize these pointers to NULL. */ token = lsptok(NULL, &length); /* get :outerjoinpath */ token = lsptok(NULL, &length); /* get @ */ token = lsptok(NULL, &length); /* now read it */ local_node->outerjoinpath = NULL; token = lsptok(NULL, &length); /* get :innerjoinpath */ token = lsptok(NULL, &length); /* get @ */ token = lsptok(NULL, &length); /* now read it */ local_node->innerjoinpath = NULL; token = lsptok(NULL, &length); /* get :outerjoincost */ token = lsptok(NULL, &length); /* now read it */ local_node->path.outerjoincost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :joinid */ local_node->path.joinid = toIntList(nodeRead(true)); /* now read it */ return local_node;}/* ---------------- * _readMergePath * * MergePath is a subclass of NestPath. * ---------------- */static MergePath *_readMergePath(){ MergePath *local_node; char *token; int length; local_node = makeNode(MergePath); token = lsptok(NULL, &length); /* get :pathtype */ token = lsptok(NULL, &length); /* now read it */ local_node->jpath.path.pathtype = atol(token); token = lsptok(NULL, &length); /* get :cost */ token = lsptok(NULL, &length); /* now read it */ local_node->jpath.path.path_cost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :pathorder */ local_node->jpath.path.pathorder = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathkeys */ local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathinfo */ local_node->jpath.pathinfo = nodeRead(true); /* now read it */ /* * Not sure if these are nodes; they're declared as "struct path *". * For now, i'll just print the addresses.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -