1 /*-------------------------------------------------------------------------
4 * Reader functions for Postgres tree nodes.
6 * Copyright (c) 1994, Regents of the University of California
10 * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.54 1999/02/11 14:58:49 momjian Exp $
13 * Most of the read functions for plan nodes are tested. (In fact, they
14 * pass the regression test as of 11/8/94.) The rest (for path selection)
15 * are probably never used. No effort has been made to get them to work.
16 * The simplest way to test these functions is by doing the following in
17 * ProcessQuery (before executing the plan):
18 * plan = stringToNode(nodeToString(plan));
19 * Then, run the regression test. Let's just say you'll notice if either
20 * of the above function are not properly done.
23 *-------------------------------------------------------------------------
31 #include "access/heapam.h"
32 #include "access/htup.h"
34 #include "utils/builtins.h"
35 #include "utils/elog.h"
36 #include "utils/palloc.h"
38 #include "utils/lsyscache.h"
39 #include "utils/syscache.h"
40 #include "catalog/pg_index.h"
41 #include "catalog/pg_type.h"
43 #include "nodes/primnodes.h"
44 #include "nodes/plannodes.h"
45 #include "nodes/parsenodes.h"
46 #include "nodes/execnodes.h"
47 #include "nodes/relation.h"
48 #include "nodes/readfuncs.h"
51 * node creator declarations
55 static Datum readDatum(Oid type);
64 /* ugly manipulation, should probably free the Value node too */
65 lfirst(l) = (void *) intVal(lfirst(l));
81 local_node = makeNode(Query);
83 token = lsptok(NULL, &length); /* skip the :command */
84 token = lsptok(NULL, &length); /* get the commandType */
85 local_node->commandType = atoi(token);
87 token = lsptok(NULL, &length); /* skip :utility */
88 /* we can't get create or index here, can we? */
90 token = lsptok(NULL, &length); /* get the notify name if any */
92 local_node->utilityStmt = NULL;
95 NotifyStmt *n = makeNode(NotifyStmt);
97 n->relname = palloc(length + 1);
98 StrNCpy(n->relname, token, length + 1);
99 local_node->utilityStmt = (Node *) n;
102 token = lsptok(NULL, &length); /* skip the :resultRelation */
103 token = lsptok(NULL, &length); /* get the resultRelation */
104 local_node->resultRelation = atoi(token);
106 token = lsptok(NULL, &length); /* skip :into */
107 token = lsptok(NULL, &length); /* get into */
109 local_node->into = NULL;
112 local_node->into = palloc(length + 1);
113 StrNCpy(local_node->into, token, length + 1);
116 token = lsptok(NULL, &length); /* skip :isPortal */
117 token = lsptok(NULL, &length); /* get isPortal */
118 local_node->isPortal = (token[0] == 't') ? true : false;
120 token = lsptok(NULL, &length); /* skip :isBinary */
121 token = lsptok(NULL, &length); /* get isBinary */
122 local_node->isBinary = (token[0] == 't') ? true : false;
124 token = lsptok(NULL, &length); /* skip :isTemp */
125 token = lsptok(NULL, &length); /* get isTemp */
126 local_node->isTemp = (token[0] == 't') ? true : false;
128 token = lsptok(NULL, &length); /* skip :unionall */
129 token = lsptok(NULL, &length); /* get unionall */
130 local_node->unionall = (token[0] == 't') ? true : false;
132 token = lsptok(NULL, &length); /* skip :uniqueFlag */
133 token = lsptok(NULL, &length); /* get uniqueFlag */
135 local_node->uniqueFlag = NULL;
138 local_node->uniqueFlag = palloc(length + 1);
139 StrNCpy(local_node->uniqueFlag, token, length + 1);
142 token = lsptok(NULL, &length); /* skip :sortClause */
143 local_node->sortClause = nodeRead(true);
145 token = lsptok(NULL, &length); /* skip :rtable */
146 local_node->rtable = nodeRead(true);
148 token = lsptok(NULL, &length); /* skip :targetlist */
149 local_node->targetList = nodeRead(true);
151 token = lsptok(NULL, &length); /* skip :qual */
152 local_node->qual = nodeRead(true);
154 token = lsptok(NULL, &length); /* skip :groupClause */
155 local_node->groupClause = nodeRead(true);
157 token = lsptok(NULL, &length); /* skip :havingQual */
158 local_node->havingQual = nodeRead(true);
160 token = lsptok(NULL, &length); /* skip the :hasAggs */
161 token = lsptok(NULL, &length); /* get hasAggs */
162 local_node->hasAggs = (token[0] == 't') ? true : false;
164 token = lsptok(NULL, &length); /* skip the :hasSubLinks */
165 token = lsptok(NULL, &length); /* get hasSubLinks */
166 local_node->hasSubLinks = (token[0] == 't') ? true : false;
168 token = lsptok(NULL, &length); /* skip :unionClause */
169 local_node->unionClause = nodeRead(true);
172 token = lsptok(NULL, &length); /* skip :intersectClause */
173 local_node->intersectClause = nodeRead(true);
176 token = lsptok(NULL, &length); /* skip :limitOffset */
177 local_node->limitOffset = nodeRead(true);
179 token = lsptok(NULL, &length); /* skip :limitCount */
180 local_node->limitCount = nodeRead(true);
182 token = lsptok(NULL, &length); /* skip :rowMark */
183 local_node->rowMark = nodeRead(true);
195 SortClause *local_node;
199 local_node = makeNode(SortClause);
201 token = lsptok(NULL, &length); /* skip the :resdom */
202 local_node->resdom = nodeRead(true);
204 token = lsptok(NULL, &length); /* skip :opoid */
205 token = lsptok(NULL, &length); /* get opoid */
206 local_node->opoid = strtoul(token, NULL, 10);
218 GroupClause *local_node;
222 local_node = makeNode(GroupClause);
224 token = lsptok(NULL, &length); /* skip the :entry */
225 local_node->entry = nodeRead(true);
227 token = lsptok(NULL, &length); /* skip :grpOpoid */
228 token = lsptok(NULL, &length); /* get grpOpoid */
229 local_node->grpOpoid = strtoul(token, NULL, 10);
244 token = lsptok(NULL, &length); /* first token is :cost */
245 token = lsptok(NULL, &length); /* next is the actual cost */
246 node->cost = (Cost) atof(token);
248 token = lsptok(NULL, &length); /* skip the :size */
249 token = lsptok(NULL, &length); /* get the plan_size */
250 node->plan_size = atoi(token);
252 token = lsptok(NULL, &length); /* skip the :width */
253 token = lsptok(NULL, &length); /* get the plan_width */
254 node->plan_width = atoi(token);
256 token = lsptok(NULL, &length); /* eat the :state stuff */
257 token = lsptok(NULL, &length); /* now get the state */
260 node->state = (EState *) NULL;
262 { /* Disgusting hack until I figure out what
264 node->state = (EState *) !NULL;
267 token = lsptok(NULL, &length); /* eat :qptargetlist */
268 node->targetlist = nodeRead(true);
270 token = lsptok(NULL, &length); /* eat :qpqual */
271 node->qual = nodeRead(true);
273 token = lsptok(NULL, &length); /* eat :lefttree */
274 node->lefttree = (Plan *) nodeRead(true);
276 token = lsptok(NULL, &length); /* eat :righttree */
277 node->righttree = (Plan *) nodeRead(true);
283 * Stuff from plannodes.h
295 local_node = makeNode(Plan);
297 _getPlan(local_node);
305 * Does some obscene, possibly unportable, magic with
316 local_node = makeNode(Result);
318 _getPlan((Plan *) local_node);
320 token = lsptok(NULL, &length); /* eat :resconstantqual */
321 local_node->resconstantqual = nodeRead(true); /* now read it */
329 * Append is a subclass of Plan.
340 local_node = makeNode(Append);
342 _getPlan((Plan *) local_node);
344 token = lsptok(NULL, &length); /* eat :appendplans */
345 local_node->appendplans = nodeRead(true); /* now read it */
347 token = lsptok(NULL, &length); /* eat :unionrtables */
348 local_node->unionrtables = nodeRead(true); /* now read it */
350 token = lsptok(NULL, &length); /* eat :inheritrelid */
351 token = lsptok(NULL, &length); /* get inheritrelid */
352 local_node->inheritrelid = strtoul(token, NULL, 10);
354 token = lsptok(NULL, &length); /* eat :inheritrtable */
355 local_node->inheritrtable = nodeRead(true); /* now read it */
363 * In case Join is not the same structure as Plan someday.
369 _getPlan((Plan *) node);
376 * Join is a subclass of Plan
384 local_node = makeNode(Join);
386 _getJoin(local_node);
394 * NestLoop is a subclass of Join
401 NestLoop *local_node;
403 local_node = makeNode(NestLoop);
405 _getJoin((Join *) local_node);
413 * MergeJoin is a subclass of Join
419 MergeJoin *local_node;
423 local_node = makeNode(MergeJoin);
425 _getJoin((Join *) local_node);
426 token = lsptok(NULL, &length); /* eat :mergeclauses */
427 local_node->mergeclauses = nodeRead(true); /* now read it */
429 token = lsptok(NULL, &length); /* eat :mergejoinop */
430 token = lsptok(NULL, &length); /* get mergejoinop */
431 local_node->mergejoinop = atol(token);
439 * HashJoin is a subclass of Join.
445 HashJoin *local_node;
449 local_node = makeNode(HashJoin);
451 _getJoin((Join *) local_node);
453 token = lsptok(NULL, &length); /* eat :hashclauses */
454 local_node->hashclauses = nodeRead(true); /* now read it */
456 token = lsptok(NULL, &length); /* eat :hashjoinop */
457 token = lsptok(NULL, &length); /* get hashjoinop */
458 local_node->hashjoinop = strtoul(token, NULL, 10);
460 token = lsptok(NULL, &length); /* eat :hashjointable */
461 token = lsptok(NULL, &length); /* eat hashjointable */
462 local_node->hashjointable = NULL;
464 token = lsptok(NULL, &length); /* eat :hashjointablekey */
465 token = lsptok(NULL, &length); /* eat hashjointablekey */
466 local_node->hashjointablekey = 0;
468 token = lsptok(NULL, &length); /* eat :hashjointablesize */
469 token = lsptok(NULL, &length); /* eat hashjointablesize */
470 local_node->hashjointablesize = 0;
472 token = lsptok(NULL, &length); /* eat :hashdone */
473 token = lsptok(NULL, &length); /* eat hashdone */
474 local_node->hashdone = false;
482 * Scan is a subclass of Node
483 * (Actually, according to the plannodes.h include file, it is a
484 * subclass of Plan. This is why _getPlan is used here.)
486 * Scan gets its own get function since stuff inherits it.
495 _getPlan((Plan *) node);
497 token = lsptok(NULL, &length); /* eat :scanrelid */
498 token = lsptok(NULL, &length); /* get scanrelid */
499 node->scanrelid = strtoul(token, NULL, 10);
505 * Scan is a subclass of Plan (Not Node, see above).
513 local_node = makeNode(Scan);
515 _getScan(local_node);
523 * SeqScan is a subclass of Scan
531 local_node = makeNode(SeqScan);
533 _getScan((Scan *) local_node);
541 * IndexScan is a subclass of Scan
547 IndexScan *local_node;
551 local_node = makeNode(IndexScan);
553 _getScan((Scan *) local_node);
555 token = lsptok(NULL, &length); /* eat :indxid */
556 local_node->indxid = toIntList(nodeRead(true)); /* now read it */
558 token = lsptok(NULL, &length); /* eat :indxqual */
559 local_node->indxqual = nodeRead(true); /* now read it */
561 token = lsptok(NULL, &length); /* eat :indxqualorig */
562 local_node->indxqualorig = nodeRead(true); /* now read it */
570 * Noname is a subclass of Plan
580 local_node = makeNode(Noname);
582 _getPlan((Plan *) local_node);
584 token = lsptok(NULL, &length); /* eat :nonameid */
585 token = lsptok(NULL, &length); /* get nonameid */
586 local_node->nonameid = atol(token);
588 token = lsptok(NULL, &length); /* eat :keycount */
589 token = lsptok(NULL, &length); /* get keycount */
590 local_node->keycount = atoi(token);
598 * Sort is a subclass of Noname
608 local_node = makeNode(Sort);
610 _getPlan((Plan *) local_node);
612 token = lsptok(NULL, &length); /* eat :nonameid */
613 token = lsptok(NULL, &length); /* get nonameid */
614 local_node->nonameid = atol(token);
616 token = lsptok(NULL, &length); /* eat :keycount */
617 token = lsptok(NULL, &length); /* get keycount */
618 local_node->keycount = atoi(token);
630 local_node = makeNode(Agg);
631 _getPlan((Plan *) local_node);
633 token = lsptok(NULL, &length); /* eat :agg */
634 local_node->aggs = nodeRead(true); /* now read it */
642 * For some reason, unique is a subclass of Noname.
651 local_node = makeNode(Unique);
653 _getPlan((Plan *) local_node);
655 token = lsptok(NULL, &length); /* eat :nonameid */
656 token = lsptok(NULL, &length); /* get :nonameid */
657 local_node->nonameid = atol(token);
659 token = lsptok(NULL, &length); /* eat :keycount */
660 token = lsptok(NULL, &length); /* get :keycount */
661 local_node->keycount = atoi(token);
669 * Hash is a subclass of Noname
679 local_node = makeNode(Hash);
681 _getPlan((Plan *) local_node);
683 token = lsptok(NULL, &length); /* eat :hashkey */
684 local_node->hashkey = (Var *) nodeRead(true);
686 token = lsptok(NULL, &length); /* eat :hashtable */
687 token = lsptok(NULL, &length); /* eat hashtable address */
688 local_node->hashtable = NULL;
690 token = lsptok(NULL, &length); /* eat :hashtablekey */
691 token = lsptok(NULL, &length); /* get hashtablekey */
692 local_node->hashtablekey = 0;
694 token = lsptok(NULL, &length); /* eat :hashtablesize */
695 token = lsptok(NULL, &length); /* get hashtablesize */
696 local_node->hashtablesize = 0;
702 * Stuff from primnodes.h.
708 * Resdom is a subclass of Node
718 local_node = makeNode(Resdom);
720 token = lsptok(NULL, &length); /* eat :resno */
721 token = lsptok(NULL, &length); /* get resno */
722 local_node->resno = atoi(token);
724 token = lsptok(NULL, &length); /* eat :restype */
725 token = lsptok(NULL, &length); /* get restype */
726 local_node->restype = atol(token);
728 token = lsptok(NULL, &length); /* eat :restypmod */
729 token = lsptok(NULL, &length); /* get restypmod */
730 local_node->restypmod = atoi(token);
732 token = lsptok(NULL, &length); /* eat :resname */
733 token = lsptok(NULL, &length); /* get the name */
736 local_node->resname = NULL;
739 local_node->resname = (char *) palloc(length + 1);
740 StrNCpy(local_node->resname, token + 1, length + 1 - 2); /* strip quotes */
743 token = lsptok(NULL, &length); /* eat :reskey */
744 token = lsptok(NULL, &length); /* get reskey */
745 local_node->reskey = strtoul(token, NULL, 10);
747 token = lsptok(NULL, &length); /* eat :reskeyop */
748 token = lsptok(NULL, &length); /* get reskeyop */
749 local_node->reskeyop = (Oid) atol(token);
751 token = lsptok(NULL, &length); /* eat :resjunk */
752 token = lsptok(NULL, &length); /* get resjunk */
753 local_node->resjunk = atoi(token);
761 * Expr is a subclass of Node
771 local_node = makeNode(Expr);
773 token = lsptok(NULL, &length); /* eat :typeOid */
774 token = lsptok(NULL, &length); /* get typeOid */
775 local_node->typeOid = (Oid) atol(token);
777 token = lsptok(NULL, &length); /* eat :opType */
778 token = lsptok(NULL, &length); /* get opType */
779 if (!strncmp(token, "op", 2))
780 local_node->opType = OP_EXPR;
781 else if (!strncmp(token, "func", 4))
782 local_node->opType = FUNC_EXPR;
783 else if (!strncmp(token, "or", 2))
784 local_node->opType = OR_EXPR;
785 else if (!strncmp(token, "and", 3))
786 local_node->opType = AND_EXPR;
787 else if (!strncmp(token, "not", 3))
788 local_node->opType = NOT_EXPR;
789 else if (!strncmp(token, "subp", 4))
790 local_node->opType = SUBPLAN_EXPR;
792 token = lsptok(NULL, &length); /* eat :oper */
793 local_node->oper = nodeRead(true);
795 token = lsptok(NULL, &length); /* eat :args */
796 local_node->args = nodeRead(true); /* now read it */
804 * CaseExpr is a subclass of Node
810 CaseExpr *local_node;
814 local_node = makeNode(CaseExpr);
816 local_node->args = nodeRead(true);
817 token = lsptok(NULL, &length); /* eat :default */
818 local_node->defresult = nodeRead(true);
826 * CaseWhen is a subclass of Node
832 CaseWhen *local_node;
836 local_node = makeNode(CaseWhen);
838 local_node->expr = nodeRead(true);
839 token = lsptok(NULL, &length); /* eat :then */
840 local_node->result = nodeRead(true);
848 * Var is a subclass of Expr
858 local_node = makeNode(Var);
860 token = lsptok(NULL, &length); /* eat :varno */
861 token = lsptok(NULL, &length); /* get varno */
862 local_node->varno = strtoul(token, NULL, 10);
864 token = lsptok(NULL, &length); /* eat :varattno */
865 token = lsptok(NULL, &length); /* get varattno */
866 local_node->varattno = atoi(token);
868 token = lsptok(NULL, &length); /* eat :vartype */
869 token = lsptok(NULL, &length); /* get vartype */
870 local_node->vartype = (Oid) atol(token);
872 token = lsptok(NULL, &length); /* eat :vartypmod */
873 token = lsptok(NULL, &length); /* get vartypmod */
874 local_node->vartypmod = atoi(token);
876 token = lsptok(NULL, &length); /* eat :varlevelsup */
877 token = lsptok(NULL, &length); /* get varlevelsup */
878 local_node->varlevelsup = (Oid) atol(token);
880 token = lsptok(NULL, &length); /* eat :varnoold */
881 token = lsptok(NULL, &length); /* get varnoold */
882 local_node->varnoold = (Oid) atol(token);
884 token = lsptok(NULL, &length); /* eat :varoattno */
885 token = lsptok(NULL, &length); /* eat :varoattno */
886 local_node->varoattno = (int) atol(token);
894 * Array is a subclass of Expr
904 local_node = makeNode(Array);
906 token = lsptok(NULL, &length); /* eat :arrayelemtype */
907 token = lsptok(NULL, &length); /* get arrayelemtype */
908 local_node->arrayelemtype = strtoul(token, NULL, 10);
910 token = lsptok(NULL, &length); /* eat :arrayelemlength */
911 token = lsptok(NULL, &length); /* get arrayelemlength */
912 local_node->arrayelemlength = atoi(token);
914 token = lsptok(NULL, &length); /* eat :arrayelembyval */
915 token = lsptok(NULL, &length); /* get arrayelembyval */
916 local_node->arrayelembyval = (token[0] == 't') ? true : false;
918 token = lsptok(NULL, &length); /* eat :arraylow */
919 token = lsptok(NULL, &length); /* get arraylow */
920 local_node->arraylow.indx[0] = atoi(token);
922 token = lsptok(NULL, &length); /* eat :arrayhigh */
923 token = lsptok(NULL, &length); /* get arrayhigh */
924 local_node->arrayhigh.indx[0] = atoi(token);
926 token = lsptok(NULL, &length); /* eat :arraylen */
927 token = lsptok(NULL, &length); /* get arraylen */
928 local_node->arraylen = atoi(token);
936 * ArrayRef is a subclass of Expr
942 ArrayRef *local_node;
946 local_node = makeNode(ArrayRef);
948 token = lsptok(NULL, &length); /* eat :refelemtype */
949 token = lsptok(NULL, &length); /* get refelemtype */
950 local_node->refelemtype = strtoul(token, NULL, 10);
952 token = lsptok(NULL, &length); /* eat :refattrlength */
953 token = lsptok(NULL, &length); /* get refattrlength */
954 local_node->refattrlength = atoi(token);
956 token = lsptok(NULL, &length); /* eat :refelemlength */
957 token = lsptok(NULL, &length); /* get refelemlength */
958 local_node->refelemlength = atoi(token);
960 token = lsptok(NULL, &length); /* eat :refelembyval */
961 token = lsptok(NULL, &length); /* get refelembyval */
962 local_node->refelembyval = (token[0] == 't') ? true : false;
964 token = lsptok(NULL, &length); /* eat :refupperindex */
965 local_node->refupperindexpr = nodeRead(true);
967 token = lsptok(NULL, &length); /* eat :reflowerindex */
968 local_node->reflowerindexpr = nodeRead(true);
970 token = lsptok(NULL, &length); /* eat :refexpr */
971 local_node->refexpr = nodeRead(true);
973 token = lsptok(NULL, &length); /* eat :refassgnexpr */
974 local_node->refassgnexpr = nodeRead(true);
982 * Const is a subclass of Expr
992 local_node = makeNode(Const);
994 token = lsptok(NULL, &length); /* get :consttype */
995 token = lsptok(NULL, &length); /* now read it */
996 local_node->consttype = atol(token);
999 token = lsptok(NULL, &length); /* get :constlen */
1000 token = lsptok(NULL, &length); /* now read it */
1001 local_node->constlen = strtol(token, NULL, 10);
1003 token = lsptok(NULL, &length); /* get :constisnull */
1004 token = lsptok(NULL, &length); /* now read it */
1006 if (!strncmp(token, "true", 4))
1007 local_node->constisnull = true;
1009 local_node->constisnull = false;
1012 token = lsptok(NULL, &length); /* get :constvalue */
1014 if (local_node->constisnull)
1016 token = lsptok(NULL, &length); /* skip "NIL" */
1024 local_node->constvalue = readDatum(local_node->consttype);
1027 token = lsptok(NULL, &length); /* get :constbyval */
1028 token = lsptok(NULL, &length); /* now read it */
1030 if (!strncmp(token, "true", 4))
1031 local_node->constbyval = true;
1033 local_node->constbyval = false;
1041 * Func is a subclass of Expr
1051 local_node = makeNode(Func);
1053 token = lsptok(NULL, &length); /* get :funcid */
1054 token = lsptok(NULL, &length); /* now read it */
1055 local_node->funcid = atol(token);
1057 token = lsptok(NULL, &length); /* get :functype */
1058 token = lsptok(NULL, &length); /* now read it */
1059 local_node->functype = atol(token);
1061 token = lsptok(NULL, &length); /* get :funcisindex */
1062 token = lsptok(NULL, &length); /* now read it */
1064 if (!strncmp(token, "true", 4))
1065 local_node->funcisindex = true;
1067 local_node->funcisindex = false;
1069 token = lsptok(NULL, &length); /* get :funcsize */
1070 token = lsptok(NULL, &length); /* now read it */
1071 local_node->funcsize = atol(token);
1073 token = lsptok(NULL, &length); /* get :func_fcache */
1074 token = lsptok(NULL, &length); /* get @ */
1075 token = lsptok(NULL, &length); /* now read it */
1077 local_node->func_fcache = (FunctionCache *) NULL;
1079 token = lsptok(NULL, &length); /* get :func_tlist */
1080 local_node->func_tlist = nodeRead(true); /* now read it */
1082 token = lsptok(NULL, &length); /* get :func_planlist */
1083 local_node->func_planlist = nodeRead(true); /* now read it */
1091 * Oper is a subclass of Expr
1101 local_node = makeNode(Oper);
1103 token = lsptok(NULL, &length); /* get :opno */
1104 token = lsptok(NULL, &length); /* now read it */
1105 local_node->opno = atol(token);
1107 token = lsptok(NULL, &length); /* get :opid */
1108 token = lsptok(NULL, &length); /* now read it */
1109 local_node->opid = atol(token);
1111 token = lsptok(NULL, &length); /* get :opresulttype */
1112 token = lsptok(NULL, &length); /* now read it */
1113 local_node->opresulttype = atol(token);
1116 * NOTE: Alternatively we can call 'replace_opid' which initializes
1117 * both 'opid' and 'op_fcache'.
1119 local_node->op_fcache = (FunctionCache *) NULL;
1127 * Param is a subclass of Expr
1137 local_node = makeNode(Param);
1139 token = lsptok(NULL, &length); /* get :paramkind */
1140 token = lsptok(NULL, &length); /* now read it */
1141 local_node->paramkind = atoi(token);
1143 token = lsptok(NULL, &length); /* get :paramid */
1144 token = lsptok(NULL, &length); /* now read it */
1145 local_node->paramid = atol(token);
1147 token = lsptok(NULL, &length); /* get :paramname */
1148 token = lsptok(NULL, &length); /* now read it */
1150 local_node->paramname = NULL;
1153 local_node->paramname = (char *) palloc(length + 1);
1154 StrNCpy(local_node->paramname, token, length + 1);
1157 token = lsptok(NULL, &length); /* get :paramtype */
1158 token = lsptok(NULL, &length); /* now read it */
1160 local_node->paramtype = atol(token);
1161 token = lsptok(NULL, &length); /* get :param_tlist */
1162 local_node->param_tlist = nodeRead(true); /* now read it */
1170 * Aggref is a subclass of Node
1180 local_node = makeNode(Aggref);
1182 token = lsptok(NULL, &length); /* eat :aggname */
1183 token = lsptok(NULL, &length); /* get aggname */
1184 local_node->aggname = (char *) palloc(length + 1);
1185 StrNCpy(local_node->aggname, token, length + 1);
1187 token = lsptok(NULL, &length); /* eat :basetype */
1188 token = lsptok(NULL, &length); /* get basetype */
1189 local_node->basetype = (Oid) atol(token);
1191 token = lsptok(NULL, &length); /* eat :aggtype */
1192 token = lsptok(NULL, &length); /* get aggtype */
1193 local_node->aggtype = (Oid) atol(token);
1195 token = lsptok(NULL, &length); /* eat :target */
1196 local_node->target = nodeRead(true); /* now read it */
1198 token = lsptok(NULL, &length); /* eat :aggno */
1199 token = lsptok(NULL, &length); /* get aggno */
1200 local_node->aggno = atoi(token);
1202 token = lsptok(NULL, &length); /* eat :usenulls */
1203 token = lsptok(NULL, &length); /* get usenulls */
1204 local_node->usenulls = (token[0] == 't') ? true : false;
1212 * SubLink is a subclass of Node
1218 SubLink *local_node;
1222 local_node = makeNode(SubLink);
1224 token = lsptok(NULL, &length); /* eat :subLinkType */
1225 token = lsptok(NULL, &length); /* get subLinkType */
1226 local_node->subLinkType = atoi(token);
1228 token = lsptok(NULL, &length); /* eat :useor */
1229 token = lsptok(NULL, &length); /* get useor */
1230 local_node->useor = (token[0] == 't') ? true : false;
1232 token = lsptok(NULL, &length); /* eat :lefthand */
1233 local_node->lefthand = nodeRead(true); /* now read it */
1235 token = lsptok(NULL, &length); /* eat :oper */
1236 local_node->oper = nodeRead(true); /* now read it */
1238 token = lsptok(NULL, &length); /* eat :subselect */
1239 local_node->subselect = nodeRead(true); /* now read it */
1245 * Stuff from execnodes.h
1251 * EState is a subclass of Node.
1261 local_node = makeNode(EState);
1263 token = lsptok(NULL, &length); /* get :direction */
1264 token = lsptok(NULL, &length); /* now read it */
1266 local_node->es_direction = atoi(token);
1268 token = lsptok(NULL, &length); /* get :range_table */
1270 local_node->es_range_table = nodeRead(true); /* now read it */
1272 token = lsptok(NULL, &length); /* get :result_relation_info */
1273 token = lsptok(NULL, &length); /* get @ */
1274 token = lsptok(NULL, &length); /* now read it */
1276 sscanf(token, "%x", (unsigned int *) &local_node->es_result_relation_info);
1282 * Stuff from relation.h
1292 RelOptInfo *local_node;
1296 local_node = makeNode(RelOptInfo);
1298 token = lsptok(NULL, &length); /* get :relids */
1299 local_node->relids = toIntList(nodeRead(true)); /* now read it */
1301 token = lsptok(NULL, &length); /* get :indexed */
1302 token = lsptok(NULL, &length); /* now read it */
1304 if (!strncmp(token, "true", 4))
1305 local_node->indexed = true;
1307 local_node->indexed = false;
1309 token = lsptok(NULL, &length); /* get :pages */
1310 token = lsptok(NULL, &length); /* now read it */
1311 local_node->pages = (unsigned int) atoi(token);
1313 token = lsptok(NULL, &length); /* get :tuples */
1314 token = lsptok(NULL, &length); /* now read it */
1315 local_node->tuples = (unsigned int) atoi(token);
1317 token = lsptok(NULL, &length); /* get :size */
1318 token = lsptok(NULL, &length); /* now read it */
1319 local_node->size = (unsigned int) atoi(token);
1321 token = lsptok(NULL, &length); /* get :width */
1322 token = lsptok(NULL, &length); /* now read it */
1323 local_node->width = (unsigned int) atoi(token);
1325 token = lsptok(NULL, &length); /* get :targetlist */
1326 local_node->targetlist = nodeRead(true); /* now read it */
1328 token = lsptok(NULL, &length); /* get :pathlist */
1329 local_node->pathlist = nodeRead(true); /* now read it */
1332 * Not sure if these are nodes or not. They're declared as struct
1333 * Path *. Since i don't know, i'll just print the addresses for now.
1334 * This can be changed later, if necessary.
1337 token = lsptok(NULL, &length); /* get :unorderpath */
1338 token = lsptok(NULL, &length); /* get @ */
1339 token = lsptok(NULL, &length); /* now read it */
1341 sscanf(token, "%x", (unsigned int *) &local_node->unorderedpath);
1343 token = lsptok(NULL, &length); /* get :cheapestpath */
1344 token = lsptok(NULL, &length); /* get @ */
1345 token = lsptok(NULL, &length); /* now read it */
1347 sscanf(token, "%x", (unsigned int *) &local_node->cheapestpath);
1350 token = lsptok(NULL, &length); /* get :restrictinfo */
1351 local_node->restrictinfo = nodeRead(true); /* now read it */
1353 token = lsptok(NULL, &length); /* get :joininfo */
1354 local_node->joininfo = nodeRead(true); /* now read it */
1356 token = lsptok(NULL, &length); /* get :innerjoin */
1357 local_node->innerjoin = nodeRead(true); /* now read it */
1366 static TargetEntry *
1369 TargetEntry *local_node;
1373 local_node = makeNode(TargetEntry);
1375 token = lsptok(NULL, &length); /* get :resdom */
1376 local_node->resdom = nodeRead(true); /* now read it */
1378 token = lsptok(NULL, &length); /* get :expr */
1379 local_node->expr = nodeRead(true); /* now read it */
1385 * _readRangeTblEntry
1388 static RangeTblEntry *
1389 _readRangeTblEntry()
1391 RangeTblEntry *local_node;
1395 local_node = makeNode(RangeTblEntry);
1397 token = lsptok(NULL, &length); /* eat :relname */
1398 token = lsptok(NULL, &length); /* get :relname */
1400 local_node->relname = NULL;
1403 local_node->relname = (char *) palloc(length + 1);
1404 StrNCpy(local_node->relname, token, length + 1);
1407 token = lsptok(NULL, &length); /* eat :refname */
1408 token = lsptok(NULL, &length); /* get :refname */
1410 local_node->refname = NULL;
1413 local_node->refname = (char *) palloc(length + 1);
1414 StrNCpy(local_node->refname, token, length + 1);
1417 token = lsptok(NULL, &length); /* eat :relid */
1418 token = lsptok(NULL, &length); /* get :relid */
1419 local_node->relid = strtoul(token, NULL, 10);
1421 token = lsptok(NULL, &length); /* eat :inh */
1422 token = lsptok(NULL, &length); /* get :inh */
1423 local_node->inh = (token[0] == 't') ? true : false;
1425 token = lsptok(NULL, &length); /* eat :inFromCl */
1426 token = lsptok(NULL, &length); /* get :inFromCl */
1427 local_node->inFromCl = (token[0] == 't') ? true : false;
1429 token = lsptok(NULL, &length); /* eat :skipAcl */
1430 token = lsptok(NULL, &length); /* get :skipAcl */
1431 local_node->skipAcl = (token[0] == 't') ? true : false;
1439 RowMark *local_node = makeNode(RowMark);
1443 token = lsptok(NULL, &length); /* eat :rti */
1444 token = lsptok(NULL, &length); /* get :rti */
1445 local_node->rti = strtoul(token, NULL, 10);
1447 token = lsptok(NULL, &length); /* eat :info */
1448 token = lsptok(NULL, &length); /* get :info */
1449 local_node->info = strtoul(token, NULL, 10);
1457 * PathOrder is part of Path and it's subclasses.
1463 PathOrder *local_node;
1467 local_node = makeNode(PathOrder);
1469 token = lsptok(NULL, &length); /* get :ordtype */
1470 token = lsptok(NULL, &length); /* now read it */
1471 local_node->ordtype = atol(token);
1473 if (local_node->ordtype == SORTOP_ORDER)
1475 token = lsptok(NULL, &length); /* get :sortop */
1478 local_node->ord.sortop = NULL;
1483 local_node->ord.sortop = palloc(sizeof(Oid) * (INDEX_MAX_KEYS+1));
1487 Assert(i <= INDEX_MAX_KEYS);
1488 token = lsptok(NULL, &length); /* now read it */
1489 local_node->ord.sortop[i] = strtoul(token, NULL, 10);
1490 } while (local_node->ord.sortop[i] != 0);
1495 token = lsptok(NULL, &length); /* get :merge */
1496 local_node->ord.merge = nodeRead(true); /* now read it */
1505 * Path is a subclass of Node.
1515 local_node = makeNode(Path);
1517 token = lsptok(NULL, &length); /* get :pathtype */
1518 token = lsptok(NULL, &length); /* now read it */
1519 local_node->pathtype = atol(token);
1521 token = lsptok(NULL, &length); /* get :cost */
1522 token = lsptok(NULL, &length); /* now read it */
1523 local_node->path_cost = (Cost) atof(token);
1525 token = lsptok(NULL, &length); /* get :pathorder */
1526 local_node->pathorder = nodeRead(true); /* now read it */
1528 token = lsptok(NULL, &length); /* get :pathkeys */
1529 local_node->pathkeys = nodeRead(true); /* now read it */
1537 * IndexPath is a subclass of Path.
1543 IndexPath *local_node;
1547 local_node = makeNode(IndexPath);
1549 token = lsptok(NULL, &length); /* get :pathtype */
1550 token = lsptok(NULL, &length); /* now read it */
1551 local_node->path.pathtype = atol(token);
1553 token = lsptok(NULL, &length); /* get :cost */
1554 token = lsptok(NULL, &length); /* now read it */
1555 local_node->path.path_cost = (Cost) atof(token);
1557 token = lsptok(NULL, &length); /* get :pathorder */
1558 local_node->path.pathorder = nodeRead(true); /* now read it */
1560 token = lsptok(NULL, &length); /* get :pathkeys */
1561 local_node->path.pathkeys = nodeRead(true); /* now read it */
1563 token = lsptok(NULL, &length); /* get :indexid */
1564 local_node->indexid = toIntList(nodeRead(true));
1566 token = lsptok(NULL, &length); /* get :indexqual */
1567 local_node->indexqual = nodeRead(true); /* now read it */
1575 * JoinPath is a subclass of Path
1581 JoinPath *local_node;
1586 local_node = makeNode(JoinPath);
1588 token = lsptok(NULL, &length); /* get :pathtype */
1589 token = lsptok(NULL, &length); /* now read it */
1590 local_node->path.pathtype = atol(token);
1592 token = lsptok(NULL, &length); /* get :cost */
1593 token = lsptok(NULL, &length); /* now read it */
1594 local_node->path.path_cost = (Cost) atof(token);
1596 token = lsptok(NULL, &length); /* get :pathorder */
1597 local_node->path.pathorder = nodeRead(true); /* now read it */
1599 token = lsptok(NULL, &length); /* get :pathkeys */
1600 local_node->path.pathkeys = nodeRead(true); /* now read it */
1602 token = lsptok(NULL, &length); /* get :pathinfo */
1603 local_node->pathinfo = nodeRead(true); /* now read it */
1606 * Not sure if these are nodes; they're declared as "struct path *".
1607 * For now, i'll just print the addresses.
1609 * GJK: Since I am parsing this stuff, I'll just ignore the addresses,
1610 * and initialize these pointers to NULL.
1613 token = lsptok(NULL, &length); /* get :outerjoinpath */
1614 token = lsptok(NULL, &length); /* get @ */
1615 token = lsptok(NULL, &length); /* now read it */
1617 local_node->outerjoinpath = NULL;
1619 token = lsptok(NULL, &length); /* get :innerjoinpath */
1620 token = lsptok(NULL, &length); /* get @ */
1621 token = lsptok(NULL, &length); /* now read it */
1623 local_node->innerjoinpath = NULL;
1625 token = lsptok(NULL, &length); /* get :outerjoincost */
1626 token = lsptok(NULL, &length); /* now read it */
1628 local_node->path.outerjoincost = (Cost) atof(token);
1630 token = lsptok(NULL, &length); /* get :joinid */
1631 local_node->path.joinid = toIntList(nodeRead(true)); /* now read it */
1639 * MergePath is a subclass of JoinPath.
1645 MergePath *local_node;
1649 local_node = makeNode(MergePath);
1651 token = lsptok(NULL, &length); /* get :pathtype */
1652 token = lsptok(NULL, &length); /* now read it */
1654 local_node->jpath.path.pathtype = atol(token);
1656 token = lsptok(NULL, &length); /* get :cost */
1657 token = lsptok(NULL, &length); /* now read it */
1659 local_node->jpath.path.path_cost = (Cost) atof(token);
1661 token = lsptok(NULL, &length); /* get :pathorder */
1662 local_node->jpath.path.pathorder = nodeRead(true); /* now read it */
1664 token = lsptok(NULL, &length); /* get :pathkeys */
1665 local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */
1667 token = lsptok(NULL, &length); /* get :pathinfo */
1668 local_node->jpath.pathinfo = nodeRead(true); /* now read it */
1671 * Not sure if these are nodes; they're declared as "struct path *".
1672 * For now, i'll just print the addresses.
1674 * GJK: Since I am parsing this stuff, I'll just ignore the addresses,
1675 * and initialize these pointers to NULL.
1678 token = lsptok(NULL, &length); /* get :outerjoinpath */
1679 token = lsptok(NULL, &length); /* get @ */
1680 token = lsptok(NULL, &length); /* now read it */
1682 local_node->jpath.outerjoinpath = NULL;
1684 token = lsptok(NULL, &length); /* get :innerjoinpath */
1685 token = lsptok(NULL, &length); /* get @ */
1686 token = lsptok(NULL, &length); /* now read it */
1688 local_node->jpath.innerjoinpath = NULL;
1690 token = lsptok(NULL, &length); /* get :outerjoincost */
1691 token = lsptok(NULL, &length); /* now read it */
1693 local_node->jpath.path.outerjoincost = (Cost) atof(token);
1695 token = lsptok(NULL, &length); /* get :joinid */
1696 local_node->jpath.path.joinid = toIntList(nodeRead(true)); /* now read it */
1698 token = lsptok(NULL, &length); /* get :path_mergeclauses */
1699 local_node->path_mergeclauses = nodeRead(true); /* now read it */
1701 token = lsptok(NULL, &length); /* get :outersortkeys */
1702 local_node->outersortkeys = nodeRead(true); /* now read it */
1704 token = lsptok(NULL, &length); /* get :innersortkeys */
1705 local_node->innersortkeys = nodeRead(true); /* now read it */
1713 * HashPath is a subclass of JoinPath.
1719 HashPath *local_node;
1723 local_node = makeNode(HashPath);
1725 token = lsptok(NULL, &length); /* get :pathtype */
1726 token = lsptok(NULL, &length); /* now read it */
1728 local_node->jpath.path.pathtype = atol(token);
1730 token = lsptok(NULL, &length); /* get :cost */
1731 token = lsptok(NULL, &length); /* now read it */
1733 local_node->jpath.path.path_cost = (Cost) atof(token);
1735 token = lsptok(NULL, &length); /* get :pathorder */
1736 local_node->jpath.path.pathorder = nodeRead(true); /* now read it */
1738 token = lsptok(NULL, &length); /* get :pathkeys */
1739 local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */
1741 token = lsptok(NULL, &length); /* get :pathinfo */
1742 local_node->jpath.pathinfo = nodeRead(true); /* now read it */
1745 * Not sure if these are nodes; they're declared as "struct path *".
1746 * For now, i'll just print the addresses.
1748 * GJK: Since I am parsing this stuff, I'll just ignore the addresses,
1749 * and initialize these pointers to NULL.
1752 token = lsptok(NULL, &length); /* get :outerjoinpath */
1753 token = lsptok(NULL, &length); /* get @ */
1754 token = lsptok(NULL, &length); /* now read it */
1756 local_node->jpath.outerjoinpath = NULL;
1758 token = lsptok(NULL, &length); /* get :innerjoinpath */
1759 token = lsptok(NULL, &length); /* get @ */
1760 token = lsptok(NULL, &length); /* now read it */
1762 local_node->jpath.innerjoinpath = NULL;
1764 token = lsptok(NULL, &length); /* get :outerjoincost */
1765 token = lsptok(NULL, &length); /* now read it */
1767 local_node->jpath.path.outerjoincost = (Cost) atof(token);
1769 token = lsptok(NULL, &length); /* get :joinid */
1770 local_node->jpath.path.joinid = toIntList(nodeRead(true)); /* now read it */
1772 token = lsptok(NULL, &length); /* get :path_hashclauses */
1773 local_node->path_hashclauses = nodeRead(true); /* now read it */
1775 token = lsptok(NULL, &length); /* get :outerhashkeys */
1776 local_node->outerhashkeys = nodeRead(true); /* now read it */
1778 token = lsptok(NULL, &length); /* get :innerhashkeys */
1779 local_node->innerhashkeys = nodeRead(true); /* now read it */
1787 * OrderKey is a subclass of Node.
1793 OrderKey *local_node;
1797 local_node = makeNode(OrderKey);
1799 token = lsptok(NULL, &length); /* get :attribute_number */
1800 token = lsptok(NULL, &length); /* now read it */
1802 local_node->attribute_number = atoi(token);
1804 token = lsptok(NULL, &length); /* get :array_index */
1805 token = lsptok(NULL, &length); /* now read it */
1807 local_node->array_index = strtoul(token, NULL, 10);
1815 * JoinKey is a subclass of Node.
1821 JoinKey *local_node;
1825 local_node = makeNode(JoinKey);
1827 token = lsptok(NULL, &length); /* get :outer */
1828 local_node->outer = nodeRead(true); /* now read it */
1830 token = lsptok(NULL, &length); /* get :inner */
1831 local_node->inner = nodeRead(true); /* now read it */
1839 * MergeOrder is a subclass of Node.
1845 MergeOrder *local_node;
1849 local_node = makeNode(MergeOrder);
1850 token = lsptok(NULL, &length); /* get :join_operator */
1851 token = lsptok(NULL, &length); /* now read it */
1853 local_node->join_operator = atol(token);
1855 token = lsptok(NULL, &length); /* get :left_operator */
1856 token = lsptok(NULL, &length); /* now read it */
1858 local_node->left_operator = atol(token);
1860 token = lsptok(NULL, &length); /* get :right_operator */
1861 token = lsptok(NULL, &length); /* now read it */
1863 local_node->right_operator = atol(token);
1865 token = lsptok(NULL, &length); /* get :left_type */
1866 token = lsptok(NULL, &length); /* now read it */
1868 local_node->left_type = atol(token);
1870 token = lsptok(NULL, &length); /* get :right_type */
1871 token = lsptok(NULL, &length); /* now read it */
1873 local_node->right_type = atol(token);
1881 * RestrictInfo is a subclass of Node.
1884 static RestrictInfo *
1887 RestrictInfo *local_node;
1891 local_node = makeNode(RestrictInfo);
1893 token = lsptok(NULL, &length); /* get :clause */
1894 local_node->clause = nodeRead(true); /* now read it */
1896 token = lsptok(NULL, &length); /* get :selectivity */
1897 token = lsptok(NULL, &length); /* now read it */
1899 local_node->selectivity = atof(token);
1901 token = lsptok(NULL, &length); /* get :notclause */
1902 token = lsptok(NULL, &length); /* now read it */
1904 if (!strncmp(token, "true", 4))
1905 local_node->notclause = true;
1907 local_node->notclause = false;
1909 token = lsptok(NULL, &length); /* get :indexids */
1910 local_node->indexids = nodeRead(true); /* now read it */
1912 token = lsptok(NULL, &length); /* get :mergejoinorder */
1913 local_node->mergejoinorder = (MergeOrder *) nodeRead(true);
1915 token = lsptok(NULL, &length); /* get :hashjoinoperator */
1916 token = lsptok(NULL, &length); /* now read it */
1918 local_node->hashjoinoperator = atol(token);
1926 * JoinMethod is a subclass of Node.
1932 JoinMethod *local_node;
1936 local_node = makeNode(JoinMethod);
1938 token = lsptok(NULL, &length); /* get :jmkeys */
1939 local_node->jmkeys = nodeRead(true); /* now read it */
1941 token = lsptok(NULL, &length); /* get :clauses */
1942 local_node->clauses = nodeRead(true); /* now read it */
1950 * HashInfo is a subclass of JoinMethod.
1956 HashInfo *local_node;
1960 local_node = makeNode(HashInfo);
1962 token = lsptok(NULL, &length); /* get :hashop */
1963 token = lsptok(NULL, &length); /* now read it */
1965 local_node->hashop = strtoul(token, NULL, 10);
1967 token = lsptok(NULL, &length); /* get :jmkeys */
1968 local_node->jmethod.jmkeys = nodeRead(true); /* now read it */
1970 token = lsptok(NULL, &length); /* get :clauses */
1971 local_node->jmethod.clauses = nodeRead(true); /* now read it */
1979 * JoinInfo is a subclass of Node.
1985 JoinInfo *local_node;
1989 local_node = makeNode(JoinInfo);
1991 token = lsptok(NULL, &length); /* get :otherrels */
1992 local_node->otherrels = toIntList(nodeRead(true)); /* now read it */
1994 token = lsptok(NULL, &length); /* get :jinfo_restrictinfo */
1995 local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */
1997 token = lsptok(NULL, &length); /* get :mergejoinable */
1999 if (!strncmp(token, "true", 4))
2000 local_node->mergejoinable = true;
2002 local_node->mergejoinable = false;
2004 token = lsptok(NULL, &length); /* get :hashjoinable */
2006 if (!strncmp(token, "true", 4))
2007 local_node->hashjoinable = true;
2009 local_node->hashjoinable = false;
2026 local_node = makeNode(Iter);
2028 token = lsptok(NULL, &length); /* eat :iterexpr */
2029 local_node->iterexpr = nodeRead(true); /* now read it */
2038 * Given a character string containing a plan, parsePlanString sets up the
2039 * plan structure representing that plan.
2041 * The string passed to parsePlanString must be null-terminated.
2045 parsePlanString(void)
2049 void *return_value = NULL;
2051 token = lsptok(NULL, &length);
2053 if (!strncmp(token, "PLAN", length))
2054 return_value = _readPlan();
2055 else if (!strncmp(token, "RESULT", length))
2056 return_value = _readResult();
2057 else if (!strncmp(token, "APPEND", length))
2058 return_value = _readAppend();
2059 else if (!strncmp(token, "JOIN", length))
2060 return_value = _readJoin();
2061 else if (!strncmp(token, "NESTLOOP", length))
2062 return_value = _readNestLoop();
2063 else if (!strncmp(token, "MERGEJOIN", length))
2064 return_value = _readMergeJoin();
2065 else if (!strncmp(token, "HASHJOIN", length))
2066 return_value = _readHashJoin();
2067 else if (!strncmp(token, "SCAN", length))
2068 return_value = _readScan();
2069 else if (!strncmp(token, "SEQSCAN", length))
2070 return_value = _readSeqScan();
2071 else if (!strncmp(token, "INDEXSCAN", length))
2072 return_value = _readIndexScan();
2073 else if (!strncmp(token, "NONAME", length))
2074 return_value = _readNoname();
2075 else if (!strncmp(token, "SORT", length))
2076 return_value = _readSort();
2077 else if (!strncmp(token, "AGGREG", length))
2078 return_value = _readAggref();
2079 else if (!strncmp(token, "SUBLINK", length))
2080 return_value = _readSubLink();
2081 else if (!strncmp(token, "AGG", length))
2082 return_value = _readAgg();
2083 else if (!strncmp(token, "UNIQUE", length))
2084 return_value = _readUnique();
2085 else if (!strncmp(token, "HASH", length))
2086 return_value = _readHash();
2087 else if (!strncmp(token, "RESDOM", length))
2088 return_value = _readResdom();
2089 else if (!strncmp(token, "EXPR", length))
2090 return_value = _readExpr();
2091 else if (!strncmp(token, "ARRAYREF", length))
2092 return_value = _readArrayRef();
2093 else if (!strncmp(token, "ARRAY", length))
2094 return_value = _readArray();
2095 else if (!strncmp(token, "VAR", length))
2096 return_value = _readVar();
2097 else if (!strncmp(token, "CONST", length))
2098 return_value = _readConst();
2099 else if (!strncmp(token, "FUNC", length))
2100 return_value = _readFunc();
2101 else if (!strncmp(token, "OPER", length))
2102 return_value = _readOper();
2103 else if (!strncmp(token, "PARAM", length))
2104 return_value = _readParam();
2105 else if (!strncmp(token, "ESTATE", length))
2106 return_value = _readEState();
2107 else if (!strncmp(token, "RELOPTINFO", length))
2108 return_value = _readRelOptInfo();
2109 else if (!strncmp(token, "TARGETENTRY", length))
2110 return_value = _readTargetEntry();
2111 else if (!strncmp(token, "RTE", length))
2112 return_value = _readRangeTblEntry();
2113 else if (!strncmp(token, "PATHORDER", length))
2114 return_value = _readPathOrder();
2115 else if (!strncmp(token, "PATH", length))
2116 return_value = _readPath();
2117 else if (!strncmp(token, "INDEXPATH", length))
2118 return_value = _readIndexPath();
2119 else if (!strncmp(token, "JOINPATH", length))
2120 return_value = _readJoinPath();
2121 else if (!strncmp(token, "MERGEPATH", length))
2122 return_value = _readMergePath();
2123 else if (!strncmp(token, "HASHPATH", length))
2124 return_value = _readHashPath();
2125 else if (!strncmp(token, "ORDERKEY", length))
2126 return_value = _readOrderKey();
2127 else if (!strncmp(token, "JOINKEY", length))
2128 return_value = _readJoinKey();
2129 else if (!strncmp(token, "MERGEORDER", length))
2130 return_value = _readMergeOrder();
2131 else if (!strncmp(token, "RETRICTINFO", length))
2132 return_value = _readRestrictInfo();
2133 else if (!strncmp(token, "JOINMETHOD", length))
2134 return_value = _readJoinMethod();
2135 else if (!strncmp(token, "JOININFO", length))
2136 return_value = _readJoinInfo();
2137 else if (!strncmp(token, "HASHINFO", length))
2138 return_value = _readHashInfo();
2139 else if (!strncmp(token, "ITER", length))
2140 return_value = _readIter();
2141 else if (!strncmp(token, "QUERY", length))
2142 return_value = _readQuery();
2143 else if (!strncmp(token, "SORTCLAUSE", length))
2144 return_value = _readSortClause();
2145 else if (!strncmp(token, "GROUPCLAUSE", length))
2146 return_value = _readGroupClause();
2147 else if (!strncmp(token, "CASE", length))
2148 return_value = _readCaseExpr();
2149 else if (!strncmp(token, "WHEN", length))
2150 return_value = _readCaseWhen();
2151 else if (!strncmp(token, "ROWMARK", length))
2152 return_value = _readRowMark();
2154 elog(ERROR, "badly formatted planstring \"%.10s\"...\n", token);
2156 return (Node *) return_value;
2159 /*------------------------------------------------------------*/
2164 * given a string representation of the value of the given type,
2165 * create the appropriate Datum
2179 byValue = get_typbyval(type);
2182 * read the actual length of the value
2184 token = lsptok(NULL, &tokenLength);
2185 length = atoi(token);
2186 token = lsptok(NULL, &tokenLength); /* skip the '[' */
2190 if (length > sizeof(Datum))
2191 elog(ERROR, "readValue: byval & length = %d", length);
2192 s = (char *) (&res);
2193 for (i = 0; i < sizeof(Datum); i++)
2195 token = lsptok(NULL, &tokenLength);
2196 s[i] = (char) atoi(token);
2199 else if (length <= 0)
2201 else if (length >= 1)
2203 s = (char *) palloc(length);
2205 for (i = 0; i < length; i++)
2207 token = lsptok(NULL, &tokenLength);
2208 s[i] = (char) atoi(token);
2210 res = PointerGetDatum(s);
2213 token = lsptok(NULL, &tokenLength); /* skip the ']' */
2214 if (token[0] != ']')
2215 elog(ERROR, "readValue: ']' expected, length =%d", length);