📄 readfuncs.c
字号:
* * 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->jpath.outerjoinpath = NULL; token = lsptok(NULL, &length); /* get :innerjoinpath */ token = lsptok(NULL, &length); /* get @ */ token = lsptok(NULL, &length); /* now read it */ local_node->jpath.innerjoinpath = NULL; token = lsptok(NULL, &length); /* get :outerjoincost */ token = lsptok(NULL, &length); /* now read it */ local_node->jpath.path.outerjoincost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :joinid */ local_node->jpath.path.joinid = toIntList(nodeRead(true)); /* now read it */ token = lsptok(NULL, &length); /* get :path_mergeclauses */ local_node->path_mergeclauses = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :outersortkeys */ local_node->outersortkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :innersortkeys */ local_node->innersortkeys = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readHashPath * * HashPath is a subclass of NestPath. * ---------------- */static HashPath *_readHashPath(){ HashPath *local_node; char *token; int length; local_node = makeNode(HashPath); 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. * * 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->jpath.outerjoinpath = NULL; token = lsptok(NULL, &length); /* get :innerjoinpath */ token = lsptok(NULL, &length); /* get @ */ token = lsptok(NULL, &length); /* now read it */ local_node->jpath.innerjoinpath = NULL; token = lsptok(NULL, &length); /* get :outerjoincost */ token = lsptok(NULL, &length); /* now read it */ local_node->jpath.path.outerjoincost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :joinid */ local_node->jpath.path.joinid = toIntList(nodeRead(true)); /* now read it */ token = lsptok(NULL, &length); /* get :path_hashclauses */ local_node->path_hashclauses = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :outerhashkeys */ local_node->outerhashkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :innerhashkeys */ local_node->innerhashkeys = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readOrderKey * * OrderKey is a subclass of Node. * ---------------- */static OrderKey *_readOrderKey(){ OrderKey *local_node; char *token; int length; local_node = makeNode(OrderKey); token = lsptok(NULL, &length); /* get :attribute_number */ token = lsptok(NULL, &length); /* now read it */ local_node->attribute_number = atoi(token); token = lsptok(NULL, &length); /* get :array_index */ token = lsptok(NULL, &length); /* now read it */ local_node->array_index = strtoul(token, NULL, 10); return local_node;}/* ---------------- * _readJoinKey * * JoinKey is a subclass of Node. * ---------------- */static JoinKey *_readJoinKey(){ JoinKey *local_node; char *token; int length; local_node = makeNode(JoinKey); token = lsptok(NULL, &length); /* get :outer */ local_node->outer = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :inner */ local_node->inner = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readMergeOrder * * MergeOrder is a subclass of Node. * ---------------- */static MergeOrder *_readMergeOrder(){ MergeOrder *local_node; char *token; int length; local_node = makeNode(MergeOrder); token = lsptok(NULL, &length); /* get :join_operator */ token = lsptok(NULL, &length); /* now read it */ local_node->join_operator = atol(token); token = lsptok(NULL, &length); /* get :left_operator */ token = lsptok(NULL, &length); /* now read it */ local_node->left_operator = atol(token); token = lsptok(NULL, &length); /* get :right_operator */ token = lsptok(NULL, &length); /* now read it */ local_node->right_operator = atol(token); token = lsptok(NULL, &length); /* get :left_type */ token = lsptok(NULL, &length); /* now read it */ local_node->left_type = atol(token); token = lsptok(NULL, &length); /* get :right_type */ token = lsptok(NULL, &length); /* now read it */ local_node->right_type = atol(token); return local_node;}/* ---------------- * _readRestrictInfo * * RestrictInfo is a subclass of Node. * ---------------- */static RestrictInfo *_readRestrictInfo(){ RestrictInfo *local_node; char *token; int length; local_node = makeNode(RestrictInfo); token = lsptok(NULL, &length); /* get :clause */ local_node->clause = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :selectivity */ token = lsptok(NULL, &length); /* now read it */ local_node->selectivity = atof(token); token = lsptok(NULL, &length); /* get :notclause */ token = lsptok(NULL, &length); /* now read it */ if (!strncmp(token, "true", 4)) local_node->notclause = true; else local_node->notclause = false; token = lsptok(NULL, &length); /* get :indexids */ local_node->indexids = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :mergejoinorder */ local_node->mergejoinorder = (MergeOrder *) nodeRead(true); token = lsptok(NULL, &length); /* get :hashjoinoperator */ token = lsptok(NULL, &length); /* now read it */ local_node->hashjoinoperator = atol(token); return local_node;}/* ---------------- * _readJoinMethod * * JoinMethod is a subclass of Node. * ---------------- */static JoinMethod *_readJoinMethod(){ JoinMethod *local_node; char *token; int length; local_node = makeNode(JoinMethod); token = lsptok(NULL, &length); /* get :jmkeys */ local_node->jmkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :clauses */ local_node->clauses = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readHashInfo * * HashInfo is a subclass of JoinMethod. * ---------------- */static HashInfo *_readHashInfo(){ HashInfo *local_node; char *token; int length; local_node = makeNode(HashInfo); token = lsptok(NULL, &length); /* get :hashop */ token = lsptok(NULL, &length); /* now read it */ local_node->hashop = strtoul(token, NULL, 10); token = lsptok(NULL, &length); /* get :jmkeys */ local_node->jmethod.jmkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :clauses */ local_node->jmethod.clauses = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * _readJoinInfo() * * JoinInfo is a subclass of Node. * ---------------- */static JoinInfo *_readJoinInfo(){ JoinInfo *local_node; char *token; int length; local_node = makeNode(JoinInfo); token = lsptok(NULL, &length); /* get :unjoined_relids */ local_node->unjoined_relids = toIntList(nodeRead(true)); /* now read it */ token = lsptok(NULL, &length); /* get :jinfo_restrictinfo */ local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :mergejoinable */ if (!strncmp(token, "true", 4)) local_node->mergejoinable = true; else local_node->mergejoinable = false; token = lsptok(NULL, &length); /* get :hashjoinable */ if (!strncmp(token, "true", 4)) local_node->hashjoinable = true; else local_node->hashjoinable = false; return local_node;}/* ---------------- * _readIter() * * ---------------- */static Iter *_readIter(){ Iter *local_node; char *token; int length; local_node = makeNode(Iter); token = lsptok(NULL, &length); /* eat :iterexpr */ local_node->iterexpr = nodeRead(true); /* now read it */ return local_node;}/* ---------------- * parsePlanString * * Given a character string containing a plan, parsePlanString sets up the * plan structure representing that plan. * * The string passed to parsePlanString must be null-terminated. * ---------------- */Node *parsePlanString(void){ char *token; int length; void *return_value = NULL; token = lsptok(NULL, &length); if (!strncmp(token, "PLAN", length)) return_value = _readPlan(); else if (!strncmp(token, "RESULT", length)) return_value = _readResult(); else if (!strncmp(token, "APPEND", length)) return_value = _readAppend(); else if (!strncmp(token, "JOIN", length)) return_value = _readJoin(); else if (!strncmp(token, "NESTLOOP", length)) return_value = _readNestLoop(); else if (!strncmp(token, "MERGEJOIN", length)) return_value = _readMergeJoin(); else if (!strncmp(token, "HASHJOIN", length)) return_value = _readHashJoin(); else if (!strncmp(token, "SCAN", length)) return_value = _readScan(); else if (!strncmp(token, "SEQSCAN", length)) return_value = _readSeqScan(); else if (!strncmp(token, "INDEXSCAN", length)) return_value = _readIndexScan(); else if (!strncmp(token, "NONAME", length)) return_value = _readNoname(); else if (!strncmp(token, "SORT", length)) return_value = _readSort(); else if (!strncmp(token, "AGGREG", length)) return_value = _readAggref(); else if (!strncmp(token, "SUBLINK", length)) return_value = _readSubLink(); else if (!strncmp(token, "AGG", length)) return_value = _readAgg(); else if (!strncmp(token, "UNIQUE", length)) return_value = _readUnique(); else if (!strncmp(token, "HASH", length)) return_value = _readHash(); else if (!strncmp(token, "RESDOM", length)) return_value = _readResdom(); else if (!strncmp(token, "EXPR", length)) return_value = _readExpr(); else if (!strncmp(token, "ARRAYREF", length)) return_value = _readArrayRef(); else if (!strncmp(token, "ARRAY", length)) return_value = _readArray(); else if (!strncmp(token, "VAR", length)) return_value = _readVar(); else if (!strncmp(token, "CONST", length)) return_value = _readConst(); else if (!strncmp(token, "FUNC", length)) return_value = _readFunc(); else if (!strncmp(token, "OPER", length)) return_value = _readOper(); else if (!strncmp(token, "PARAM", length)) return_value = _readParam(); else if (!strncmp(token, "ESTATE", length)) return_value = _readEState(); else if (!strncmp(token, "RELOPTINFO", length)) return_value = _readRelOptInfo(); else if (!strncmp(token, "TARGETENTRY", length)) return_value = _readTargetEntry(); else if (!strncmp(token, "RTE", length)) return_value = _readRangeTblEntry(); else if (!strncmp(token, "PATHORDER", length)) return_value = _readPathOrder(); else if (!strncmp(token, "PATH", length)) return_value = _readPath(); else if (!strncmp(token, "INDEXPATH", length)) return_value = _readIndexPath(); else if (!strncmp(token, "NESTPATH", length)) return_value = _readNestPath(); else if (!strncmp(token, "MERGEPATH", length)) return_value = _readMergePath(); else if (!strncmp(token, "HASHPATH", length)) return_value = _readHashPath(); else if (!strncmp(token, "ORDERKEY", length)) return_value = _readOrderKey(); else if (!strncmp(token, "JOINKEY", length)) return_value = _readJoinKey(); else if (!strncmp(token, "MERGEORDER", length)) return_value = _readMergeOrder(); else if (!strncmp(token, "RETRICTINFO", length)) return_value = _readRestrictInfo(); else if (!strncmp(token, "JOINMETHOD", length)) return_value = _readJoinMethod(); else if (!strncmp(token, "JOININFO", length)) return_value = _readJoinInfo(); else if (!strncmp(token, "HASHINFO", length)) return_value = _readHashInfo(); else if (!strncmp(token, "ITER", length)) return_value = _readIter(); else if (!strncmp(token, "QUERY", length)) return_value = _readQuery(); else if (!strncmp(token, "SORTCLAUSE", length)) return_value = _readSortClause(); else if (!strncmp(token, "GROUPCLAUSE", length)) return_value = _readGroupClause(); else if (!strncmp(token, "CASE", length)) return_value = _readCaseExpr(); else if (!strncmp(token, "WHEN", length)) return_value = _readCaseWhen(); else if (!strncmp(token, "ROWMARK", length)) return_value = _readRowMark(); else elog(ERROR, "badly formatted planstring \"%.10s\"...\n", token); return (Node *) return_value;}/*------------------------------------------------------------*//* ---------------- * readDatum * * given a string representation of the value of the given type, * create the appropriate Datum * ---------------- */static DatumreadDatum(Oid type){ int length; int tokenLength; char *token; bool byValue; Datum res; char *s; int i; byValue = get_typbyval(type); /* * read the actual length of the value */ token = lsptok(NULL, &tokenLength); length = atoi(token); token = lsptok(NULL, &tokenLength); /* skip the '[' */ if (byValue) { if (length > sizeof(Datum)) elog(ERROR, "readValue: byval & length = %d", length); s = (char *) (&res); for (i = 0; i < sizeof(Datum); i++) { token = lsptok(NULL, &tokenLength); s[i] = (char) atoi(token); } } else if (length <= 0) s = NULL; else if (length >= 1) { s = (char *) palloc(length); Assert(s != NULL); for (i = 0; i < length; i++) { token = lsptok(NULL, &tokenLength); s[i] = (char) atoi(token); } res = PointerGetDatum(s); } token = lsptok(NULL, &tokenLength); /* skip the ']' */ if (token[0] != ']') elog(ERROR, "readValue: ']' expected, length =%d", length); return res;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -