PostgreSQL Source Code  git master
readfuncs.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * readfuncs.c
4  * Reader functions for Postgres tree nodes.
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/nodes/readfuncs.c
12  *
13  * NOTES
14  * Path nodes do not have any readfuncs support, because we never
15  * have occasion to read them in. (There was once code here that
16  * claimed to read them, but it was broken as well as unused.) We
17  * never read executor state trees, either.
18  *
19  * Parse location fields are written out by outfuncs.c, but only for
20  * possible debugging use. When reading a location field, we discard
21  * the stored value and set the location field to -1 (ie, "unknown").
22  * This is because nodes coming from a stored rule should not be thought
23  * to have a known location in the current query's text.
24  *
25  *-------------------------------------------------------------------------
26  */
27 #include "postgres.h"
28 
29 #include <math.h>
30 
31 #include "fmgr.h"
32 #include "nodes/extensible.h"
33 #include "nodes/parsenodes.h"
34 #include "nodes/plannodes.h"
35 #include "nodes/readfuncs.h"
36 #include "utils/builtins.h"
37 
38 
39 /*
40  * Macros to simplify reading of different kinds of fields. Use these
41  * wherever possible to reduce the chance for silly typos. Note that these
42  * hard-wire conventions about the names of the local variables in a Read
43  * routine.
44  */
45 
46 /* Macros for declaring appropriate local variables */
47 
48 /* A few guys need only local_node */
49 #define READ_LOCALS_NO_FIELDS(nodeTypeName) \
50  nodeTypeName *local_node = makeNode(nodeTypeName)
51 
52 /* And a few guys need only the pg_strtok support fields */
53 #define READ_TEMP_LOCALS() \
54  char *token; \
55  int length
56 
57 /* ... but most need both */
58 #define READ_LOCALS(nodeTypeName) \
59  READ_LOCALS_NO_FIELDS(nodeTypeName); \
60  READ_TEMP_LOCALS()
61 
62 /* Read an integer field (anything written as ":fldname %d") */
63 #define READ_INT_FIELD(fldname) \
64  token = pg_strtok(&length); /* skip :fldname */ \
65  token = pg_strtok(&length); /* get field value */ \
66  local_node->fldname = atoi(token)
67 
68 /* Read an unsigned integer field (anything written as ":fldname %u") */
69 #define READ_UINT_FIELD(fldname) \
70  token = pg_strtok(&length); /* skip :fldname */ \
71  token = pg_strtok(&length); /* get field value */ \
72  local_node->fldname = atoui(token)
73 
74 /* Read an unsigned integer field (anything written using UINT64_FORMAT) */
75 #define READ_UINT64_FIELD(fldname) \
76  token = pg_strtok(&length); /* skip :fldname */ \
77  token = pg_strtok(&length); /* get field value */ \
78  local_node->fldname = pg_strtouint64(token, NULL, 10)
79 
80 /* Read an long integer field (anything written as ":fldname %ld") */
81 #define READ_LONG_FIELD(fldname) \
82  token = pg_strtok(&length); /* skip :fldname */ \
83  token = pg_strtok(&length); /* get field value */ \
84  local_node->fldname = atol(token)
85 
86 /* Read an OID field (don't hard-wire assumption that OID is same as uint) */
87 #define READ_OID_FIELD(fldname) \
88  token = pg_strtok(&length); /* skip :fldname */ \
89  token = pg_strtok(&length); /* get field value */ \
90  local_node->fldname = atooid(token)
91 
92 /* Read a char field (ie, one ascii character) */
93 #define READ_CHAR_FIELD(fldname) \
94  token = pg_strtok(&length); /* skip :fldname */ \
95  token = pg_strtok(&length); /* get field value */ \
96  /* avoid overhead of calling debackslash() for one char */ \
97  local_node->fldname = (length == 0) ? '\0' : (token[0] == '\\' ? token[1] : token[0])
98 
99 /* Read an enumerated-type field that was written as an integer code */
100 #define READ_ENUM_FIELD(fldname, enumtype) \
101  token = pg_strtok(&length); /* skip :fldname */ \
102  token = pg_strtok(&length); /* get field value */ \
103  local_node->fldname = (enumtype) atoi(token)
104 
105 /* Read a float field */
106 #define READ_FLOAT_FIELD(fldname) \
107  token = pg_strtok(&length); /* skip :fldname */ \
108  token = pg_strtok(&length); /* get field value */ \
109  local_node->fldname = atof(token)
110 
111 /* Read a boolean field */
112 #define READ_BOOL_FIELD(fldname) \
113  token = pg_strtok(&length); /* skip :fldname */ \
114  token = pg_strtok(&length); /* get field value */ \
115  local_node->fldname = strtobool(token)
116 
117 /* Read a character-string field */
118 #define READ_STRING_FIELD(fldname) \
119  token = pg_strtok(&length); /* skip :fldname */ \
120  token = pg_strtok(&length); /* get field value */ \
121  local_node->fldname = nullable_string(token, length)
122 
123 /* Read a parse location field (and throw away the value, per notes above) */
124 #define READ_LOCATION_FIELD(fldname) \
125  token = pg_strtok(&length); /* skip :fldname */ \
126  token = pg_strtok(&length); /* get field value */ \
127  (void) token; /* in case not used elsewhere */ \
128  local_node->fldname = -1 /* set field to "unknown" */
129 
130 /* Read a Node field */
131 #define READ_NODE_FIELD(fldname) \
132  token = pg_strtok(&length); /* skip :fldname */ \
133  (void) token; /* in case not used elsewhere */ \
134  local_node->fldname = nodeRead(NULL, 0)
135 
136 /* Read a bitmapset field */
137 #define READ_BITMAPSET_FIELD(fldname) \
138  token = pg_strtok(&length); /* skip :fldname */ \
139  (void) token; /* in case not used elsewhere */ \
140  local_node->fldname = _readBitmapset()
141 
142 /* Read an attribute number array */
143 #define READ_ATTRNUMBER_ARRAY(fldname, len) \
144  token = pg_strtok(&length); /* skip :fldname */ \
145  local_node->fldname = readAttrNumberCols(len);
146 
147 /* Read an oid array */
148 #define READ_OID_ARRAY(fldname, len) \
149  token = pg_strtok(&length); /* skip :fldname */ \
150  local_node->fldname = readOidCols(len);
151 
152 /* Read an int array */
153 #define READ_INT_ARRAY(fldname, len) \
154  token = pg_strtok(&length); /* skip :fldname */ \
155  local_node->fldname = readIntCols(len);
156 
157 /* Read a bool array */
158 #define READ_BOOL_ARRAY(fldname, len) \
159  token = pg_strtok(&length); /* skip :fldname */ \
160  local_node->fldname = readBoolCols(len);
161 
162 /* Routine exit */
163 #define READ_DONE() \
164  return local_node
165 
166 
167 /*
168  * NOTE: use atoi() to read values written with %d, or atoui() to read
169  * values written with %u in outfuncs.c. An exception is OID values,
170  * for which use atooid(). (As of 7.1, outfuncs.c writes OIDs as %u,
171  * but this will probably change in the future.)
172  */
173 #define atoui(x) ((unsigned int) strtoul((x), NULL, 10))
174 
175 #define strtobool(x) ((*(x) == 't') ? true : false)
176 
177 #define nullable_string(token,length) \
178  ((length) == 0 ? NULL : debackslash(token, length))
179 
180 
181 /*
182  * _readBitmapset
183  */
184 static Bitmapset *
186 {
187  Bitmapset *result = NULL;
188 
190 
191  token = pg_strtok(&length);
192  if (token == NULL)
193  elog(ERROR, "incomplete Bitmapset structure");
194  if (length != 1 || token[0] != '(')
195  elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
196 
197  token = pg_strtok(&length);
198  if (token == NULL)
199  elog(ERROR, "incomplete Bitmapset structure");
200  if (length != 1 || token[0] != 'b')
201  elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
202 
203  for (;;)
204  {
205  int val;
206  char *endptr;
207 
208  token = pg_strtok(&length);
209  if (token == NULL)
210  elog(ERROR, "unterminated Bitmapset structure");
211  if (length == 1 && token[0] == ')')
212  break;
213  val = (int) strtol(token, &endptr, 10);
214  if (endptr != token + length)
215  elog(ERROR, "unrecognized integer: \"%.*s\"", length, token);
216  result = bms_add_member(result, val);
217  }
218 
219  return result;
220 }
221 
222 /*
223  * for use by extensions which define extensible nodes
224  */
225 Bitmapset *
227 {
228  return _readBitmapset();
229 }
230 
231 /*
232  * _readQuery
233  */
234 static Query *
236 {
238 
239  READ_ENUM_FIELD(commandType, CmdType);
240  READ_ENUM_FIELD(querySource, QuerySource);
241  local_node->queryId = UINT64CONST(0); /* not saved in output format */
242  READ_BOOL_FIELD(canSetTag);
243  READ_NODE_FIELD(utilityStmt);
244  READ_INT_FIELD(resultRelation);
245  READ_BOOL_FIELD(hasAggs);
246  READ_BOOL_FIELD(hasWindowFuncs);
247  READ_BOOL_FIELD(hasTargetSRFs);
248  READ_BOOL_FIELD(hasSubLinks);
249  READ_BOOL_FIELD(hasDistinctOn);
250  READ_BOOL_FIELD(hasRecursive);
251  READ_BOOL_FIELD(hasModifyingCTE);
252  READ_BOOL_FIELD(hasForUpdate);
253  READ_BOOL_FIELD(hasRowSecurity);
254  READ_NODE_FIELD(cteList);
255  READ_NODE_FIELD(rtable);
256  READ_NODE_FIELD(jointree);
257  READ_NODE_FIELD(targetList);
258  READ_ENUM_FIELD(override, OverridingKind);
259  READ_NODE_FIELD(onConflict);
260  READ_NODE_FIELD(returningList);
261  READ_NODE_FIELD(groupClause);
262  READ_NODE_FIELD(groupingSets);
263  READ_NODE_FIELD(havingQual);
264  READ_NODE_FIELD(windowClause);
265  READ_NODE_FIELD(distinctClause);
266  READ_NODE_FIELD(sortClause);
267  READ_NODE_FIELD(limitOffset);
268  READ_NODE_FIELD(limitCount);
269  READ_NODE_FIELD(rowMarks);
270  READ_NODE_FIELD(setOperations);
271  READ_NODE_FIELD(constraintDeps);
272  /* withCheckOptions intentionally omitted, see comment in parsenodes.h */
273  READ_LOCATION_FIELD(stmt_location);
274  READ_LOCATION_FIELD(stmt_len);
275 
276  READ_DONE();
277 }
278 
279 /*
280  * _readNotifyStmt
281  */
282 static NotifyStmt *
284 {
286 
287  READ_STRING_FIELD(conditionname);
288  READ_STRING_FIELD(payload);
289 
290  READ_DONE();
291 }
292 
293 /*
294  * _readDeclareCursorStmt
295  */
296 static DeclareCursorStmt *
298 {
300 
301  READ_STRING_FIELD(portalname);
303  READ_NODE_FIELD(query);
304 
305  READ_DONE();
306 }
307 
308 /*
309  * _readWithCheckOption
310  */
311 static WithCheckOption *
313 {
315 
316  READ_ENUM_FIELD(kind, WCOKind);
317  READ_STRING_FIELD(relname);
318  READ_STRING_FIELD(polname);
319  READ_NODE_FIELD(qual);
320  READ_BOOL_FIELD(cascaded);
321 
322  READ_DONE();
323 }
324 
325 /*
326  * _readSortGroupClause
327  */
328 static SortGroupClause *
330 {
332 
333  READ_UINT_FIELD(tleSortGroupRef);
334  READ_OID_FIELD(eqop);
335  READ_OID_FIELD(sortop);
336  READ_BOOL_FIELD(nulls_first);
337  READ_BOOL_FIELD(hashable);
338 
339  READ_DONE();
340 }
341 
342 /*
343  * _readGroupingSet
344  */
345 static GroupingSet *
347 {
349 
351  READ_NODE_FIELD(content);
352  READ_LOCATION_FIELD(location);
353 
354  READ_DONE();
355 }
356 
357 /*
358  * _readWindowClause
359  */
360 static WindowClause *
362 {
364 
366  READ_STRING_FIELD(refname);
367  READ_NODE_FIELD(partitionClause);
368  READ_NODE_FIELD(orderClause);
369  READ_INT_FIELD(frameOptions);
370  READ_NODE_FIELD(startOffset);
371  READ_NODE_FIELD(endOffset);
372  READ_UINT_FIELD(winref);
373  READ_BOOL_FIELD(copiedOrder);
374 
375  READ_DONE();
376 }
377 
378 /*
379  * _readRowMarkClause
380  */
381 static RowMarkClause *
383 {
385 
386  READ_UINT_FIELD(rti);
388  READ_ENUM_FIELD(waitPolicy, LockWaitPolicy);
389  READ_BOOL_FIELD(pushedDown);
390 
391  READ_DONE();
392 }
393 
394 /*
395  * _readCommonTableExpr
396  */
397 static CommonTableExpr *
399 {
401 
402  READ_STRING_FIELD(ctename);
403  READ_NODE_FIELD(aliascolnames);
404  READ_NODE_FIELD(ctequery);
405  READ_LOCATION_FIELD(location);
406  READ_BOOL_FIELD(cterecursive);
407  READ_INT_FIELD(cterefcount);
408  READ_NODE_FIELD(ctecolnames);
409  READ_NODE_FIELD(ctecoltypes);
410  READ_NODE_FIELD(ctecoltypmods);
411  READ_NODE_FIELD(ctecolcollations);
412 
413  READ_DONE();
414 }
415 
416 /*
417  * _readSetOperationStmt
418  */
419 static SetOperationStmt *
421 {
423 
425  READ_BOOL_FIELD(all);
426  READ_NODE_FIELD(larg);
427  READ_NODE_FIELD(rarg);
428  READ_NODE_FIELD(colTypes);
429  READ_NODE_FIELD(colTypmods);
430  READ_NODE_FIELD(colCollations);
431  READ_NODE_FIELD(groupClauses);
432 
433  READ_DONE();
434 }
435 
436 
437 /*
438  * Stuff from primnodes.h.
439  */
440 
441 static Alias *
443 {
445 
446  READ_STRING_FIELD(aliasname);
447  READ_NODE_FIELD(colnames);
448 
449  READ_DONE();
450 }
451 
452 static RangeVar *
454 {
456 
457  local_node->catalogname = NULL; /* not currently saved in output format */
458 
459  READ_STRING_FIELD(schemaname);
460  READ_STRING_FIELD(relname);
461  READ_BOOL_FIELD(inh);
462  READ_CHAR_FIELD(relpersistence);
463  READ_NODE_FIELD(alias);
464  READ_LOCATION_FIELD(location);
465 
466  READ_DONE();
467 }
468 
469 /*
470  * _readTableFunc
471  */
472 static TableFunc *
474 {
476 
477  READ_NODE_FIELD(ns_uris);
478  READ_NODE_FIELD(ns_names);
479  READ_NODE_FIELD(docexpr);
480  READ_NODE_FIELD(rowexpr);
481  READ_NODE_FIELD(colnames);
482  READ_NODE_FIELD(coltypes);
483  READ_NODE_FIELD(coltypmods);
484  READ_NODE_FIELD(colcollations);
485  READ_NODE_FIELD(colexprs);
486  READ_NODE_FIELD(coldefexprs);
487  READ_BITMAPSET_FIELD(notnulls);
488  READ_INT_FIELD(ordinalitycol);
489  READ_LOCATION_FIELD(location);
490 
491  READ_DONE();
492 }
493 
494 static IntoClause *
496 {
498 
499  READ_NODE_FIELD(rel);
500  READ_NODE_FIELD(colNames);
502  READ_ENUM_FIELD(onCommit, OnCommitAction);
503  READ_STRING_FIELD(tableSpaceName);
504  READ_NODE_FIELD(viewQuery);
505  READ_BOOL_FIELD(skipData);
506 
507  READ_DONE();
508 }
509 
510 /*
511  * _readVar
512  */
513 static Var *
514 _readVar(void)
515 {
516  READ_LOCALS(Var);
517 
518  READ_UINT_FIELD(varno);
519  READ_INT_FIELD(varattno);
520  READ_OID_FIELD(vartype);
521  READ_INT_FIELD(vartypmod);
522  READ_OID_FIELD(varcollid);
523  READ_UINT_FIELD(varlevelsup);
524  READ_UINT_FIELD(varnoold);
525  READ_INT_FIELD(varoattno);
526  READ_LOCATION_FIELD(location);
527 
528  READ_DONE();
529 }
530 
531 /*
532  * _readConst
533  */
534 static Const *
536 {
538 
539  READ_OID_FIELD(consttype);
540  READ_INT_FIELD(consttypmod);
541  READ_OID_FIELD(constcollid);
542  READ_INT_FIELD(constlen);
543  READ_BOOL_FIELD(constbyval);
544  READ_BOOL_FIELD(constisnull);
545  READ_LOCATION_FIELD(location);
546 
547  token = pg_strtok(&length); /* skip :constvalue */
548  if (local_node->constisnull)
549  token = pg_strtok(&length); /* skip "<>" */
550  else
551  local_node->constvalue = readDatum(local_node->constbyval);
552 
553  READ_DONE();
554 }
555 
556 /*
557  * _readParam
558  */
559 static Param *
561 {
563 
564  READ_ENUM_FIELD(paramkind, ParamKind);
565  READ_INT_FIELD(paramid);
566  READ_OID_FIELD(paramtype);
567  READ_INT_FIELD(paramtypmod);
568  READ_OID_FIELD(paramcollid);
569  READ_LOCATION_FIELD(location);
570 
571  READ_DONE();
572 }
573 
574 /*
575  * _readAggref
576  */
577 static Aggref *
579 {
581 
582  READ_OID_FIELD(aggfnoid);
583  READ_OID_FIELD(aggtype);
584  READ_OID_FIELD(aggcollid);
585  READ_OID_FIELD(inputcollid);
586  READ_OID_FIELD(aggtranstype);
587  READ_NODE_FIELD(aggargtypes);
588  READ_NODE_FIELD(aggdirectargs);
590  READ_NODE_FIELD(aggorder);
591  READ_NODE_FIELD(aggdistinct);
592  READ_NODE_FIELD(aggfilter);
593  READ_BOOL_FIELD(aggstar);
594  READ_BOOL_FIELD(aggvariadic);
595  READ_CHAR_FIELD(aggkind);
596  READ_UINT_FIELD(agglevelsup);
597  READ_ENUM_FIELD(aggsplit, AggSplit);
598  READ_LOCATION_FIELD(location);
599 
600  READ_DONE();
601 }
602 
603 /*
604  * _readGroupingFunc
605  */
606 static GroupingFunc *
608 {
610 
612  READ_NODE_FIELD(refs);
613  READ_NODE_FIELD(cols);
614  READ_UINT_FIELD(agglevelsup);
615  READ_LOCATION_FIELD(location);
616 
617  READ_DONE();
618 }
619 
620 /*
621  * _readWindowFunc
622  */
623 static WindowFunc *
625 {
627 
628  READ_OID_FIELD(winfnoid);
629  READ_OID_FIELD(wintype);
630  READ_OID_FIELD(wincollid);
631  READ_OID_FIELD(inputcollid);
633  READ_NODE_FIELD(aggfilter);
634  READ_UINT_FIELD(winref);
635  READ_BOOL_FIELD(winstar);
636  READ_BOOL_FIELD(winagg);
637  READ_LOCATION_FIELD(location);
638 
639  READ_DONE();
640 }
641 
642 /*
643  * _readArrayRef
644  */
645 static ArrayRef *
647 {
649 
650  READ_OID_FIELD(refarraytype);
651  READ_OID_FIELD(refelemtype);
652  READ_INT_FIELD(reftypmod);
653  READ_OID_FIELD(refcollid);
654  READ_NODE_FIELD(refupperindexpr);
655  READ_NODE_FIELD(reflowerindexpr);
656  READ_NODE_FIELD(refexpr);
657  READ_NODE_FIELD(refassgnexpr);
658 
659  READ_DONE();
660 }
661 
662 /*
663  * _readFuncExpr
664  */
665 static FuncExpr *
667 {
669 
670  READ_OID_FIELD(funcid);
671  READ_OID_FIELD(funcresulttype);
672  READ_BOOL_FIELD(funcretset);
673  READ_BOOL_FIELD(funcvariadic);
674  READ_ENUM_FIELD(funcformat, CoercionForm);
675  READ_OID_FIELD(funccollid);
676  READ_OID_FIELD(inputcollid);
678  READ_LOCATION_FIELD(location);
679 
680  READ_DONE();
681 }
682 
683 /*
684  * _readNamedArgExpr
685  */
686 static NamedArgExpr *
688 {
690 
693  READ_INT_FIELD(argnumber);
694  READ_LOCATION_FIELD(location);
695 
696  READ_DONE();
697 }
698 
699 /*
700  * _readOpExpr
701  */
702 static OpExpr *
704 {
706 
707  READ_OID_FIELD(opno);
708  READ_OID_FIELD(opfuncid);
709  READ_OID_FIELD(opresulttype);
710  READ_BOOL_FIELD(opretset);
711  READ_OID_FIELD(opcollid);
712  READ_OID_FIELD(inputcollid);
714  READ_LOCATION_FIELD(location);
715 
716  READ_DONE();
717 }
718 
719 /*
720  * _readDistinctExpr
721  */
722 static DistinctExpr *
724 {
726 
727  READ_OID_FIELD(opno);
728  READ_OID_FIELD(opfuncid);
729  READ_OID_FIELD(opresulttype);
730  READ_BOOL_FIELD(opretset);
731  READ_OID_FIELD(opcollid);
732  READ_OID_FIELD(inputcollid);
734  READ_LOCATION_FIELD(location);
735 
736  READ_DONE();
737 }
738 
739 /*
740  * _readNullIfExpr
741  */
742 static NullIfExpr *
744 {
746 
747  READ_OID_FIELD(opno);
748  READ_OID_FIELD(opfuncid);
749  READ_OID_FIELD(opresulttype);
750  READ_BOOL_FIELD(opretset);
751  READ_OID_FIELD(opcollid);
752  READ_OID_FIELD(inputcollid);
754  READ_LOCATION_FIELD(location);
755 
756  READ_DONE();
757 }
758 
759 /*
760  * _readScalarArrayOpExpr
761  */
762 static ScalarArrayOpExpr *
764 {
766 
767  READ_OID_FIELD(opno);
768  READ_OID_FIELD(opfuncid);
769  READ_BOOL_FIELD(useOr);
770  READ_OID_FIELD(inputcollid);
772  READ_LOCATION_FIELD(location);
773 
774  READ_DONE();
775 }
776 
777 /*
778  * _readBoolExpr
779  */
780 static BoolExpr *
782 {
784 
785  /* do-it-yourself enum representation */
786  token = pg_strtok(&length); /* skip :boolop */
787  token = pg_strtok(&length); /* get field value */
788  if (strncmp(token, "and", 3) == 0)
789  local_node->boolop = AND_EXPR;
790  else if (strncmp(token, "or", 2) == 0)
791  local_node->boolop = OR_EXPR;
792  else if (strncmp(token, "not", 3) == 0)
793  local_node->boolop = NOT_EXPR;
794  else
795  elog(ERROR, "unrecognized boolop \"%.*s\"", length, token);
796 
798  READ_LOCATION_FIELD(location);
799 
800  READ_DONE();
801 }
802 
803 /*
804  * _readSubLink
805  */
806 static SubLink *
808 {
810 
811  READ_ENUM_FIELD(subLinkType, SubLinkType);
812  READ_INT_FIELD(subLinkId);
813  READ_NODE_FIELD(testexpr);
814  READ_NODE_FIELD(operName);
815  READ_NODE_FIELD(subselect);
816  READ_LOCATION_FIELD(location);
817 
818  READ_DONE();
819 }
820 
821 /*
822  * _readSubPlan is not needed since it doesn't appear in stored rules.
823  */
824 
825 /*
826  * _readFieldSelect
827  */
828 static FieldSelect *
830 {
832 
834  READ_INT_FIELD(fieldnum);
835  READ_OID_FIELD(resulttype);
836  READ_INT_FIELD(resulttypmod);
837  READ_OID_FIELD(resultcollid);
838 
839  READ_DONE();
840 }
841 
842 /*
843  * _readFieldStore
844  */
845 static FieldStore *
847 {
849 
851  READ_NODE_FIELD(newvals);
852  READ_NODE_FIELD(fieldnums);
853  READ_OID_FIELD(resulttype);
854 
855  READ_DONE();
856 }
857 
858 /*
859  * _readRelabelType
860  */
861 static RelabelType *
863 {
865 
867  READ_OID_FIELD(resulttype);
868  READ_INT_FIELD(resulttypmod);
869  READ_OID_FIELD(resultcollid);
870  READ_ENUM_FIELD(relabelformat, CoercionForm);
871  READ_LOCATION_FIELD(location);
872 
873  READ_DONE();
874 }
875 
876 /*
877  * _readCoerceViaIO
878  */
879 static CoerceViaIO *
881 {
883 
885  READ_OID_FIELD(resulttype);
886  READ_OID_FIELD(resultcollid);
887  READ_ENUM_FIELD(coerceformat, CoercionForm);
888  READ_LOCATION_FIELD(location);
889 
890  READ_DONE();
891 }
892 
893 /*
894  * _readArrayCoerceExpr
895  */
896 static ArrayCoerceExpr *
898 {
900 
902  READ_NODE_FIELD(elemexpr);
903  READ_OID_FIELD(resulttype);
904  READ_INT_FIELD(resulttypmod);
905  READ_OID_FIELD(resultcollid);
906  READ_ENUM_FIELD(coerceformat, CoercionForm);
907  READ_LOCATION_FIELD(location);
908 
909  READ_DONE();
910 }
911 
912 /*
913  * _readConvertRowtypeExpr
914  */
915 static ConvertRowtypeExpr *
917 {
919 
921  READ_OID_FIELD(resulttype);
922  READ_ENUM_FIELD(convertformat, CoercionForm);
923  READ_LOCATION_FIELD(location);
924 
925  READ_DONE();
926 }
927 
928 /*
929  * _readCollateExpr
930  */
931 static CollateExpr *
933 {
935 
937  READ_OID_FIELD(collOid);
938  READ_LOCATION_FIELD(location);
939 
940  READ_DONE();
941 }
942 
943 /*
944  * _readCaseExpr
945  */
946 static CaseExpr *
948 {
950 
951  READ_OID_FIELD(casetype);
952  READ_OID_FIELD(casecollid);
955  READ_NODE_FIELD(defresult);
956  READ_LOCATION_FIELD(location);
957 
958  READ_DONE();
959 }
960 
961 /*
962  * _readCaseWhen
963  */
964 static CaseWhen *
966 {
968 
969  READ_NODE_FIELD(expr);
970  READ_NODE_FIELD(result);
971  READ_LOCATION_FIELD(location);
972 
973  READ_DONE();
974 }
975 
976 /*
977  * _readCaseTestExpr
978  */
979 static CaseTestExpr *
981 {
983 
984  READ_OID_FIELD(typeId);
985  READ_INT_FIELD(typeMod);
986  READ_OID_FIELD(collation);
987 
988  READ_DONE();
989 }
990 
991 /*
992  * _readArrayExpr
993  */
994 static ArrayExpr *
996 {
998 
999  READ_OID_FIELD(array_typeid);
1000  READ_OID_FIELD(array_collid);
1001  READ_OID_FIELD(element_typeid);
1002  READ_NODE_FIELD(elements);
1003  READ_BOOL_FIELD(multidims);
1004  READ_LOCATION_FIELD(location);
1005 
1006  READ_DONE();
1007 }
1008 
1009 /*
1010  * _readRowExpr
1011  */
1012 static RowExpr *
1014 {
1016 
1018  READ_OID_FIELD(row_typeid);
1019  READ_ENUM_FIELD(row_format, CoercionForm);
1020  READ_NODE_FIELD(colnames);
1021  READ_LOCATION_FIELD(location);
1022 
1023  READ_DONE();
1024 }
1025 
1026 /*
1027  * _readRowCompareExpr
1028  */
1029 static RowCompareExpr *
1031 {
1033 
1035  READ_NODE_FIELD(opnos);
1036  READ_NODE_FIELD(opfamilies);
1037  READ_NODE_FIELD(inputcollids);
1038  READ_NODE_FIELD(largs);
1039  READ_NODE_FIELD(rargs);
1040 
1041  READ_DONE();
1042 }
1043 
1044 /*
1045  * _readCoalesceExpr
1046  */
1047 static CoalesceExpr *
1049 {
1051 
1052  READ_OID_FIELD(coalescetype);
1053  READ_OID_FIELD(coalescecollid);
1055  READ_LOCATION_FIELD(location);
1056 
1057  READ_DONE();
1058 }
1059 
1060 /*
1061  * _readMinMaxExpr
1062  */
1063 static MinMaxExpr *
1065 {
1067 
1068  READ_OID_FIELD(minmaxtype);
1069  READ_OID_FIELD(minmaxcollid);
1070  READ_OID_FIELD(inputcollid);
1073  READ_LOCATION_FIELD(location);
1074 
1075  READ_DONE();
1076 }
1077 
1078 /*
1079  * _readSQLValueFunction
1080  */
1081 static SQLValueFunction *
1083 {
1085 
1088  READ_INT_FIELD(typmod);
1089  READ_LOCATION_FIELD(location);
1090 
1091  READ_DONE();
1092 }
1093 
1094 /*
1095  * _readXmlExpr
1096  */
1097 static XmlExpr *
1099 {
1101 
1104  READ_NODE_FIELD(named_args);
1105  READ_NODE_FIELD(arg_names);
1109  READ_INT_FIELD(typmod);
1110  READ_LOCATION_FIELD(location);
1111 
1112  READ_DONE();
1113 }
1114 
1115 /*
1116  * _readNullTest
1117  */
1118 static NullTest *
1120 {
1122 
1124  READ_ENUM_FIELD(nulltesttype, NullTestType);
1125  READ_BOOL_FIELD(argisrow);
1126  READ_LOCATION_FIELD(location);
1127 
1128  READ_DONE();
1129 }
1130 
1131 /*
1132  * _readBooleanTest
1133  */
1134 static BooleanTest *
1136 {
1138 
1140  READ_ENUM_FIELD(booltesttype, BoolTestType);
1141  READ_LOCATION_FIELD(location);
1142 
1143  READ_DONE();
1144 }
1145 
1146 /*
1147  * _readCoerceToDomain
1148  */
1149 static CoerceToDomain *
1151 {
1153 
1155  READ_OID_FIELD(resulttype);
1156  READ_INT_FIELD(resulttypmod);
1157  READ_OID_FIELD(resultcollid);
1158  READ_ENUM_FIELD(coercionformat, CoercionForm);
1159  READ_LOCATION_FIELD(location);
1160 
1161  READ_DONE();
1162 }
1163 
1164 /*
1165  * _readCoerceToDomainValue
1166  */
1167 static CoerceToDomainValue *
1169 {
1171 
1172  READ_OID_FIELD(typeId);
1173  READ_INT_FIELD(typeMod);
1174  READ_OID_FIELD(collation);
1175  READ_LOCATION_FIELD(location);
1176 
1177  READ_DONE();
1178 }
1179 
1180 /*
1181  * _readSetToDefault
1182  */
1183 static SetToDefault *
1185 {
1187 
1188  READ_OID_FIELD(typeId);
1189  READ_INT_FIELD(typeMod);
1190  READ_OID_FIELD(collation);
1191  READ_LOCATION_FIELD(location);
1192 
1193  READ_DONE();
1194 }
1195 
1196 /*
1197  * _readCurrentOfExpr
1198  */
1199 static CurrentOfExpr *
1201 {
1203 
1204  READ_UINT_FIELD(cvarno);
1205  READ_STRING_FIELD(cursor_name);
1206  READ_INT_FIELD(cursor_param);
1207 
1208  READ_DONE();
1209 }
1210 
1211 /*
1212  * _readNextValueExpr
1213  */
1214 static NextValueExpr *
1216 {
1218 
1219  READ_OID_FIELD(seqid);
1220  READ_OID_FIELD(typeId);
1221 
1222  READ_DONE();
1223 }
1224 
1225 /*
1226  * _readInferenceElem
1227  */
1228 static InferenceElem *
1230 {
1232 
1233  READ_NODE_FIELD(expr);
1234  READ_OID_FIELD(infercollid);
1235  READ_OID_FIELD(inferopclass);
1236 
1237  READ_DONE();
1238 }
1239 
1240 /*
1241  * _readTargetEntry
1242  */
1243 static TargetEntry *
1245 {
1247 
1248  READ_NODE_FIELD(expr);
1249  READ_INT_FIELD(resno);
1250  READ_STRING_FIELD(resname);
1251  READ_UINT_FIELD(ressortgroupref);
1252  READ_OID_FIELD(resorigtbl);
1253  READ_INT_FIELD(resorigcol);
1254  READ_BOOL_FIELD(resjunk);
1255 
1256  READ_DONE();
1257 }
1258 
1259 /*
1260  * _readRangeTblRef
1261  */
1262 static RangeTblRef *
1264 {
1266 
1267  READ_INT_FIELD(rtindex);
1268 
1269  READ_DONE();
1270 }
1271 
1272 /*
1273  * _readJoinExpr
1274  */
1275 static JoinExpr *
1277 {
1279 
1280  READ_ENUM_FIELD(jointype, JoinType);
1281  READ_BOOL_FIELD(isNatural);
1282  READ_NODE_FIELD(larg);
1283  READ_NODE_FIELD(rarg);
1284  READ_NODE_FIELD(usingClause);
1285  READ_NODE_FIELD(quals);
1286  READ_NODE_FIELD(alias);
1287  READ_INT_FIELD(rtindex);
1288 
1289  READ_DONE();
1290 }
1291 
1292 /*
1293  * _readFromExpr
1294  */
1295 static FromExpr *
1297 {
1299 
1300  READ_NODE_FIELD(fromlist);
1301  READ_NODE_FIELD(quals);
1302 
1303  READ_DONE();
1304 }
1305 
1306 /*
1307  * _readOnConflictExpr
1308  */
1309 static OnConflictExpr *
1311 {
1313 
1315  READ_NODE_FIELD(arbiterElems);
1316  READ_NODE_FIELD(arbiterWhere);
1317  READ_OID_FIELD(constraint);
1318  READ_NODE_FIELD(onConflictSet);
1319  READ_NODE_FIELD(onConflictWhere);
1320  READ_INT_FIELD(exclRelIndex);
1321  READ_NODE_FIELD(exclRelTlist);
1322 
1323  READ_DONE();
1324 }
1325 
1326 /*
1327  * Stuff from parsenodes.h.
1328  */
1329 
1330 /*
1331  * _readRangeTblEntry
1332  */
1333 static RangeTblEntry *
1335 {
1337 
1338  /* put alias + eref first to make dump more legible */
1339  READ_NODE_FIELD(alias);
1340  READ_NODE_FIELD(eref);
1341  READ_ENUM_FIELD(rtekind, RTEKind);
1342 
1343  switch (local_node->rtekind)
1344  {
1345  case RTE_RELATION:
1346  READ_OID_FIELD(relid);
1347  READ_CHAR_FIELD(relkind);
1348  READ_NODE_FIELD(tablesample);
1349  break;
1350  case RTE_SUBQUERY:
1351  READ_NODE_FIELD(subquery);
1352  READ_BOOL_FIELD(security_barrier);
1353  break;
1354  case RTE_JOIN:
1355  READ_ENUM_FIELD(jointype, JoinType);
1356  READ_NODE_FIELD(joinaliasvars);
1357  break;
1358  case RTE_FUNCTION:
1360  READ_BOOL_FIELD(funcordinality);
1361  break;
1362  case RTE_TABLEFUNC:
1363  READ_NODE_FIELD(tablefunc);
1364  break;
1365  case RTE_VALUES:
1366  READ_NODE_FIELD(values_lists);
1367  READ_NODE_FIELD(coltypes);
1368  READ_NODE_FIELD(coltypmods);
1369  READ_NODE_FIELD(colcollations);
1370  break;
1371  case RTE_CTE:
1372  READ_STRING_FIELD(ctename);
1373  READ_UINT_FIELD(ctelevelsup);
1374  READ_BOOL_FIELD(self_reference);
1375  READ_NODE_FIELD(coltypes);
1376  READ_NODE_FIELD(coltypmods);
1377  READ_NODE_FIELD(colcollations);
1378  break;
1379  case RTE_NAMEDTUPLESTORE:
1380  READ_STRING_FIELD(enrname);
1381  READ_FLOAT_FIELD(enrtuples);
1382  READ_OID_FIELD(relid);
1383  READ_NODE_FIELD(coltypes);
1384  READ_NODE_FIELD(coltypmods);
1385  READ_NODE_FIELD(colcollations);
1386  break;
1387  default:
1388  elog(ERROR, "unrecognized RTE kind: %d",
1389  (int) local_node->rtekind);
1390  break;
1391  }
1392 
1393  READ_BOOL_FIELD(lateral);
1394  READ_BOOL_FIELD(inh);
1395  READ_BOOL_FIELD(inFromCl);
1396  READ_UINT_FIELD(requiredPerms);
1397  READ_OID_FIELD(checkAsUser);
1398  READ_BITMAPSET_FIELD(selectedCols);
1399  READ_BITMAPSET_FIELD(insertedCols);
1400  READ_BITMAPSET_FIELD(updatedCols);
1401  READ_NODE_FIELD(securityQuals);
1402 
1403  READ_DONE();
1404 }
1405 
1406 /*
1407  * _readRangeTblFunction
1408  */
1409 static RangeTblFunction *
1411 {
1413 
1414  READ_NODE_FIELD(funcexpr);
1415  READ_INT_FIELD(funccolcount);
1416  READ_NODE_FIELD(funccolnames);
1417  READ_NODE_FIELD(funccoltypes);
1418  READ_NODE_FIELD(funccoltypmods);
1419  READ_NODE_FIELD(funccolcollations);
1420  READ_BITMAPSET_FIELD(funcparams);
1421 
1422  READ_DONE();
1423 }
1424 
1425 /*
1426  * _readTableSampleClause
1427  */
1428 static TableSampleClause *
1430 {
1432 
1433  READ_OID_FIELD(tsmhandler);
1435  READ_NODE_FIELD(repeatable);
1436 
1437  READ_DONE();
1438 }
1439 
1440 /*
1441  * _readDefElem
1442  */
1443 static DefElem *
1445 {
1447 
1448  READ_STRING_FIELD(defnamespace);
1449  READ_STRING_FIELD(defname);
1451  READ_ENUM_FIELD(defaction, DefElemAction);
1452  READ_LOCATION_FIELD(location);
1453 
1454  READ_DONE();
1455 }
1456 
1457 /*
1458  * _readPlannedStmt
1459  */
1460 static PlannedStmt *
1462 {
1464 
1465  READ_ENUM_FIELD(commandType, CmdType);
1466  READ_UINT64_FIELD(queryId);
1467  READ_BOOL_FIELD(hasReturning);
1468  READ_BOOL_FIELD(hasModifyingCTE);
1469  READ_BOOL_FIELD(canSetTag);
1470  READ_BOOL_FIELD(transientPlan);
1471  READ_BOOL_FIELD(dependsOnRole);
1472  READ_BOOL_FIELD(parallelModeNeeded);
1473  READ_NODE_FIELD(planTree);
1474  READ_NODE_FIELD(rtable);
1475  READ_NODE_FIELD(resultRelations);
1476  READ_NODE_FIELD(nonleafResultRelations);
1477  READ_NODE_FIELD(rootResultRelations);
1478  READ_NODE_FIELD(subplans);
1479  READ_BITMAPSET_FIELD(rewindPlanIDs);
1480  READ_NODE_FIELD(rowMarks);
1481  READ_NODE_FIELD(relationOids);
1482  READ_NODE_FIELD(invalItems);
1483  READ_NODE_FIELD(paramExecTypes);
1484  READ_NODE_FIELD(utilityStmt);
1485  READ_LOCATION_FIELD(stmt_location);
1486  READ_LOCATION_FIELD(stmt_len);
1487 
1488  READ_DONE();
1489 }
1490 
1491 /*
1492  * ReadCommonPlan
1493  * Assign the basic stuff of all nodes that inherit from Plan
1494  */
1495 static void
1496 ReadCommonPlan(Plan *local_node)
1497 {
1498  READ_TEMP_LOCALS();
1499 
1500  READ_FLOAT_FIELD(startup_cost);
1501  READ_FLOAT_FIELD(total_cost);
1502  READ_FLOAT_FIELD(plan_rows);
1503  READ_INT_FIELD(plan_width);
1504  READ_BOOL_FIELD(parallel_aware);
1505  READ_BOOL_FIELD(parallel_safe);
1506  READ_INT_FIELD(plan_node_id);
1507  READ_NODE_FIELD(targetlist);
1508  READ_NODE_FIELD(qual);
1509  READ_NODE_FIELD(lefttree);
1510  READ_NODE_FIELD(righttree);
1511  READ_NODE_FIELD(initPlan);
1512  READ_BITMAPSET_FIELD(extParam);
1513  READ_BITMAPSET_FIELD(allParam);
1514 }
1515 
1516 /*
1517  * _readPlan
1518  */
1519 static Plan *
1521 {
1523 
1524  ReadCommonPlan(local_node);
1525 
1526  READ_DONE();
1527 }
1528 
1529 /*
1530  * _readResult
1531  */
1532 static Result *
1534 {
1536 
1537  ReadCommonPlan(&local_node->plan);
1538 
1539  READ_NODE_FIELD(resconstantqual);
1540 
1541  READ_DONE();
1542 }
1543 
1544 /*
1545  * _readProjectSet
1546  */
1547 static ProjectSet *
1549 {
1551 
1552  ReadCommonPlan(&local_node->plan);
1553 
1554  READ_DONE();
1555 }
1556 
1557 /*
1558  * _readModifyTable
1559  */
1560 static ModifyTable *
1562 {
1564 
1565  ReadCommonPlan(&local_node->plan);
1566 
1567  READ_ENUM_FIELD(operation, CmdType);
1568  READ_BOOL_FIELD(canSetTag);
1569  READ_UINT_FIELD(nominalRelation);
1570  READ_NODE_FIELD(partitioned_rels);
1571  READ_NODE_FIELD(resultRelations);
1572  READ_INT_FIELD(resultRelIndex);
1573  READ_INT_FIELD(rootResultRelIndex);
1574  READ_NODE_FIELD(plans);
1575  READ_NODE_FIELD(withCheckOptionLists);
1576  READ_NODE_FIELD(returningLists);
1577  READ_NODE_FIELD(fdwPrivLists);
1578  READ_BITMAPSET_FIELD(fdwDirectModifyPlans);
1579  READ_NODE_FIELD(rowMarks);
1580  READ_INT_FIELD(epqParam);
1581  READ_ENUM_FIELD(onConflictAction, OnConflictAction);
1582  READ_NODE_FIELD(arbiterIndexes);
1583  READ_NODE_FIELD(onConflictSet);
1584  READ_NODE_FIELD(onConflictWhere);
1585  READ_UINT_FIELD(exclRelRTI);
1586  READ_NODE_FIELD(exclRelTlist);
1587 
1588  READ_DONE();
1589 }
1590 
1591 /*
1592  * _readAppend
1593  */
1594 static Append *
1596 {
1598 
1599  ReadCommonPlan(&local_node->plan);
1600 
1601  READ_NODE_FIELD(partitioned_rels);
1602  READ_NODE_FIELD(appendplans);
1603 
1604  READ_DONE();
1605 }
1606 
1607 /*
1608  * _readMergeAppend
1609  */
1610 static MergeAppend *
1612 {
1614 
1615  ReadCommonPlan(&local_node->plan);
1616 
1617  READ_NODE_FIELD(partitioned_rels);
1618  READ_NODE_FIELD(mergeplans);
1619  READ_INT_FIELD(numCols);
1620  READ_ATTRNUMBER_ARRAY(sortColIdx, local_node->numCols);
1621  READ_OID_ARRAY(sortOperators, local_node->numCols);
1622  READ_OID_ARRAY(collations, local_node->numCols);
1623  READ_BOOL_ARRAY(nullsFirst, local_node->numCols);
1624 
1625  READ_DONE();
1626 }
1627 
1628 /*
1629  * _readRecursiveUnion
1630  */
1631 static RecursiveUnion *
1633 {
1635 
1636  ReadCommonPlan(&local_node->plan);
1637 
1638  READ_INT_FIELD(wtParam);
1639  READ_INT_FIELD(numCols);
1640  READ_ATTRNUMBER_ARRAY(dupColIdx, local_node->numCols);
1641  READ_OID_ARRAY(dupOperators, local_node->numCols);
1642  READ_LONG_FIELD(numGroups);
1643 
1644  READ_DONE();
1645 }
1646 
1647 /*
1648  * _readBitmapAnd
1649  */
1650 static BitmapAnd *
1652 {
1654 
1655  ReadCommonPlan(&local_node->plan);
1656 
1657  READ_NODE_FIELD(bitmapplans);
1658 
1659  READ_DONE();
1660 }
1661 
1662 /*
1663  * _readBitmapOr
1664  */
1665 static BitmapOr *
1667 {
1669 
1670  ReadCommonPlan(&local_node->plan);
1671 
1672  READ_BOOL_FIELD(isshared);
1673  READ_NODE_FIELD(bitmapplans);
1674 
1675  READ_DONE();
1676 }
1677 
1678 /*
1679  * ReadCommonScan
1680  * Assign the basic stuff of all nodes that inherit from Scan
1681  */
1682 static void
1683 ReadCommonScan(Scan *local_node)
1684 {
1685  READ_TEMP_LOCALS();
1686 
1687  ReadCommonPlan(&local_node->plan);
1688 
1689  READ_UINT_FIELD(scanrelid);
1690 }
1691 
1692 /*
1693  * _readScan
1694  */
1695 static Scan *
1697 {
1699 
1700  ReadCommonScan(local_node);
1701 
1702  READ_DONE();
1703 }
1704 
1705 /*
1706  * _readSeqScan
1707  */
1708 static SeqScan *
1710 {
1712 
1713  ReadCommonScan(local_node);
1714 
1715  READ_DONE();
1716 }
1717 
1718 /*
1719  * _readSampleScan
1720  */
1721 static SampleScan *
1723 {
1725 
1726  ReadCommonScan(&local_node->scan);
1727 
1728  READ_NODE_FIELD(tablesample);
1729 
1730  READ_DONE();
1731 }
1732 
1733 /*
1734  * _readIndexScan
1735  */
1736 static IndexScan *
1738 {
1740 
1741  ReadCommonScan(&local_node->scan);
1742 
1743  READ_OID_FIELD(indexid);
1744  READ_NODE_FIELD(indexqual);
1745  READ_NODE_FIELD(indexqualorig);
1746  READ_NODE_FIELD(indexorderby);
1747  READ_NODE_FIELD(indexorderbyorig);
1748  READ_NODE_FIELD(indexorderbyops);
1749  READ_ENUM_FIELD(indexorderdir, ScanDirection);
1750 
1751  READ_DONE();
1752 }
1753 
1754 /*
1755  * _readIndexOnlyScan
1756  */
1757 static IndexOnlyScan *
1759 {
1761 
1762  ReadCommonScan(&local_node->scan);
1763 
1764  READ_OID_FIELD(indexid);
1765  READ_NODE_FIELD(indexqual);
1766  READ_NODE_FIELD(indexorderby);
1767  READ_NODE_FIELD(indextlist);
1768  READ_ENUM_FIELD(indexorderdir, ScanDirection);
1769 
1770  READ_DONE();
1771 }
1772 
1773 /*
1774  * _readBitmapIndexScan
1775  */
1776 static BitmapIndexScan *
1778 {
1780 
1781  ReadCommonScan(&local_node->scan);
1782 
1783  READ_OID_FIELD(indexid);
1784  READ_BOOL_FIELD(isshared);
1785  READ_NODE_FIELD(indexqual);
1786  READ_NODE_FIELD(indexqualorig);
1787 
1788  READ_DONE();
1789 }
1790 
1791 /*
1792  * _readBitmapHeapScan
1793  */
1794 static BitmapHeapScan *
1796 {
1798 
1799  ReadCommonScan(&local_node->scan);
1800 
1801  READ_NODE_FIELD(bitmapqualorig);
1802 
1803  READ_DONE();
1804 }
1805 
1806 /*
1807  * _readTidScan
1808  */
1809 static TidScan *
1811 {
1813 
1814  ReadCommonScan(&local_node->scan);
1815 
1816  READ_NODE_FIELD(tidquals);
1817 
1818  READ_DONE();
1819 }
1820 
1821 /*
1822  * _readSubqueryScan
1823  */
1824 static SubqueryScan *
1826 {
1828 
1829  ReadCommonScan(&local_node->scan);
1830 
1831  READ_NODE_FIELD(subplan);
1832 
1833  READ_DONE();
1834 }
1835 
1836 /*
1837  * _readFunctionScan
1838  */
1839 static FunctionScan *
1841 {
1843 
1844  ReadCommonScan(&local_node->scan);
1845 
1847  READ_BOOL_FIELD(funcordinality);
1848 
1849  READ_DONE();
1850 }
1851 
1852 /*
1853  * _readValuesScan
1854  */
1855 static ValuesScan *
1857 {
1859 
1860  ReadCommonScan(&local_node->scan);
1861 
1862  READ_NODE_FIELD(values_lists);
1863 
1864  READ_DONE();
1865 }
1866 
1867 /*
1868  * _readTableFuncScan
1869  */
1870 static TableFuncScan *
1872 {
1874 
1875  ReadCommonScan(&local_node->scan);
1876 
1877  READ_NODE_FIELD(tablefunc);
1878 
1879  READ_DONE();
1880 }
1881 
1882 /*
1883  * _readCteScan
1884  */
1885 static CteScan *
1887 {
1889 
1890  ReadCommonScan(&local_node->scan);
1891 
1892  READ_INT_FIELD(ctePlanId);
1893  READ_INT_FIELD(cteParam);
1894 
1895  READ_DONE();
1896 }
1897 
1898 /*
1899  * _readWorkTableScan
1900  */
1901 static WorkTableScan *
1903 {
1905 
1906  ReadCommonScan(&local_node->scan);
1907 
1908  READ_INT_FIELD(wtParam);
1909 
1910  READ_DONE();
1911 }
1912 
1913 /*
1914  * _readForeignScan
1915  */
1916 static ForeignScan *
1918 {
1920 
1921  ReadCommonScan(&local_node->scan);
1922 
1923  READ_ENUM_FIELD(operation, CmdType);
1924  READ_OID_FIELD(fs_server);
1925  READ_NODE_FIELD(fdw_exprs);
1926  READ_NODE_FIELD(fdw_private);
1927  READ_NODE_FIELD(fdw_scan_tlist);
1928  READ_NODE_FIELD(fdw_recheck_quals);
1929  READ_BITMAPSET_FIELD(fs_relids);
1930  READ_BOOL_FIELD(fsSystemCol);
1931 
1932  READ_DONE();
1933 }
1934 
1935 /*
1936  * _readCustomScan
1937  */
1938 static CustomScan *
1940 {
1942  char *custom_name;
1943  const CustomScanMethods *methods;
1944 
1945  ReadCommonScan(&local_node->scan);
1946 
1947  READ_UINT_FIELD(flags);
1948  READ_NODE_FIELD(custom_plans);
1949  READ_NODE_FIELD(custom_exprs);
1950  READ_NODE_FIELD(custom_private);
1951  READ_NODE_FIELD(custom_scan_tlist);
1952  READ_BITMAPSET_FIELD(custom_relids);
1953 
1954  /* Lookup CustomScanMethods by CustomName */
1955  token = pg_strtok(&length); /* skip methods: */
1956  token = pg_strtok(&length); /* CustomName */
1957  custom_name = nullable_string(token, length);
1958  methods = GetCustomScanMethods(custom_name, false);
1959  local_node->methods = methods;
1960 
1961  READ_DONE();
1962 }
1963 
1964 /*
1965  * ReadCommonJoin
1966  * Assign the basic stuff of all nodes that inherit from Join
1967  */
1968 static void
1969 ReadCommonJoin(Join *local_node)
1970 {
1971  READ_TEMP_LOCALS();
1972 
1973  ReadCommonPlan(&local_node->plan);
1974 
1975  READ_ENUM_FIELD(jointype, JoinType);
1976  READ_BOOL_FIELD(inner_unique);
1977  READ_NODE_FIELD(joinqual);
1978 }
1979 
1980 /*
1981  * _readJoin
1982  */
1983 static Join *
1985 {
1987 
1988  ReadCommonJoin(local_node);
1989 
1990  READ_DONE();
1991 }
1992 
1993 /*
1994  * _readNestLoop
1995  */
1996 static NestLoop *
1998 {
2000 
2001  ReadCommonJoin(&local_node->join);
2002 
2003  READ_NODE_FIELD(nestParams);
2004 
2005  READ_DONE();
2006 }
2007 
2008 /*
2009  * _readMergeJoin
2010  */
2011 static MergeJoin *
2013 {
2014  int numCols;
2015 
2017 
2018  ReadCommonJoin(&local_node->join);
2019 
2020  READ_BOOL_FIELD(skip_mark_restore);
2021  READ_NODE_FIELD(mergeclauses);
2022 
2023  numCols = list_length(local_node->mergeclauses);
2024 
2025  READ_OID_ARRAY(mergeFamilies, numCols);
2026  READ_OID_ARRAY(mergeCollations, numCols);
2027  READ_INT_ARRAY(mergeStrategies, numCols);
2028  READ_BOOL_ARRAY(mergeNullsFirst, numCols);
2029 
2030  READ_DONE();
2031 }
2032 
2033 /*
2034  * _readHashJoin
2035  */
2036 static HashJoin *
2038 {
2040 
2041  ReadCommonJoin(&local_node->join);
2042 
2043  READ_NODE_FIELD(hashclauses);
2044 
2045  READ_DONE();
2046 }
2047 
2048 /*
2049  * _readMaterial
2050  */
2051 static Material *
2053 {
2055 
2056  ReadCommonPlan(&local_node->plan);
2057 
2058  READ_DONE();
2059 }
2060 
2061 /*
2062  * _readSort
2063  */
2064 static Sort *
2066 {
2067  READ_LOCALS(Sort);
2068 
2069  ReadCommonPlan(&local_node->plan);
2070 
2071  READ_INT_FIELD(numCols);
2072  READ_ATTRNUMBER_ARRAY(sortColIdx, local_node->numCols);
2073  READ_OID_ARRAY(sortOperators, local_node->numCols);
2074  READ_OID_ARRAY(collations, local_node->numCols);
2075  READ_BOOL_ARRAY(nullsFirst, local_node->numCols);
2076 
2077  READ_DONE();
2078 }
2079 
2080 /*
2081  * _readGroup
2082  */
2083 static Group *
2085 {
2086  READ_LOCALS(Group);
2087 
2088  ReadCommonPlan(&local_node->plan);
2089 
2090  READ_INT_FIELD(numCols);
2091  READ_ATTRNUMBER_ARRAY(grpColIdx, local_node->numCols);
2092  READ_OID_ARRAY(grpOperators, local_node->numCols);
2093 
2094  READ_DONE();
2095 }
2096 
2097 /*
2098  * _readAgg
2099  */
2100 static Agg *
2102 {
2103  READ_LOCALS(Agg);
2104 
2105  ReadCommonPlan(&local_node->plan);
2106 
2107  READ_ENUM_FIELD(aggstrategy, AggStrategy);
2108  READ_ENUM_FIELD(aggsplit, AggSplit);
2109  READ_INT_FIELD(numCols);
2110  READ_ATTRNUMBER_ARRAY(grpColIdx, local_node->numCols);
2111  READ_OID_ARRAY(grpOperators, local_node->numCols);
2112  READ_LONG_FIELD(numGroups);
2113  READ_BITMAPSET_FIELD(aggParams);
2114  READ_NODE_FIELD(groupingSets);
2115  READ_NODE_FIELD(chain);
2116 
2117  READ_DONE();
2118 }
2119 
2120 /*
2121  * _readWindowAgg
2122  */
2123 static WindowAgg *
2125 {
2127 
2128  ReadCommonPlan(&local_node->plan);
2129 
2130  READ_UINT_FIELD(winref);
2131  READ_INT_FIELD(partNumCols);
2132  READ_ATTRNUMBER_ARRAY(partColIdx, local_node->partNumCols);
2133  READ_OID_ARRAY(partOperators, local_node->partNumCols);
2134  READ_INT_FIELD(ordNumCols);
2135  READ_ATTRNUMBER_ARRAY(ordColIdx, local_node->ordNumCols);
2136  READ_OID_ARRAY(ordOperators, local_node->ordNumCols);
2137  READ_INT_FIELD(frameOptions);
2138  READ_NODE_FIELD(startOffset);
2139  READ_NODE_FIELD(endOffset);
2140 
2141  READ_DONE();
2142 }
2143 
2144 /*
2145  * _readUnique
2146  */
2147 static Unique *
2149 {
2151 
2152  ReadCommonPlan(&local_node->plan);
2153 
2154  READ_INT_FIELD(numCols);
2155  READ_ATTRNUMBER_ARRAY(uniqColIdx, local_node->numCols);
2156  READ_OID_ARRAY(uniqOperators, local_node->numCols);
2157 
2158  READ_DONE();
2159 }
2160 
2161 /*
2162  * _readGather
2163  */
2164 static Gather *
2166 {
2168 
2169  ReadCommonPlan(&local_node->plan);
2170 
2171  READ_INT_FIELD(num_workers);
2172  READ_INT_FIELD(rescan_param);
2173  READ_BOOL_FIELD(single_copy);
2174  READ_BOOL_FIELD(invisible);
2175  READ_BITMAPSET_FIELD(initParam);
2176 
2177  READ_DONE();
2178 }
2179 
2180 /*
2181  * _readGatherMerge
2182  */
2183 static GatherMerge *
2185 {
2187 
2188  ReadCommonPlan(&local_node->plan);
2189 
2190  READ_INT_FIELD(num_workers);
2191  READ_INT_FIELD(rescan_param);
2192  READ_INT_FIELD(numCols);
2193  READ_ATTRNUMBER_ARRAY(sortColIdx, local_node->numCols);
2194  READ_OID_ARRAY(sortOperators, local_node->numCols);
2195  READ_OID_ARRAY(collations, local_node->numCols);
2196  READ_BOOL_ARRAY(nullsFirst, local_node->numCols);
2197  READ_BITMAPSET_FIELD(initParam);
2198 
2199  READ_DONE();
2200 }
2201 
2202 /*
2203  * _readHash
2204  */
2205 static Hash *
2207 {
2208  READ_LOCALS(Hash);
2209 
2210  ReadCommonPlan(&local_node->plan);
2211 
2212  READ_OID_FIELD(skewTable);
2213  READ_INT_FIELD(skewColumn);
2214  READ_BOOL_FIELD(skewInherit);
2215 
2216  READ_DONE();
2217 }
2218 
2219 /*
2220  * _readSetOp
2221  */
2222 static SetOp *
2224 {
2225  READ_LOCALS(SetOp);
2226 
2227  ReadCommonPlan(&local_node->plan);
2228 
2229  READ_ENUM_FIELD(cmd, SetOpCmd);
2230  READ_ENUM_FIELD(strategy, SetOpStrategy);
2231  READ_INT_FIELD(numCols);
2232  READ_ATTRNUMBER_ARRAY(dupColIdx, local_node->numCols);
2233  READ_OID_ARRAY(dupOperators, local_node->numCols);
2234  READ_INT_FIELD(flagColIdx);
2235  READ_INT_FIELD(firstFlag);
2236  READ_LONG_FIELD(numGroups);
2237 
2238  READ_DONE();
2239 }
2240 
2241 /*
2242  * _readLockRows
2243  */
2244 static LockRows *
2246 {
2248 
2249  ReadCommonPlan(&local_node->plan);
2250 
2251  READ_NODE_FIELD(rowMarks);
2252  READ_INT_FIELD(epqParam);
2253 
2254  READ_DONE();
2255 }
2256 
2257 /*
2258  * _readLimit
2259  */
2260 static Limit *
2262 {
2263  READ_LOCALS(Limit);
2264 
2265  ReadCommonPlan(&local_node->plan);
2266 
2267  READ_NODE_FIELD(limitOffset);
2268  READ_NODE_FIELD(limitCount);
2269 
2270  READ_DONE();
2271 }
2272 
2273 /*
2274  * _readNestLoopParam
2275  */
2276 static NestLoopParam *
2278 {
2280 
2281  READ_INT_FIELD(paramno);
2282  READ_NODE_FIELD(paramval);
2283 
2284  READ_DONE();
2285 }
2286 
2287 /*
2288  * _readPlanRowMark
2289  */
2290 static PlanRowMark *
2292 {
2294 
2295  READ_UINT_FIELD(rti);
2296  READ_UINT_FIELD(prti);
2297  READ_UINT_FIELD(rowmarkId);
2298  READ_ENUM_FIELD(markType, RowMarkType);
2299  READ_INT_FIELD(allMarkTypes);
2301  READ_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2302  READ_BOOL_FIELD(isParent);
2303 
2304  READ_DONE();
2305 }
2306 
2307 /*
2308  * _readPlanInvalItem
2309  */
2310 static PlanInvalItem *
2312 {
2314 
2315  READ_INT_FIELD(cacheId);
2316  READ_UINT_FIELD(hashValue);
2317 
2318  READ_DONE();
2319 }
2320 
2321 /*
2322  * _readSubPlan
2323  */
2324 static SubPlan *
2326 {
2328 
2329  READ_ENUM_FIELD(subLinkType, SubLinkType);
2330  READ_NODE_FIELD(testexpr);
2331  READ_NODE_FIELD(paramIds);
2332  READ_INT_FIELD(plan_id);
2333  READ_STRING_FIELD(plan_name);
2334  READ_OID_FIELD(firstColType);
2335  READ_INT_FIELD(firstColTypmod);
2336  READ_OID_FIELD(firstColCollation);
2337  READ_BOOL_FIELD(useHashTable);
2338  READ_BOOL_FIELD(unknownEqFalse);
2339  READ_BOOL_FIELD(parallel_safe);
2340  READ_NODE_FIELD(setParam);
2341  READ_NODE_FIELD(parParam);
2343  READ_FLOAT_FIELD(startup_cost);
2344  READ_FLOAT_FIELD(per_call_cost);
2345 
2346  READ_DONE();
2347 }
2348 
2349 /*
2350  * _readAlternativeSubPlan
2351  */
2352 static AlternativeSubPlan *
2354 {
2356 
2357  READ_NODE_FIELD(subplans);
2358 
2359  READ_DONE();
2360 }
2361 
2362 /*
2363  * _readExtensibleNode
2364  */
2365 static ExtensibleNode *
2367 {
2368  const ExtensibleNodeMethods *methods;
2369  ExtensibleNode *local_node;
2370  const char *extnodename;
2371 
2372  READ_TEMP_LOCALS();
2373 
2374  token = pg_strtok(&length); /* skip :extnodename */
2375  token = pg_strtok(&length); /* get extnodename */
2376 
2377  extnodename = nullable_string(token, length);
2378  if (!extnodename)
2379  elog(ERROR, "extnodename has to be supplied");
2380  methods = GetExtensibleNodeMethods(extnodename, false);
2381 
2382  local_node = (ExtensibleNode *) newNode(methods->node_size,
2384  local_node->extnodename = extnodename;
2385 
2386  /* deserialize the private fields */
2387  methods->nodeRead(local_node);
2388 
2389  READ_DONE();
2390 }
2391 
2392 /*
2393  * _readPartitionBoundSpec
2394  */
2395 static PartitionBoundSpec *
2397 {
2399 
2400  READ_CHAR_FIELD(strategy);
2401  READ_BOOL_FIELD(is_default);
2402  READ_INT_FIELD(modulus);
2403  READ_INT_FIELD(remainder);
2404  READ_NODE_FIELD(listdatums);
2405  READ_NODE_FIELD(lowerdatums);
2406  READ_NODE_FIELD(upperdatums);
2407  READ_LOCATION_FIELD(location);
2408 
2409  READ_DONE();
2410 }
2411 
2412 /*
2413  * _readPartitionRangeDatum
2414  */
2415 static PartitionRangeDatum *
2417 {
2419 
2422  READ_LOCATION_FIELD(location);
2423 
2424  READ_DONE();
2425 }
2426 
2427 /*
2428  * parseNodeString
2429  *
2430  * Given a character string representing a node tree, parseNodeString creates
2431  * the internal node structure.
2432  *
2433  * The string to be read must already have been loaded into pg_strtok().
2434  */
2435 Node *
2437 {
2438  void *return_value;
2439 
2440  READ_TEMP_LOCALS();
2441 
2442  token = pg_strtok(&length);
2443 
2444 #define MATCH(tokname, namelen) \
2445  (length == namelen && memcmp(token, tokname, namelen) == 0)
2446 
2447  if (MATCH("QUERY", 5))
2448  return_value = _readQuery();
2449  else if (MATCH("WITHCHECKOPTION", 15))
2450  return_value = _readWithCheckOption();
2451  else if (MATCH("SORTGROUPCLAUSE", 15))
2452  return_value = _readSortGroupClause();
2453  else if (MATCH("GROUPINGSET", 11))
2454  return_value = _readGroupingSet();
2455  else if (MATCH("WINDOWCLAUSE", 12))
2456  return_value = _readWindowClause();
2457  else if (MATCH("ROWMARKCLAUSE", 13))
2458  return_value = _readRowMarkClause();
2459  else if (MATCH("COMMONTABLEEXPR", 15))
2460  return_value = _readCommonTableExpr();
2461  else if (MATCH("SETOPERATIONSTMT", 16))
2462  return_value = _readSetOperationStmt();
2463  else if (MATCH("ALIAS", 5))
2464  return_value = _readAlias();
2465  else if (MATCH("RANGEVAR", 8))
2466  return_value = _readRangeVar();
2467  else if (MATCH("INTOCLAUSE", 10))
2468  return_value = _readIntoClause();
2469  else if (MATCH("TABLEFUNC", 9))
2470  return_value = _readTableFunc();
2471  else if (MATCH("VAR", 3))
2472  return_value = _readVar();
2473  else if (MATCH("CONST", 5))
2474  return_value = _readConst();
2475  else if (MATCH("PARAM", 5))
2476  return_value = _readParam();
2477  else if (MATCH("AGGREF", 6))
2478  return_value = _readAggref();
2479  else if (MATCH("GROUPINGFUNC", 12))
2480  return_value = _readGroupingFunc();
2481  else if (MATCH("WINDOWFUNC", 10))
2482  return_value = _readWindowFunc();
2483  else if (MATCH("ARRAYREF", 8))
2484  return_value = _readArrayRef();
2485  else if (MATCH("FUNCEXPR", 8))
2486  return_value = _readFuncExpr();
2487  else if (MATCH("NAMEDARGEXPR", 12))
2488  return_value = _readNamedArgExpr();
2489  else if (MATCH("OPEXPR", 6))
2490  return_value = _readOpExpr();
2491  else if (MATCH("DISTINCTEXPR", 12))
2492  return_value = _readDistinctExpr();
2493  else if (MATCH("NULLIFEXPR", 10))
2494  return_value = _readNullIfExpr();
2495  else if (MATCH("SCALARARRAYOPEXPR", 17))
2496  return_value = _readScalarArrayOpExpr();
2497  else if (MATCH("BOOLEXPR", 8))
2498  return_value = _readBoolExpr();
2499  else if (MATCH("SUBLINK", 7))
2500  return_value = _readSubLink();
2501  else if (MATCH("FIELDSELECT", 11))
2502  return_value = _readFieldSelect();
2503  else if (MATCH("FIELDSTORE", 10))
2504  return_value = _readFieldStore();
2505  else if (MATCH("RELABELTYPE", 11))
2506  return_value = _readRelabelType();
2507  else if (MATCH("COERCEVIAIO", 11))
2508  return_value = _readCoerceViaIO();
2509  else if (MATCH("ARRAYCOERCEEXPR", 15))
2510  return_value = _readArrayCoerceExpr();
2511  else if (MATCH("CONVERTROWTYPEEXPR", 18))
2512  return_value = _readConvertRowtypeExpr();
2513  else if (MATCH("COLLATE", 7))
2514  return_value = _readCollateExpr();
2515  else if (MATCH("CASE", 4))
2516  return_value = _readCaseExpr();
2517  else if (MATCH("WHEN", 4))
2518  return_value = _readCaseWhen();
2519  else if (MATCH("CASETESTEXPR", 12))
2520  return_value = _readCaseTestExpr();
2521  else if (MATCH("ARRAY", 5))
2522  return_value = _readArrayExpr();
2523  else if (MATCH("ROW", 3))
2524  return_value = _readRowExpr();
2525  else if (MATCH("ROWCOMPARE", 10))
2526  return_value = _readRowCompareExpr();
2527  else if (MATCH("COALESCE", 8))
2528  return_value = _readCoalesceExpr();
2529  else if (MATCH("MINMAX", 6))
2530  return_value = _readMinMaxExpr();
2531  else if (MATCH("SQLVALUEFUNCTION", 16))
2532  return_value = _readSQLValueFunction();
2533  else if (MATCH("XMLEXPR", 7))
2534  return_value = _readXmlExpr();
2535  else if (MATCH("NULLTEST", 8))
2536  return_value = _readNullTest();
2537  else if (MATCH("BOOLEANTEST", 11))
2538  return_value = _readBooleanTest();
2539  else if (MATCH("COERCETODOMAIN", 14))
2540  return_value = _readCoerceToDomain();
2541  else if (MATCH("COERCETODOMAINVALUE", 19))
2542  return_value = _readCoerceToDomainValue();
2543  else if (MATCH("SETTODEFAULT", 12))
2544  return_value = _readSetToDefault();
2545  else if (MATCH("CURRENTOFEXPR", 13))
2546  return_value = _readCurrentOfExpr();
2547  else if (MATCH("NEXTVALUEEXPR", 13))
2548  return_value = _readNextValueExpr();
2549  else if (MATCH("INFERENCEELEM", 13))
2550  return_value = _readInferenceElem();
2551  else if (MATCH("TARGETENTRY", 11))
2552  return_value = _readTargetEntry();
2553  else if (MATCH("RANGETBLREF", 11))
2554  return_value = _readRangeTblRef();
2555  else if (MATCH("JOINEXPR", 8))
2556  return_value = _readJoinExpr();
2557  else if (MATCH("FROMEXPR", 8))
2558  return_value = _readFromExpr();
2559  else if (MATCH("ONCONFLICTEXPR", 14))
2560  return_value = _readOnConflictExpr();
2561  else if (MATCH("RTE", 3))
2562  return_value = _readRangeTblEntry();
2563  else if (MATCH("RANGETBLFUNCTION", 16))
2564  return_value = _readRangeTblFunction();
2565  else if (MATCH("TABLESAMPLECLAUSE", 17))
2566  return_value = _readTableSampleClause();
2567  else if (MATCH("NOTIFY", 6))
2568  return_value = _readNotifyStmt();
2569  else if (MATCH("DEFELEM", 7))
2570  return_value = _readDefElem();
2571  else if (MATCH("DECLARECURSOR", 13))
2572  return_value = _readDeclareCursorStmt();
2573  else if (MATCH("PLANNEDSTMT", 11))
2574  return_value = _readPlannedStmt();
2575  else if (MATCH("PLAN", 4))
2576  return_value = _readPlan();
2577  else if (MATCH("RESULT", 6))
2578  return_value = _readResult();
2579  else if (MATCH("PROJECTSET", 10))
2580  return_value = _readProjectSet();
2581  else if (MATCH("MODIFYTABLE", 11))
2582  return_value = _readModifyTable();
2583  else if (MATCH("APPEND", 6))
2584  return_value = _readAppend();
2585  else if (MATCH("MERGEAPPEND", 11))
2586  return_value = _readMergeAppend();
2587  else if (MATCH("RECURSIVEUNION", 14))
2588  return_value = _readRecursiveUnion();
2589  else if (MATCH("BITMAPAND", 9))
2590  return_value = _readBitmapAnd();
2591  else if (MATCH("BITMAPOR", 8))
2592  return_value = _readBitmapOr();
2593  else if (MATCH("SCAN", 4))
2594  return_value = _readScan();
2595  else if (MATCH("SEQSCAN", 7))
2596  return_value = _readSeqScan();
2597  else if (MATCH("SAMPLESCAN", 10))
2598  return_value = _readSampleScan();
2599  else if (MATCH("INDEXSCAN", 9))
2600  return_value = _readIndexScan();
2601  else if (MATCH("INDEXONLYSCAN", 13))
2602  return_value = _readIndexOnlyScan();
2603  else if (MATCH("BITMAPINDEXSCAN", 15))
2604  return_value = _readBitmapIndexScan();
2605  else if (MATCH("BITMAPHEAPSCAN", 14))
2606  return_value = _readBitmapHeapScan();
2607  else if (MATCH("TIDSCAN", 7))
2608  return_value = _readTidScan();
2609  else if (MATCH("SUBQUERYSCAN", 12))
2610  return_value = _readSubqueryScan();
2611  else if (MATCH("FUNCTIONSCAN", 12))
2612  return_value = _readFunctionScan();
2613  else if (MATCH("VALUESSCAN", 10))
2614  return_value = _readValuesScan();
2615  else if (MATCH("TABLEFUNCSCAN", 13))
2616  return_value = _readTableFuncScan();
2617  else if (MATCH("CTESCAN", 7))
2618  return_value = _readCteScan();
2619  else if (MATCH("WORKTABLESCAN", 13))
2620  return_value = _readWorkTableScan();
2621  else if (MATCH("FOREIGNSCAN", 11))
2622  return_value = _readForeignScan();
2623  else if (MATCH("CUSTOMSCAN", 10))
2624  return_value = _readCustomScan();
2625  else if (MATCH("JOIN", 4))
2626  return_value = _readJoin();
2627  else if (MATCH("NESTLOOP", 8))
2628  return_value = _readNestLoop();
2629  else if (MATCH("MERGEJOIN", 9))
2630  return_value = _readMergeJoin();
2631  else if (MATCH("HASHJOIN", 8))
2632  return_value = _readHashJoin();
2633  else if (MATCH("MATERIAL", 8))
2634  return_value = _readMaterial();
2635  else if (MATCH("SORT", 4))
2636  return_value = _readSort();
2637  else if (MATCH("GROUP", 5))
2638  return_value = _readGroup();
2639  else if (MATCH("AGG", 3))
2640  return_value = _readAgg();
2641  else if (MATCH("WINDOWAGG", 9))
2642  return_value = _readWindowAgg();
2643  else if (MATCH("UNIQUE", 6))
2644  return_value = _readUnique();
2645  else if (MATCH("GATHER", 6))
2646  return_value = _readGather();
2647  else if (MATCH("GATHERMERGE", 11))
2648  return_value = _readGatherMerge();
2649  else if (MATCH("HASH", 4))
2650  return_value = _readHash();
2651  else if (MATCH("SETOP", 5))
2652  return_value = _readSetOp();
2653  else if (MATCH("LOCKROWS", 8))
2654  return_value = _readLockRows();
2655  else if (MATCH("LIMIT", 5))
2656  return_value = _readLimit();
2657  else if (MATCH("NESTLOOPPARAM", 13))
2658  return_value = _readNestLoopParam();
2659  else if (MATCH("PLANROWMARK", 11))
2660  return_value = _readPlanRowMark();
2661  else if (MATCH("PLANINVALITEM", 13))
2662  return_value = _readPlanInvalItem();
2663  else if (MATCH("SUBPLAN", 7))
2664  return_value = _readSubPlan();
2665  else if (MATCH("ALTERNATIVESUBPLAN", 18))
2666  return_value = _readAlternativeSubPlan();
2667  else if (MATCH("EXTENSIBLENODE", 14))
2668  return_value = _readExtensibleNode();
2669  else if (MATCH("PARTITIONBOUNDSPEC", 18))
2670  return_value = _readPartitionBoundSpec();
2671  else if (MATCH("PARTITIONRANGEDATUM", 19))
2672  return_value = _readPartitionRangeDatum();
2673  else
2674  {
2675  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
2676  return_value = NULL; /* keep compiler quiet */
2677  }
2678 
2679  return (Node *) return_value;
2680 }
2681 
2682 
2683 /*
2684  * readDatum
2685  *
2686  * Given a string representation of a constant, recreate the appropriate
2687  * Datum. The string representation embeds length info, but not byValue,
2688  * so we must be told that.
2689  */
2690 Datum
2691 readDatum(bool typbyval)
2692 {
2693  Size length,
2694  i;
2695  int tokenLength;
2696  char *token;
2697  Datum res;
2698  char *s;
2699 
2700  /*
2701  * read the actual length of the value
2702  */
2703  token = pg_strtok(&tokenLength);
2704  length = atoui(token);
2705 
2706  token = pg_strtok(&tokenLength); /* read the '[' */
2707  if (token == NULL || token[0] != '[')
2708  elog(ERROR, "expected \"[\" to start datum, but got \"%s\"; length = %zu",
2709  token ? (const char *) token : "[NULL]", length);
2710 
2711  if (typbyval)
2712  {
2713  if (length > (Size) sizeof(Datum))
2714  elog(ERROR, "byval datum but length = %zu", length);
2715  res = (Datum) 0;
2716  s = (char *) (&res);
2717  for (i = 0; i < (Size) sizeof(Datum); i++)
2718  {
2719  token = pg_strtok(&tokenLength);
2720  s[i] = (char) atoi(token);
2721  }
2722  }
2723  else if (length <= 0)
2724  res = (Datum) NULL;
2725  else
2726  {
2727  s = (char *) palloc(length);
2728  for (i = 0; i < length; i++)
2729  {
2730  token = pg_strtok(&tokenLength);
2731  s[i] = (char) atoi(token);
2732  }
2733  res = PointerGetDatum(s);
2734  }
2735 
2736  token = pg_strtok(&tokenLength); /* read the ']' */
2737  if (token == NULL || token[0] != ']')
2738  elog(ERROR, "expected \"]\" to end datum, but got \"%s\"; length = %zu",
2739  token ? (const char *) token : "[NULL]", length);
2740 
2741  return res;
2742 }
2743 
2744 /*
2745  * readAttrNumberCols
2746  */
2747 AttrNumber *
2749 {
2750  int tokenLength,
2751  i;
2752  char *token;
2753  AttrNumber *attr_vals;
2754 
2755  if (numCols <= 0)
2756  return NULL;
2757 
2758  attr_vals = (AttrNumber *) palloc(numCols * sizeof(AttrNumber));
2759  for (i = 0; i < numCols; i++)
2760  {
2761  token = pg_strtok(&tokenLength);
2762  attr_vals[i] = atoi(token);
2763  }
2764 
2765  return attr_vals;
2766 }
2767 
2768 /*
2769  * readOidCols
2770  */
2771 Oid *
2772 readOidCols(int numCols)
2773 {
2774  int tokenLength,
2775  i;
2776  char *token;
2777  Oid *oid_vals;
2778 
2779  if (numCols <= 0)
2780  return NULL;
2781 
2782  oid_vals = (Oid *) palloc(numCols * sizeof(Oid));
2783  for (i = 0; i < numCols; i++)
2784  {
2785  token = pg_strtok(&tokenLength);
2786  oid_vals[i] = atooid(token);
2787  }
2788 
2789  return oid_vals;
2790 }
2791 
2792 /*
2793  * readIntCols
2794  */
2795 int *
2796 readIntCols(int numCols)
2797 {
2798  int tokenLength,
2799  i;
2800  char *token;
2801  int *int_vals;
2802 
2803  if (numCols <= 0)
2804  return NULL;
2805 
2806  int_vals = (int *) palloc(numCols * sizeof(int));
2807  for (i = 0; i < numCols; i++)
2808  {
2809  token = pg_strtok(&tokenLength);
2810  int_vals[i] = atoi(token);
2811  }
2812 
2813  return int_vals;
2814 }
2815 
2816 /*
2817  * readBoolCols
2818  */
2819 bool *
2820 readBoolCols(int numCols)
2821 {
2822  int tokenLength,
2823  i;
2824  char *token;
2825  bool *bool_vals;
2826 
2827  if (numCols <= 0)
2828  return NULL;
2829 
2830  bool_vals = (bool *) palloc(numCols * sizeof(bool));
2831  for (i = 0; i < numCols; i++)
2832  {
2833  token = pg_strtok(&tokenLength);
2834  bool_vals[i] = strtobool(token);
2835  }
2836 
2837  return bool_vals;
2838 }
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1119
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1276
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:453
#define atoui(x)
Definition: readfuncs.c:173
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1334
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1444
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1013
int length(const List *list)
Definition: list.c:1271
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:2012
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1064
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:382
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:666
Plan plan
Definition: plannodes.h:328
#define READ_BOOL_ARRAY(fldname, len)
Definition: readfuncs.c:158
static Hash * _readHash(void)
Definition: readfuncs.c:2206
char * pg_strtok(int *length)
Definition: read.c:107
static Result * _readResult(void)
Definition: readfuncs.c:1533
static Query * _readQuery(void)
Definition: readfuncs.c:235
static RowCompareExpr * _readRowCompareExpr(void)
Definition: readfuncs.c:1030
static Param * _readParam(void)
Definition: readfuncs.c:560
static PlanInvalItem * _readPlanInvalItem(void)
Definition: readfuncs.c:2311
ParamKind
Definition: primnodes.h:233
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2124
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:1737
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:283
static Scan * _readScan(void)
Definition: readfuncs.c:1696
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:687
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2245
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1200
PartitionRangeDatumKind
Definition: parsenodes.h:823
#define READ_LONG_FIELD(fldname)
Definition: readfuncs.c:81
#define PointerGetDatum(X)
Definition: postgres.h:562
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:932
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:1825
BoolTestType
Definition: primnodes.h:1202
#define strtobool(x)
Definition: readfuncs.c:175
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:1777
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:947
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:1840
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2396
#define READ_BOOL_FIELD(fldname)
Definition: readfuncs.c:112
XmlExprOp
Definition: primnodes.h:1128
QuerySource
Definition: parsenodes.h:38
static Unique * _readUnique(void)
Definition: readfuncs.c:2148
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1611
Definition: nodes.h:510
#define READ_LOCALS_NO_FIELDS(nodeTypeName)
Definition: readfuncs.c:49
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:624
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:361
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:703
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:1758
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:1651
NullTestType
Definition: primnodes.h:1179
unsigned int Oid
Definition: postgres_ext.h:31
Definition: primnodes.h:163
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1296
static Aggref * _readAggref(void)
Definition: readfuncs.c:578
SetOpStrategy
Definition: nodes.h:788
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:1997
OnCommitAction
Definition: primnodes.h:47
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1561
static NextValueExpr * _readNextValueExpr(void)
Definition: readfuncs.c:1215
JoinType
Definition: nodes.h:674
static DistinctExpr * _readDistinctExpr(void)
Definition: readfuncs.c:723
Oid * readOidCols(int numCols)
Definition: readfuncs.c:2772
static ArrayCoerceExpr * _readArrayCoerceExpr(void)
Definition: readfuncs.c:897
static TargetEntry * _readTargetEntry(void)
Definition: readfuncs.c:1244
#define newNode(size, tag)
Definition: nodes.h:548
static void ReadCommonPlan(Plan *local_node)
Definition: readfuncs.c:1496
static Agg * _readAgg(void)
Definition: readfuncs.c:2101
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:1709
MinMaxOp
Definition: primnodes.h:1061
SetOperation
Definition: parsenodes.h:1502
bool * readBoolCols(int numCols)
Definition: readfuncs.c:2820
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2353
static CteScan * _readCteScan(void)
Definition: readfuncs.c:1886
static GroupingFunc * _readGroupingFunc(void)
Definition: readfuncs.c:607
#define ERROR
Definition: elog.h:43
static CoerceToDomain * _readCoerceToDomain(void)
Definition: readfuncs.c:1150
static SubLink * _readSubLink(void)
Definition: readfuncs.c:807
static HashJoin * _readHashJoin(void)
Definition: readfuncs.c:2037
#define READ_FLOAT_FIELD(fldname)
Definition: readfuncs.c:106
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:1856
static ConvertRowtypeExpr * _readConvertRowtypeExpr(void)
Definition: readfuncs.c:916
#define READ_OID_ARRAY(fldname, len)
Definition: readfuncs.c:148
static struct @121 value
static OnConflictExpr * _readOnConflictExpr(void)
Definition: readfuncs.c:1310
RTEKind
Definition: parsenodes.h:935
static NullIfExpr * _readNullIfExpr(void)
Definition: readfuncs.c:743
static Append * _readAppend(void)
Definition: readfuncs.c:1595
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2366
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2291
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:829
int * readIntCols(int numCols)
Definition: readfuncs.c:2796
static ArrayRef * _readArrayRef(void)
Definition: readfuncs.c:646
ScanDirection
Definition: sdir.h:22
static CaseWhen * _readCaseWhen(void)
Definition: readfuncs.c:965
static SQLValueFunction * _readSQLValueFunction(void)
Definition: readfuncs.c:1082
#define READ_CHAR_FIELD(fldname)
Definition: readfuncs.c:93
AttrNumber * readAttrNumberCols(int numCols)
Definition: readfuncs.c:2748
#define MATCH(tokname, namelen)
#define atooid(x)
Definition: postgres_ext.h:42
static ForeignScan * _readForeignScan(void)
Definition: readfuncs.c:1917
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:862
WCOKind
Definition: parsenodes.h:1117
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2223
#define READ_UINT_FIELD(fldname)
Definition: readfuncs.c:69
#define READ_ENUM_FIELD(fldname, enumtype)
Definition: readfuncs.c:100
Datum readDatum(bool typbyval)
Definition: readfuncs.c:2691
SQLValueFunctionOp
Definition: primnodes.h:1089
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:329
#define READ_NODE_FIELD(fldname)
Definition: readfuncs.c:131
SubLinkType
Definition: primnodes.h:618
Bitmapset * readBitmapset(void)
Definition: readfuncs.c:226
static Limit * _readLimit(void)
Definition: readfuncs.c:2261
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2416
LockClauseStrength
Definition: lockoptions.h:21
static void ReadCommonScan(Scan *local_node)
Definition: readfuncs.c:1683
uintptr_t Datum
Definition: postgres.h:372
static void ReadCommonJoin(Join *local_node)
Definition: readfuncs.c:1969
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2184
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:297
static Gather * _readGather(void)
Definition: readfuncs.c:2165
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:53
#define READ_UINT64_FIELD(fldname)
Definition: readfuncs.c:75
const char * extnodename
Definition: extensible.h:35
static Var * _readVar(void)
Definition: readfuncs.c:514
#define READ_LOCATION_FIELD(fldname)
Definition: readfuncs.c:124
RowCompareType
Definition: primnodes.h:1024
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:1722
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2325
#define READ_LOCALS(nodeTypeName)
Definition: readfuncs.c:58
static TidScan * _readTidScan(void)
Definition: readfuncs.c:1810
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1168
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:1871
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:495
static Const * _readConst(void)
Definition: readfuncs.c:535
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:420
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1461
XmlOptionType
Definition: primnodes.h:1140
void(* nodeRead)(struct ExtensibleNode *node)
Definition: extensible.h:70
size_t Size
Definition: c.h:404
static Material * _readMaterial(void)
Definition: readfuncs.c:2052
AggSplit
Definition: nodes.h:758
#define READ_OID_FIELD(fldname)
Definition: readfuncs.c:87
static int list_length(const List *l)
Definition: pg_list.h:89
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:980
RowMarkType
Definition: plannodes.h:963
static Alias * _readAlias(void)
Definition: readfuncs.c:442
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:1666
static const struct fns functions
Definition: regcomp.c:299
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1263
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1632
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition: bitmapset.c:698
static FieldStore * _readFieldStore(void)
Definition: readfuncs.c:846
static CoalesceExpr * _readCoalesceExpr(void)
Definition: readfuncs.c:1048
const char * name
Definition: encode.c:521
#define READ_BITMAPSET_FIELD(fldname)
Definition: readfuncs.c:137
Node * parseNodeString(void)
Definition: readfuncs.c:2436
static SetToDefault * _readSetToDefault(void)
Definition: readfuncs.c:1184
static WithCheckOption * _readWithCheckOption(void)
Definition: readfuncs.c:312
static InferenceElem * _readInferenceElem(void)
Definition: readfuncs.c:1229
AggStrategy
Definition: nodes.h:736
static ScalarArrayOpExpr * _readScalarArrayOpExpr(void)
Definition: readfuncs.c:763
void * palloc(Size size)
Definition: mcxt.c:848
int xmloption
Definition: xml.c:97
SetOpCmd
Definition: nodes.h:780
int i
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:781
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:1939
DefElemAction
Definition: parsenodes.h:707
void * arg
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:398
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:995
GroupingSetKind
Definition: parsenodes.h:1253
#define READ_STRING_FIELD(fldname)
Definition: readfuncs.c:118
#define READ_DONE()
Definition: readfuncs.c:163
#define READ_INT_FIELD(fldname)
Definition: readfuncs.c:63
Definition: plannodes.h:780
#define elog
Definition: elog.h:219
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1410
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1135
static Plan * _readPlan(void)
Definition: readfuncs.c:1520
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1098
#define READ_ATTRNUMBER_ARRAY(fldname, len)
Definition: readfuncs.c:143
CoercionForm
Definition: primnodes.h:436
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:473
#define READ_INT_ARRAY(fldname, len)
Definition: readfuncs.c:153
const CustomScanMethods * GetCustomScanMethods(const char *CustomName, bool missing_ok)
Definition: extensible.c:137
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1429
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2277
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1548
OnConflictAction
Definition: nodes.h:800
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:1795
int16 AttrNumber
Definition: attnum.h:21
LockWaitPolicy
Definition: lockoptions.h:36
long val
Definition: informix.c:689
static Bitmapset * _readBitmapset(void)
Definition: readfuncs.c:185
CmdType
Definition: nodes.h:650
static Join * _readJoin(void)
Definition: readfuncs.c:1984
static Sort * _readSort(void)
Definition: readfuncs.c:2065
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:880
static Group * _readGroup(void)
Definition: readfuncs.c:2084
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:346
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:1902
const ExtensibleNodeMethods * GetExtensibleNodeMethods(const char *extnodename, bool missing_ok)
Definition: extensible.c:125
#define nullable_string(token, length)
Definition: readfuncs.c:177
Plan plan
Definition: plannodes.h:666
OverridingKind
Definition: parsenodes.h:30