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-2022, 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  * debugging use. When reading a location field, we normally 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  * However, if restore_location_fields is true, we do restore location
25  * fields from the string. This is currently intended only for use by the
26  * WRITE_READ_PARSE_PLAN_TREES test code, which doesn't want to cause
27  * any change in the node contents.
28  *
29  *-------------------------------------------------------------------------
30  */
31 #include "postgres.h"
32 
33 #include <math.h>
34 
35 #include "miscadmin.h"
36 #include "nodes/extensible.h"
37 #include "nodes/parsenodes.h"
38 #include "nodes/plannodes.h"
39 #include "nodes/readfuncs.h"
40 
41 
42 /*
43  * Macros to simplify reading of different kinds of fields. Use these
44  * wherever possible to reduce the chance for silly typos. Note that these
45  * hard-wire conventions about the names of the local variables in a Read
46  * routine.
47  */
48 
49 /* Macros for declaring appropriate local variables */
50 
51 /* A few guys need only local_node */
52 #define READ_LOCALS_NO_FIELDS(nodeTypeName) \
53  nodeTypeName *local_node = makeNode(nodeTypeName)
54 
55 /* And a few guys need only the pg_strtok support fields */
56 #define READ_TEMP_LOCALS() \
57  const char *token; \
58  int length
59 
60 /* ... but most need both */
61 #define READ_LOCALS(nodeTypeName) \
62  READ_LOCALS_NO_FIELDS(nodeTypeName); \
63  READ_TEMP_LOCALS()
64 
65 /* Read an integer field (anything written as ":fldname %d") */
66 #define READ_INT_FIELD(fldname) \
67  token = pg_strtok(&length); /* skip :fldname */ \
68  token = pg_strtok(&length); /* get field value */ \
69  local_node->fldname = atoi(token)
70 
71 /* Read an unsigned integer field (anything written as ":fldname %u") */
72 #define READ_UINT_FIELD(fldname) \
73  token = pg_strtok(&length); /* skip :fldname */ \
74  token = pg_strtok(&length); /* get field value */ \
75  local_node->fldname = atoui(token)
76 
77 /* Read an unsigned integer field (anything written using UINT64_FORMAT) */
78 #define READ_UINT64_FIELD(fldname) \
79  token = pg_strtok(&length); /* skip :fldname */ \
80  token = pg_strtok(&length); /* get field value */ \
81  local_node->fldname = strtou64(token, NULL, 10)
82 
83 /* Read a long integer field (anything written as ":fldname %ld") */
84 #define READ_LONG_FIELD(fldname) \
85  token = pg_strtok(&length); /* skip :fldname */ \
86  token = pg_strtok(&length); /* get field value */ \
87  local_node->fldname = atol(token)
88 
89 /* Read an OID field (don't hard-wire assumption that OID is same as uint) */
90 #define READ_OID_FIELD(fldname) \
91  token = pg_strtok(&length); /* skip :fldname */ \
92  token = pg_strtok(&length); /* get field value */ \
93  local_node->fldname = atooid(token)
94 
95 /* Read a char field (ie, one ascii character) */
96 #define READ_CHAR_FIELD(fldname) \
97  token = pg_strtok(&length); /* skip :fldname */ \
98  token = pg_strtok(&length); /* get field value */ \
99  /* avoid overhead of calling debackslash() for one char */ \
100  local_node->fldname = (length == 0) ? '\0' : (token[0] == '\\' ? token[1] : token[0])
101 
102 /* Read an enumerated-type field that was written as an integer code */
103 #define READ_ENUM_FIELD(fldname, enumtype) \
104  token = pg_strtok(&length); /* skip :fldname */ \
105  token = pg_strtok(&length); /* get field value */ \
106  local_node->fldname = (enumtype) atoi(token)
107 
108 /* Read a float field */
109 #define READ_FLOAT_FIELD(fldname) \
110  token = pg_strtok(&length); /* skip :fldname */ \
111  token = pg_strtok(&length); /* get field value */ \
112  local_node->fldname = atof(token)
113 
114 /* Read a boolean field */
115 #define READ_BOOL_FIELD(fldname) \
116  token = pg_strtok(&length); /* skip :fldname */ \
117  token = pg_strtok(&length); /* get field value */ \
118  local_node->fldname = strtobool(token)
119 
120 /* Read a character-string field */
121 #define READ_STRING_FIELD(fldname) \
122  token = pg_strtok(&length); /* skip :fldname */ \
123  token = pg_strtok(&length); /* get field value */ \
124  local_node->fldname = nullable_string(token, length)
125 
126 /* Read a parse location field (and possibly throw away the value) */
127 #ifdef WRITE_READ_PARSE_PLAN_TREES
128 #define READ_LOCATION_FIELD(fldname) \
129  token = pg_strtok(&length); /* skip :fldname */ \
130  token = pg_strtok(&length); /* get field value */ \
131  local_node->fldname = restore_location_fields ? atoi(token) : -1
132 #else
133 #define READ_LOCATION_FIELD(fldname) \
134  token = pg_strtok(&length); /* skip :fldname */ \
135  token = pg_strtok(&length); /* get field value */ \
136  (void) token; /* in case not used elsewhere */ \
137  local_node->fldname = -1 /* set field to "unknown" */
138 #endif
139 
140 /* Read a Node field */
141 #define READ_NODE_FIELD(fldname) \
142  token = pg_strtok(&length); /* skip :fldname */ \
143  (void) token; /* in case not used elsewhere */ \
144  local_node->fldname = nodeRead(NULL, 0)
145 
146 /* Read a bitmapset field */
147 #define READ_BITMAPSET_FIELD(fldname) \
148  token = pg_strtok(&length); /* skip :fldname */ \
149  (void) token; /* in case not used elsewhere */ \
150  local_node->fldname = _readBitmapset()
151 
152 /* Read an attribute number array */
153 #define READ_ATTRNUMBER_ARRAY(fldname, len) \
154  token = pg_strtok(&length); /* skip :fldname */ \
155  local_node->fldname = readAttrNumberCols(len)
156 
157 /* Read an oid array */
158 #define READ_OID_ARRAY(fldname, len) \
159  token = pg_strtok(&length); /* skip :fldname */ \
160  local_node->fldname = readOidCols(len)
161 
162 /* Read an int array */
163 #define READ_INT_ARRAY(fldname, len) \
164  token = pg_strtok(&length); /* skip :fldname */ \
165  local_node->fldname = readIntCols(len)
166 
167 /* Read a bool array */
168 #define READ_BOOL_ARRAY(fldname, len) \
169  token = pg_strtok(&length); /* skip :fldname */ \
170  local_node->fldname = readBoolCols(len)
171 
172 /* Routine exit */
173 #define READ_DONE() \
174  return local_node
175 
176 
177 /*
178  * NOTE: use atoi() to read values written with %d, or atoui() to read
179  * values written with %u in outfuncs.c. An exception is OID values,
180  * for which use atooid(). (As of 7.1, outfuncs.c writes OIDs as %u,
181  * but this will probably change in the future.)
182  */
183 #define atoui(x) ((unsigned int) strtoul((x), NULL, 10))
184 
185 #define strtobool(x) ((*(x) == 't') ? true : false)
186 
187 #define nullable_string(token,length) \
188  ((length) == 0 ? NULL : debackslash(token, length))
189 
190 
191 /*
192  * _readBitmapset
193  */
194 static Bitmapset *
196 {
197  Bitmapset *result = NULL;
198 
200 
201  token = pg_strtok(&length);
202  if (token == NULL)
203  elog(ERROR, "incomplete Bitmapset structure");
204  if (length != 1 || token[0] != '(')
205  elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
206 
207  token = pg_strtok(&length);
208  if (token == NULL)
209  elog(ERROR, "incomplete Bitmapset structure");
210  if (length != 1 || token[0] != 'b')
211  elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
212 
213  for (;;)
214  {
215  int val;
216  char *endptr;
217 
218  token = pg_strtok(&length);
219  if (token == NULL)
220  elog(ERROR, "unterminated Bitmapset structure");
221  if (length == 1 && token[0] == ')')
222  break;
223  val = (int) strtol(token, &endptr, 10);
224  if (endptr != token + length)
225  elog(ERROR, "unrecognized integer: \"%.*s\"", length, token);
226  result = bms_add_member(result, val);
227  }
228 
229  return result;
230 }
231 
232 /*
233  * for use by extensions which define extensible nodes
234  */
235 Bitmapset *
237 {
238  return _readBitmapset();
239 }
240 
241 /*
242  * _readQuery
243  */
244 static Query *
246 {
248 
249  READ_ENUM_FIELD(commandType, CmdType);
250  READ_ENUM_FIELD(querySource, QuerySource);
251  local_node->queryId = UINT64CONST(0); /* not saved in output format */
252  READ_BOOL_FIELD(canSetTag);
253  READ_NODE_FIELD(utilityStmt);
254  READ_INT_FIELD(resultRelation);
255  READ_BOOL_FIELD(hasAggs);
256  READ_BOOL_FIELD(hasWindowFuncs);
257  READ_BOOL_FIELD(hasTargetSRFs);
258  READ_BOOL_FIELD(hasSubLinks);
259  READ_BOOL_FIELD(hasDistinctOn);
260  READ_BOOL_FIELD(hasRecursive);
261  READ_BOOL_FIELD(hasModifyingCTE);
262  READ_BOOL_FIELD(hasForUpdate);
263  READ_BOOL_FIELD(hasRowSecurity);
264  READ_BOOL_FIELD(isReturn);
265  READ_NODE_FIELD(cteList);
266  READ_NODE_FIELD(rtable);
267  READ_NODE_FIELD(jointree);
268  READ_NODE_FIELD(targetList);
269  READ_ENUM_FIELD(override, OverridingKind);
270  READ_NODE_FIELD(onConflict);
271  READ_NODE_FIELD(returningList);
272  READ_NODE_FIELD(groupClause);
273  READ_BOOL_FIELD(groupDistinct);
274  READ_NODE_FIELD(groupingSets);
275  READ_NODE_FIELD(havingQual);
276  READ_NODE_FIELD(windowClause);
277  READ_NODE_FIELD(distinctClause);
278  READ_NODE_FIELD(sortClause);
279  READ_NODE_FIELD(limitOffset);
280  READ_NODE_FIELD(limitCount);
281  READ_ENUM_FIELD(limitOption, LimitOption);
282  READ_NODE_FIELD(rowMarks);
283  READ_NODE_FIELD(setOperations);
284  READ_NODE_FIELD(constraintDeps);
285  READ_NODE_FIELD(withCheckOptions);
286  READ_NODE_FIELD(mergeActionList);
287  READ_BOOL_FIELD(mergeUseOuterJoin);
288  READ_LOCATION_FIELD(stmt_location);
289  READ_INT_FIELD(stmt_len);
290 
291  READ_DONE();
292 }
293 
294 /*
295  * _readNotifyStmt
296  */
297 static NotifyStmt *
299 {
301 
302  READ_STRING_FIELD(conditionname);
303  READ_STRING_FIELD(payload);
304 
305  READ_DONE();
306 }
307 
308 /*
309  * _readDeclareCursorStmt
310  */
311 static DeclareCursorStmt *
313 {
315 
316  READ_STRING_FIELD(portalname);
318  READ_NODE_FIELD(query);
319 
320  READ_DONE();
321 }
322 
323 /*
324  * _readWithCheckOption
325  */
326 static WithCheckOption *
328 {
330 
331  READ_ENUM_FIELD(kind, WCOKind);
333  READ_STRING_FIELD(polname);
334  READ_NODE_FIELD(qual);
335  READ_BOOL_FIELD(cascaded);
336 
337  READ_DONE();
338 }
339 
340 /*
341  * _readSortGroupClause
342  */
343 static SortGroupClause *
345 {
347 
348  READ_UINT_FIELD(tleSortGroupRef);
349  READ_OID_FIELD(eqop);
350  READ_OID_FIELD(sortop);
351  READ_BOOL_FIELD(nulls_first);
352  READ_BOOL_FIELD(hashable);
353 
354  READ_DONE();
355 }
356 
357 /*
358  * _readGroupingSet
359  */
360 static GroupingSet *
362 {
364 
366  READ_NODE_FIELD(content);
367  READ_LOCATION_FIELD(location);
368 
369  READ_DONE();
370 }
371 
372 /*
373  * _readWindowClause
374  */
375 static WindowClause *
377 {
379 
381  READ_STRING_FIELD(refname);
382  READ_NODE_FIELD(partitionClause);
383  READ_NODE_FIELD(orderClause);
384  READ_INT_FIELD(frameOptions);
385  READ_NODE_FIELD(startOffset);
386  READ_NODE_FIELD(endOffset);
387  READ_NODE_FIELD(runCondition);
388  READ_OID_FIELD(startInRangeFunc);
389  READ_OID_FIELD(endInRangeFunc);
390  READ_OID_FIELD(inRangeColl);
391  READ_BOOL_FIELD(inRangeAsc);
392  READ_BOOL_FIELD(inRangeNullsFirst);
393  READ_UINT_FIELD(winref);
394  READ_BOOL_FIELD(copiedOrder);
395 
396  READ_DONE();
397 }
398 
399 /*
400  * _readRowMarkClause
401  */
402 static RowMarkClause *
404 {
406 
407  READ_UINT_FIELD(rti);
409  READ_ENUM_FIELD(waitPolicy, LockWaitPolicy);
410  READ_BOOL_FIELD(pushedDown);
411 
412  READ_DONE();
413 }
414 
415 /*
416  * _readCTESearchClause
417  */
418 static CTESearchClause *
420 {
422 
423  READ_NODE_FIELD(search_col_list);
424  READ_BOOL_FIELD(search_breadth_first);
425  READ_STRING_FIELD(search_seq_column);
426  READ_LOCATION_FIELD(location);
427 
428  READ_DONE();
429 }
430 
431 /*
432  * _readCTECycleClause
433  */
434 static CTECycleClause *
436 {
438 
439  READ_NODE_FIELD(cycle_col_list);
440  READ_STRING_FIELD(cycle_mark_column);
441  READ_NODE_FIELD(cycle_mark_value);
442  READ_NODE_FIELD(cycle_mark_default);
443  READ_STRING_FIELD(cycle_path_column);
444  READ_LOCATION_FIELD(location);
445  READ_OID_FIELD(cycle_mark_type);
446  READ_INT_FIELD(cycle_mark_typmod);
447  READ_OID_FIELD(cycle_mark_collation);
448  READ_OID_FIELD(cycle_mark_neop);
449 
450  READ_DONE();
451 }
452 
453 /*
454  * _readCommonTableExpr
455  */
456 static CommonTableExpr *
458 {
460 
461  READ_STRING_FIELD(ctename);
462  READ_NODE_FIELD(aliascolnames);
463  READ_ENUM_FIELD(ctematerialized, CTEMaterialize);
464  READ_NODE_FIELD(ctequery);
465  READ_NODE_FIELD(search_clause);
466  READ_NODE_FIELD(cycle_clause);
467  READ_LOCATION_FIELD(location);
468  READ_BOOL_FIELD(cterecursive);
469  READ_INT_FIELD(cterefcount);
470  READ_NODE_FIELD(ctecolnames);
471  READ_NODE_FIELD(ctecoltypes);
472  READ_NODE_FIELD(ctecoltypmods);
473  READ_NODE_FIELD(ctecolcollations);
474 
475  READ_DONE();
476 }
477 
478 /*
479  * _readMergeWhenClause
480  */
481 static MergeWhenClause *
483 {
485 
486  READ_BOOL_FIELD(matched);
487  READ_ENUM_FIELD(commandType, CmdType);
488  READ_NODE_FIELD(condition);
489  READ_NODE_FIELD(targetList);
491  READ_ENUM_FIELD(override, OverridingKind);
492 
493  READ_DONE();
494 }
495 
496 /*
497  * _readMergeAction
498  */
499 static MergeAction *
501 {
503 
504  READ_BOOL_FIELD(matched);
505  READ_ENUM_FIELD(commandType, CmdType);
506  READ_ENUM_FIELD(override, OverridingKind);
507  READ_NODE_FIELD(qual);
508  READ_NODE_FIELD(targetList);
509  READ_NODE_FIELD(updateColnos);
510 
511  READ_DONE();
512 }
513 
514 /*
515  * _readSetOperationStmt
516  */
517 static SetOperationStmt *
519 {
521 
523  READ_BOOL_FIELD(all);
524  READ_NODE_FIELD(larg);
525  READ_NODE_FIELD(rarg);
526  READ_NODE_FIELD(colTypes);
527  READ_NODE_FIELD(colTypmods);
528  READ_NODE_FIELD(colCollations);
529  READ_NODE_FIELD(groupClauses);
530 
531  READ_DONE();
532 }
533 
534 
535 /*
536  * Stuff from primnodes.h.
537  */
538 
539 static Alias *
541 {
543 
544  READ_STRING_FIELD(aliasname);
545  READ_NODE_FIELD(colnames);
546 
547  READ_DONE();
548 }
549 
550 static RangeVar *
552 {
554 
555  local_node->catalogname = NULL; /* not currently saved in output format */
556 
557  READ_STRING_FIELD(schemaname);
559  READ_BOOL_FIELD(inh);
560  READ_CHAR_FIELD(relpersistence);
561  READ_NODE_FIELD(alias);
562  READ_LOCATION_FIELD(location);
563 
564  READ_DONE();
565 }
566 
567 /*
568  * _readTableFunc
569  */
570 static TableFunc *
572 {
574 
575  READ_ENUM_FIELD(functype, TableFuncType);
576  READ_NODE_FIELD(ns_uris);
577  READ_NODE_FIELD(ns_names);
578  READ_NODE_FIELD(docexpr);
579  READ_NODE_FIELD(rowexpr);
580  READ_NODE_FIELD(colnames);
581  READ_NODE_FIELD(coltypes);
582  READ_NODE_FIELD(coltypmods);
583  READ_NODE_FIELD(colcollations);
584  READ_NODE_FIELD(colexprs);
585  READ_NODE_FIELD(coldefexprs);
586  READ_NODE_FIELD(colvalexprs);
587  READ_BITMAPSET_FIELD(notnulls);
588  READ_NODE_FIELD(plan);
589  READ_INT_FIELD(ordinalitycol);
590  READ_LOCATION_FIELD(location);
591 
592  READ_DONE();
593 }
594 
595 static IntoClause *
597 {
599 
600  READ_NODE_FIELD(rel);
601  READ_NODE_FIELD(colNames);
602  READ_STRING_FIELD(accessMethod);
604  READ_ENUM_FIELD(onCommit, OnCommitAction);
605  READ_STRING_FIELD(tableSpaceName);
606  READ_NODE_FIELD(viewQuery);
607  READ_BOOL_FIELD(skipData);
608 
609  READ_DONE();
610 }
611 
612 /*
613  * _readVar
614  */
615 static Var *
616 _readVar(void)
617 {
618  READ_LOCALS(Var);
619 
620  READ_INT_FIELD(varno);
621  READ_INT_FIELD(varattno);
622  READ_OID_FIELD(vartype);
623  READ_INT_FIELD(vartypmod);
624  READ_OID_FIELD(varcollid);
625  READ_UINT_FIELD(varlevelsup);
626  READ_UINT_FIELD(varnosyn);
627  READ_INT_FIELD(varattnosyn);
628  READ_LOCATION_FIELD(location);
629 
630  READ_DONE();
631 }
632 
633 /*
634  * _readConst
635  */
636 static Const *
638 {
640 
641  READ_OID_FIELD(consttype);
642  READ_INT_FIELD(consttypmod);
643  READ_OID_FIELD(constcollid);
644  READ_INT_FIELD(constlen);
645  READ_BOOL_FIELD(constbyval);
646  READ_BOOL_FIELD(constisnull);
647  READ_LOCATION_FIELD(location);
648 
649  token = pg_strtok(&length); /* skip :constvalue */
650  if (local_node->constisnull)
651  token = pg_strtok(&length); /* skip "<>" */
652  else
653  local_node->constvalue = readDatum(local_node->constbyval);
654 
655  READ_DONE();
656 }
657 
658 /*
659  * _readParam
660  */
661 static Param *
663 {
665 
666  READ_ENUM_FIELD(paramkind, ParamKind);
667  READ_INT_FIELD(paramid);
668  READ_OID_FIELD(paramtype);
669  READ_INT_FIELD(paramtypmod);
670  READ_OID_FIELD(paramcollid);
671  READ_LOCATION_FIELD(location);
672 
673  READ_DONE();
674 }
675 
676 /*
677  * _readAggref
678  */
679 static Aggref *
681 {
683 
684  READ_OID_FIELD(aggfnoid);
685  READ_OID_FIELD(aggtype);
686  READ_OID_FIELD(aggcollid);
687  READ_OID_FIELD(inputcollid);
688  READ_OID_FIELD(aggtranstype);
689  READ_NODE_FIELD(aggargtypes);
690  READ_NODE_FIELD(aggdirectargs);
692  READ_NODE_FIELD(aggorder);
693  READ_NODE_FIELD(aggdistinct);
694  READ_NODE_FIELD(aggfilter);
695  READ_BOOL_FIELD(aggstar);
696  READ_BOOL_FIELD(aggvariadic);
697  READ_CHAR_FIELD(aggkind);
698  READ_UINT_FIELD(agglevelsup);
699  READ_ENUM_FIELD(aggsplit, AggSplit);
700  READ_INT_FIELD(aggno);
701  READ_INT_FIELD(aggtransno);
702  READ_LOCATION_FIELD(location);
703 
704  READ_DONE();
705 }
706 
707 /*
708  * _readGroupingFunc
709  */
710 static GroupingFunc *
712 {
714 
716  READ_NODE_FIELD(refs);
717  READ_NODE_FIELD(cols);
718  READ_UINT_FIELD(agglevelsup);
719  READ_LOCATION_FIELD(location);
720 
721  READ_DONE();
722 }
723 
724 /*
725  * _readWindowFunc
726  */
727 static WindowFunc *
729 {
731 
732  READ_OID_FIELD(winfnoid);
733  READ_OID_FIELD(wintype);
734  READ_OID_FIELD(wincollid);
735  READ_OID_FIELD(inputcollid);
737  READ_NODE_FIELD(aggfilter);
738  READ_UINT_FIELD(winref);
739  READ_BOOL_FIELD(winstar);
740  READ_BOOL_FIELD(winagg);
741  READ_LOCATION_FIELD(location);
742 
743  READ_DONE();
744 }
745 
746 /*
747  * _readSubscriptingRef
748  */
749 static SubscriptingRef *
751 {
753 
754  READ_OID_FIELD(refcontainertype);
755  READ_OID_FIELD(refelemtype);
756  READ_OID_FIELD(refrestype);
757  READ_INT_FIELD(reftypmod);
758  READ_OID_FIELD(refcollid);
759  READ_NODE_FIELD(refupperindexpr);
760  READ_NODE_FIELD(reflowerindexpr);
761  READ_NODE_FIELD(refexpr);
762  READ_NODE_FIELD(refassgnexpr);
763 
764  READ_DONE();
765 }
766 
767 /*
768  * _readFuncExpr
769  */
770 static FuncExpr *
772 {
774 
775  READ_OID_FIELD(funcid);
776  READ_OID_FIELD(funcresulttype);
777  READ_BOOL_FIELD(funcretset);
778  READ_BOOL_FIELD(funcvariadic);
779  READ_ENUM_FIELD(funcformat, CoercionForm);
780  READ_OID_FIELD(funccollid);
781  READ_OID_FIELD(inputcollid);
783  READ_LOCATION_FIELD(location);
784 
785  READ_DONE();
786 }
787 
788 /*
789  * _readNamedArgExpr
790  */
791 static NamedArgExpr *
793 {
795 
798  READ_INT_FIELD(argnumber);
799  READ_LOCATION_FIELD(location);
800 
801  READ_DONE();
802 }
803 
804 /*
805  * _readOpExpr
806  */
807 static OpExpr *
809 {
811 
812  READ_OID_FIELD(opno);
813  READ_OID_FIELD(opfuncid);
814  READ_OID_FIELD(opresulttype);
815  READ_BOOL_FIELD(opretset);
816  READ_OID_FIELD(opcollid);
817  READ_OID_FIELD(inputcollid);
819  READ_LOCATION_FIELD(location);
820 
821  READ_DONE();
822 }
823 
824 /*
825  * _readDistinctExpr
826  */
827 static DistinctExpr *
829 {
831 
832  READ_OID_FIELD(opno);
833  READ_OID_FIELD(opfuncid);
834  READ_OID_FIELD(opresulttype);
835  READ_BOOL_FIELD(opretset);
836  READ_OID_FIELD(opcollid);
837  READ_OID_FIELD(inputcollid);
839  READ_LOCATION_FIELD(location);
840 
841  READ_DONE();
842 }
843 
844 /*
845  * _readNullIfExpr
846  */
847 static NullIfExpr *
849 {
851 
852  READ_OID_FIELD(opno);
853  READ_OID_FIELD(opfuncid);
854  READ_OID_FIELD(opresulttype);
855  READ_BOOL_FIELD(opretset);
856  READ_OID_FIELD(opcollid);
857  READ_OID_FIELD(inputcollid);
859  READ_LOCATION_FIELD(location);
860 
861  READ_DONE();
862 }
863 
864 /*
865  * _readScalarArrayOpExpr
866  */
867 static ScalarArrayOpExpr *
869 {
871 
872  READ_OID_FIELD(opno);
873  READ_OID_FIELD(opfuncid);
874  READ_OID_FIELD(hashfuncid);
875  READ_OID_FIELD(negfuncid);
876  READ_BOOL_FIELD(useOr);
877  READ_OID_FIELD(inputcollid);
879  READ_LOCATION_FIELD(location);
880 
881  READ_DONE();
882 }
883 
884 /*
885  * _readBoolExpr
886  */
887 static BoolExpr *
889 {
891 
892  /* do-it-yourself enum representation */
893  token = pg_strtok(&length); /* skip :boolop */
894  token = pg_strtok(&length); /* get field value */
895  if (strncmp(token, "and", 3) == 0)
896  local_node->boolop = AND_EXPR;
897  else if (strncmp(token, "or", 2) == 0)
898  local_node->boolop = OR_EXPR;
899  else if (strncmp(token, "not", 3) == 0)
900  local_node->boolop = NOT_EXPR;
901  else
902  elog(ERROR, "unrecognized boolop \"%.*s\"", length, token);
903 
905  READ_LOCATION_FIELD(location);
906 
907  READ_DONE();
908 }
909 
910 /*
911  * _readSubLink
912  */
913 static SubLink *
915 {
917 
918  READ_ENUM_FIELD(subLinkType, SubLinkType);
919  READ_INT_FIELD(subLinkId);
920  READ_NODE_FIELD(testexpr);
921  READ_NODE_FIELD(operName);
922  READ_NODE_FIELD(subselect);
923  READ_LOCATION_FIELD(location);
924 
925  READ_DONE();
926 }
927 
928 /*
929  * _readSubPlan is not needed since it doesn't appear in stored rules.
930  */
931 
932 /*
933  * _readFieldSelect
934  */
935 static FieldSelect *
937 {
939 
941  READ_INT_FIELD(fieldnum);
942  READ_OID_FIELD(resulttype);
943  READ_INT_FIELD(resulttypmod);
944  READ_OID_FIELD(resultcollid);
945 
946  READ_DONE();
947 }
948 
949 /*
950  * _readFieldStore
951  */
952 static FieldStore *
954 {
956 
958  READ_NODE_FIELD(newvals);
959  READ_NODE_FIELD(fieldnums);
960  READ_OID_FIELD(resulttype);
961 
962  READ_DONE();
963 }
964 
965 /*
966  * _readRelabelType
967  */
968 static RelabelType *
970 {
972 
974  READ_OID_FIELD(resulttype);
975  READ_INT_FIELD(resulttypmod);
976  READ_OID_FIELD(resultcollid);
977  READ_ENUM_FIELD(relabelformat, CoercionForm);
978  READ_LOCATION_FIELD(location);
979 
980  READ_DONE();
981 }
982 
983 /*
984  * _readCoerceViaIO
985  */
986 static CoerceViaIO *
988 {
990 
992  READ_OID_FIELD(resulttype);
993  READ_OID_FIELD(resultcollid);
994  READ_ENUM_FIELD(coerceformat, CoercionForm);
995  READ_LOCATION_FIELD(location);
996 
997  READ_DONE();
998 }
999 
1000 /*
1001  * _readArrayCoerceExpr
1002  */
1003 static ArrayCoerceExpr *
1005 {
1007 
1009  READ_NODE_FIELD(elemexpr);
1010  READ_OID_FIELD(resulttype);
1011  READ_INT_FIELD(resulttypmod);
1012  READ_OID_FIELD(resultcollid);
1013  READ_ENUM_FIELD(coerceformat, CoercionForm);
1014  READ_LOCATION_FIELD(location);
1015 
1016  READ_DONE();
1017 }
1018 
1019 /*
1020  * _readConvertRowtypeExpr
1021  */
1022 static ConvertRowtypeExpr *
1024 {
1026 
1028  READ_OID_FIELD(resulttype);
1029  READ_ENUM_FIELD(convertformat, CoercionForm);
1030  READ_LOCATION_FIELD(location);
1031 
1032  READ_DONE();
1033 }
1034 
1035 /*
1036  * _readCollateExpr
1037  */
1038 static CollateExpr *
1040 {
1042 
1044  READ_OID_FIELD(collOid);
1045  READ_LOCATION_FIELD(location);
1046 
1047  READ_DONE();
1048 }
1049 
1050 /*
1051  * _readCaseExpr
1052  */
1053 static CaseExpr *
1055 {
1057 
1058  READ_OID_FIELD(casetype);
1059  READ_OID_FIELD(casecollid);
1062  READ_NODE_FIELD(defresult);
1063  READ_LOCATION_FIELD(location);
1064 
1065  READ_DONE();
1066 }
1067 
1068 /*
1069  * _readCaseWhen
1070  */
1071 static CaseWhen *
1073 {
1075 
1076  READ_NODE_FIELD(expr);
1077  READ_NODE_FIELD(result);
1078  READ_LOCATION_FIELD(location);
1079 
1080  READ_DONE();
1081 }
1082 
1083 /*
1084  * _readCaseTestExpr
1085  */
1086 static CaseTestExpr *
1088 {
1090 
1091  READ_OID_FIELD(typeId);
1092  READ_INT_FIELD(typeMod);
1093  READ_OID_FIELD(collation);
1094 
1095  READ_DONE();
1096 }
1097 
1098 /*
1099  * _readArrayExpr
1100  */
1101 static ArrayExpr *
1103 {
1105 
1106  READ_OID_FIELD(array_typeid);
1107  READ_OID_FIELD(array_collid);
1108  READ_OID_FIELD(element_typeid);
1109  READ_NODE_FIELD(elements);
1110  READ_BOOL_FIELD(multidims);
1111  READ_LOCATION_FIELD(location);
1112 
1113  READ_DONE();
1114 }
1115 
1116 /*
1117  * _readRowExpr
1118  */
1119 static RowExpr *
1121 {
1123 
1125  READ_OID_FIELD(row_typeid);
1126  READ_ENUM_FIELD(row_format, CoercionForm);
1127  READ_NODE_FIELD(colnames);
1128  READ_LOCATION_FIELD(location);
1129 
1130  READ_DONE();
1131 }
1132 
1133 /*
1134  * _readRowCompareExpr
1135  */
1136 static RowCompareExpr *
1138 {
1140 
1142  READ_NODE_FIELD(opnos);
1143  READ_NODE_FIELD(opfamilies);
1144  READ_NODE_FIELD(inputcollids);
1145  READ_NODE_FIELD(largs);
1146  READ_NODE_FIELD(rargs);
1147 
1148  READ_DONE();
1149 }
1150 
1151 /*
1152  * _readCoalesceExpr
1153  */
1154 static CoalesceExpr *
1156 {
1158 
1159  READ_OID_FIELD(coalescetype);
1160  READ_OID_FIELD(coalescecollid);
1162  READ_LOCATION_FIELD(location);
1163 
1164  READ_DONE();
1165 }
1166 
1167 /*
1168  * _readMinMaxExpr
1169  */
1170 static MinMaxExpr *
1172 {
1174 
1175  READ_OID_FIELD(minmaxtype);
1176  READ_OID_FIELD(minmaxcollid);
1177  READ_OID_FIELD(inputcollid);
1180  READ_LOCATION_FIELD(location);
1181 
1182  READ_DONE();
1183 }
1184 
1185 /*
1186  * _readSQLValueFunction
1187  */
1188 static SQLValueFunction *
1190 {
1192 
1195  READ_INT_FIELD(typmod);
1196  READ_LOCATION_FIELD(location);
1197 
1198  READ_DONE();
1199 }
1200 
1201 /*
1202  * _readXmlExpr
1203  */
1204 static XmlExpr *
1206 {
1208 
1211  READ_NODE_FIELD(named_args);
1212  READ_NODE_FIELD(arg_names);
1216  READ_INT_FIELD(typmod);
1217  READ_LOCATION_FIELD(location);
1218 
1219  READ_DONE();
1220 }
1221 
1222 /*
1223  * _readNullTest
1224  */
1225 static NullTest *
1227 {
1229 
1231  READ_ENUM_FIELD(nulltesttype, NullTestType);
1232  READ_BOOL_FIELD(argisrow);
1233  READ_LOCATION_FIELD(location);
1234 
1235  READ_DONE();
1236 }
1237 
1238 /*
1239  * _readBooleanTest
1240  */
1241 static BooleanTest *
1243 {
1245 
1247  READ_ENUM_FIELD(booltesttype, BoolTestType);
1248  READ_LOCATION_FIELD(location);
1249 
1250  READ_DONE();
1251 }
1252 
1253 /*
1254  * _readCoerceToDomain
1255  */
1256 static CoerceToDomain *
1258 {
1260 
1262  READ_OID_FIELD(resulttype);
1263  READ_INT_FIELD(resulttypmod);
1264  READ_OID_FIELD(resultcollid);
1265  READ_ENUM_FIELD(coercionformat, CoercionForm);
1266  READ_LOCATION_FIELD(location);
1267 
1268  READ_DONE();
1269 }
1270 
1271 /*
1272  * _readCoerceToDomainValue
1273  */
1274 static CoerceToDomainValue *
1276 {
1278 
1279  READ_OID_FIELD(typeId);
1280  READ_INT_FIELD(typeMod);
1281  READ_OID_FIELD(collation);
1282  READ_LOCATION_FIELD(location);
1283 
1284  READ_DONE();
1285 }
1286 
1287 /*
1288  * _readSetToDefault
1289  */
1290 static SetToDefault *
1292 {
1294 
1295  READ_OID_FIELD(typeId);
1296  READ_INT_FIELD(typeMod);
1297  READ_OID_FIELD(collation);
1298  READ_LOCATION_FIELD(location);
1299 
1300  READ_DONE();
1301 }
1302 
1303 /*
1304  * _readCurrentOfExpr
1305  */
1306 static CurrentOfExpr *
1308 {
1310 
1311  READ_UINT_FIELD(cvarno);
1312  READ_STRING_FIELD(cursor_name);
1313  READ_INT_FIELD(cursor_param);
1314 
1315  READ_DONE();
1316 }
1317 
1318 /*
1319  * _readNextValueExpr
1320  */
1321 static NextValueExpr *
1323 {
1325 
1326  READ_OID_FIELD(seqid);
1327  READ_OID_FIELD(typeId);
1328 
1329  READ_DONE();
1330 }
1331 
1332 /*
1333  * _readInferenceElem
1334  */
1335 static InferenceElem *
1337 {
1339 
1340  READ_NODE_FIELD(expr);
1341  READ_OID_FIELD(infercollid);
1342  READ_OID_FIELD(inferopclass);
1343 
1344  READ_DONE();
1345 }
1346 
1347 /*
1348  * _readTargetEntry
1349  */
1350 static TargetEntry *
1352 {
1354 
1355  READ_NODE_FIELD(expr);
1356  READ_INT_FIELD(resno);
1357  READ_STRING_FIELD(resname);
1358  READ_UINT_FIELD(ressortgroupref);
1359  READ_OID_FIELD(resorigtbl);
1360  READ_INT_FIELD(resorigcol);
1361  READ_BOOL_FIELD(resjunk);
1362 
1363  READ_DONE();
1364 }
1365 
1366 /*
1367  * _readRangeTblRef
1368  */
1369 static RangeTblRef *
1371 {
1373 
1374  READ_INT_FIELD(rtindex);
1375 
1376  READ_DONE();
1377 }
1378 
1379 /*
1380  * _readJoinExpr
1381  */
1382 static JoinExpr *
1384 {
1386 
1387  READ_ENUM_FIELD(jointype, JoinType);
1388  READ_BOOL_FIELD(isNatural);
1389  READ_NODE_FIELD(larg);
1390  READ_NODE_FIELD(rarg);
1391  READ_NODE_FIELD(usingClause);
1392  READ_NODE_FIELD(join_using_alias);
1393  READ_NODE_FIELD(quals);
1394  READ_NODE_FIELD(alias);
1395  READ_INT_FIELD(rtindex);
1396 
1397  READ_DONE();
1398 }
1399 
1400 /*
1401  * _readFromExpr
1402  */
1403 static FromExpr *
1405 {
1407 
1408  READ_NODE_FIELD(fromlist);
1409  READ_NODE_FIELD(quals);
1410 
1411  READ_DONE();
1412 }
1413 
1414 /*
1415  * _readOnConflictExpr
1416  */
1417 static OnConflictExpr *
1419 {
1421 
1423  READ_NODE_FIELD(arbiterElems);
1424  READ_NODE_FIELD(arbiterWhere);
1425  READ_OID_FIELD(constraint);
1426  READ_NODE_FIELD(onConflictSet);
1427  READ_NODE_FIELD(onConflictWhere);
1428  READ_INT_FIELD(exclRelIndex);
1429  READ_NODE_FIELD(exclRelTlist);
1430 
1431  READ_DONE();
1432 }
1433 
1434 /*
1435  * _readJsonFormat
1436  */
1437 static JsonFormat *
1439 {
1441 
1444  READ_LOCATION_FIELD(location);
1445 
1446  READ_DONE();
1447 }
1448 
1449 /*
1450  * _readJsonReturning
1451  */
1452 static JsonReturning *
1454 {
1456 
1458  READ_OID_FIELD(typid);
1459  READ_INT_FIELD(typmod);
1460 
1461  READ_DONE();
1462 }
1463 
1464 /*
1465  * _readJsonValueExpr
1466  */
1467 static JsonValueExpr *
1469 {
1471 
1472  READ_NODE_FIELD(raw_expr);
1473  READ_NODE_FIELD(formatted_expr);
1475 
1476  READ_DONE();
1477 }
1478 
1479 /*
1480  * _readJsonConstructorExpr
1481  */
1482 static JsonConstructorExpr *
1484 {
1486 
1489  READ_NODE_FIELD(func);
1490  READ_NODE_FIELD(coercion);
1491  READ_NODE_FIELD(returning);
1492  READ_BOOL_FIELD(absent_on_null);
1493  READ_BOOL_FIELD(unique);
1494  READ_LOCATION_FIELD(location);
1495 
1496  READ_DONE();
1497 }
1498 
1499 /*
1500  * _readJsonBehavior
1501  */
1502 static JsonBehavior *
1504 {
1506 
1508  READ_NODE_FIELD(default_expr);
1509 
1510  READ_DONE();
1511 }
1512 
1513 /*
1514  * _readJsonExpr
1515  */
1516 static JsonExpr *
1518 {
1520 
1522  READ_NODE_FIELD(formatted_expr);
1523  READ_NODE_FIELD(result_coercion);
1525  READ_NODE_FIELD(path_spec);
1526  READ_NODE_FIELD(passing_names);
1527  READ_NODE_FIELD(passing_values);
1528  READ_NODE_FIELD(returning);
1529  READ_NODE_FIELD(on_empty);
1530  READ_NODE_FIELD(on_error);
1531  READ_NODE_FIELD(coercions);
1532  READ_ENUM_FIELD(wrapper, JsonWrapper);
1533  READ_BOOL_FIELD(omit_quotes);
1534  READ_LOCATION_FIELD(location);
1535 
1536  READ_DONE();
1537 }
1538 
1539 static JsonTableParent *
1541 {
1543 
1544  READ_NODE_FIELD(path);
1546  READ_NODE_FIELD(child);
1547  READ_BOOL_FIELD(outerJoin);
1548  READ_INT_FIELD(colMin);
1549  READ_INT_FIELD(colMax);
1550  READ_BOOL_FIELD(errorOnError);
1551 
1552  READ_DONE();
1553 }
1554 
1555 static JsonTableSibling *
1557 {
1559 
1560  READ_NODE_FIELD(larg);
1561  READ_NODE_FIELD(rarg);
1562  READ_BOOL_FIELD(cross);
1563 
1564  READ_DONE();
1565 }
1566 
1567 /*
1568  * _readJsonCoercion
1569  */
1570 static JsonCoercion *
1572 {
1574 
1575  READ_NODE_FIELD(expr);
1576  READ_BOOL_FIELD(via_populate);
1577  READ_BOOL_FIELD(via_io);
1578  READ_OID_FIELD(collation);
1579 
1580  READ_DONE();
1581 }
1582 
1583 /*
1584  * _readJsonItemCoercions
1585  */
1586 static JsonItemCoercions *
1588 {
1590 
1591  READ_NODE_FIELD(null);
1592  READ_NODE_FIELD(string);
1594  READ_NODE_FIELD(boolean);
1596  READ_NODE_FIELD(time);
1597  READ_NODE_FIELD(timetz);
1599  READ_NODE_FIELD(timestamptz);
1600  READ_NODE_FIELD(composite);
1601 
1602  READ_DONE();
1603 }
1604 
1605 /*
1606  * _readJsonIsPredicate
1607  */
1608 static JsonIsPredicate *
1610 {
1612 
1613  READ_NODE_FIELD(expr);
1615  READ_ENUM_FIELD(item_type, JsonValueType);
1616  READ_BOOL_FIELD(unique_keys);
1617  READ_LOCATION_FIELD(location);
1618 
1619  READ_DONE();
1620 }
1621 
1622 /*
1623  * Stuff from pathnodes.h.
1624  *
1625  * Mostly we don't need to read planner nodes back in again, but some
1626  * of these also end up in plan trees.
1627  */
1628 
1629 /*
1630  * _readAppendRelInfo
1631  */
1632 static AppendRelInfo *
1634 {
1636 
1637  READ_UINT_FIELD(parent_relid);
1638  READ_UINT_FIELD(child_relid);
1639  READ_OID_FIELD(parent_reltype);
1640  READ_OID_FIELD(child_reltype);
1641  READ_NODE_FIELD(translated_vars);
1642  READ_INT_FIELD(num_child_cols);
1643  READ_ATTRNUMBER_ARRAY(parent_colnos, local_node->num_child_cols);
1644  READ_OID_FIELD(parent_reloid);
1645 
1646  READ_DONE();
1647 }
1648 
1649 /*
1650  * Stuff from parsenodes.h.
1651  */
1652 
1653 /*
1654  * _readRangeTblEntry
1655  */
1656 static RangeTblEntry *
1658 {
1660 
1661  /* put alias + eref first to make dump more legible */
1662  READ_NODE_FIELD(alias);
1663  READ_NODE_FIELD(eref);
1664  READ_ENUM_FIELD(rtekind, RTEKind);
1665 
1666  switch (local_node->rtekind)
1667  {
1668  case RTE_RELATION:
1669  READ_OID_FIELD(relid);
1670  READ_CHAR_FIELD(relkind);
1671  READ_INT_FIELD(rellockmode);
1672  READ_NODE_FIELD(tablesample);
1673  break;
1674  case RTE_SUBQUERY:
1675  READ_NODE_FIELD(subquery);
1676  READ_BOOL_FIELD(security_barrier);
1677  break;
1678  case RTE_JOIN:
1679  READ_ENUM_FIELD(jointype, JoinType);
1680  READ_INT_FIELD(joinmergedcols);
1681  READ_NODE_FIELD(joinaliasvars);
1682  READ_NODE_FIELD(joinleftcols);
1683  READ_NODE_FIELD(joinrightcols);
1684  READ_NODE_FIELD(join_using_alias);
1685  break;
1686  case RTE_FUNCTION:
1688  READ_BOOL_FIELD(funcordinality);
1689  break;
1690  case RTE_TABLEFUNC:
1691  READ_NODE_FIELD(tablefunc);
1692  /* The RTE must have a copy of the column type info, if any */
1693  if (local_node->tablefunc)
1694  {
1695  TableFunc *tf = local_node->tablefunc;
1696 
1697  local_node->coltypes = tf->coltypes;
1698  local_node->coltypmods = tf->coltypmods;
1699  local_node->colcollations = tf->colcollations;
1700  }
1701  break;
1702  case RTE_VALUES:
1703  READ_NODE_FIELD(values_lists);
1704  READ_NODE_FIELD(coltypes);
1705  READ_NODE_FIELD(coltypmods);
1706  READ_NODE_FIELD(colcollations);
1707  break;
1708  case RTE_CTE:
1709  READ_STRING_FIELD(ctename);
1710  READ_UINT_FIELD(ctelevelsup);
1711  READ_BOOL_FIELD(self_reference);
1712  READ_NODE_FIELD(coltypes);
1713  READ_NODE_FIELD(coltypmods);
1714  READ_NODE_FIELD(colcollations);
1715  break;
1716  case RTE_NAMEDTUPLESTORE:
1717  READ_STRING_FIELD(enrname);
1718  READ_FLOAT_FIELD(enrtuples);
1719  READ_OID_FIELD(relid);
1720  READ_NODE_FIELD(coltypes);
1721  READ_NODE_FIELD(coltypmods);
1722  READ_NODE_FIELD(colcollations);
1723  break;
1724  case RTE_RESULT:
1725  /* no extra fields */
1726  break;
1727  default:
1728  elog(ERROR, "unrecognized RTE kind: %d",
1729  (int) local_node->rtekind);
1730  break;
1731  }
1732 
1733  READ_BOOL_FIELD(lateral);
1734  READ_BOOL_FIELD(inh);
1735  READ_BOOL_FIELD(inFromCl);
1736  READ_UINT_FIELD(requiredPerms);
1737  READ_OID_FIELD(checkAsUser);
1738  READ_BITMAPSET_FIELD(selectedCols);
1739  READ_BITMAPSET_FIELD(insertedCols);
1740  READ_BITMAPSET_FIELD(updatedCols);
1741  READ_BITMAPSET_FIELD(extraUpdatedCols);
1742  READ_NODE_FIELD(securityQuals);
1743 
1744  READ_DONE();
1745 }
1746 
1747 /*
1748  * _readRangeTblFunction
1749  */
1750 static RangeTblFunction *
1752 {
1754 
1755  READ_NODE_FIELD(funcexpr);
1756  READ_INT_FIELD(funccolcount);
1757  READ_NODE_FIELD(funccolnames);
1758  READ_NODE_FIELD(funccoltypes);
1759  READ_NODE_FIELD(funccoltypmods);
1760  READ_NODE_FIELD(funccolcollations);
1761  READ_BITMAPSET_FIELD(funcparams);
1762 
1763  READ_DONE();
1764 }
1765 
1766 /*
1767  * _readTableSampleClause
1768  */
1769 static TableSampleClause *
1771 {
1773 
1774  READ_OID_FIELD(tsmhandler);
1776  READ_NODE_FIELD(repeatable);
1777 
1778  READ_DONE();
1779 }
1780 
1781 /*
1782  * _readDefElem
1783  */
1784 static DefElem *
1786 {
1788 
1789  READ_STRING_FIELD(defnamespace);
1790  READ_STRING_FIELD(defname);
1792  READ_ENUM_FIELD(defaction, DefElemAction);
1793  READ_LOCATION_FIELD(location);
1794 
1795  READ_DONE();
1796 }
1797 
1798 /*
1799  * Stuff from plannodes.h.
1800  */
1801 
1802 /*
1803  * _readPlannedStmt
1804  */
1805 static PlannedStmt *
1807 {
1809 
1810  READ_ENUM_FIELD(commandType, CmdType);
1811  READ_UINT64_FIELD(queryId);
1812  READ_BOOL_FIELD(hasReturning);
1813  READ_BOOL_FIELD(hasModifyingCTE);
1814  READ_BOOL_FIELD(canSetTag);
1815  READ_BOOL_FIELD(transientPlan);
1816  READ_BOOL_FIELD(dependsOnRole);
1817  READ_BOOL_FIELD(parallelModeNeeded);
1818  READ_INT_FIELD(jitFlags);
1819  READ_NODE_FIELD(planTree);
1820  READ_NODE_FIELD(rtable);
1821  READ_NODE_FIELD(resultRelations);
1822  READ_NODE_FIELD(appendRelations);
1823  READ_NODE_FIELD(subplans);
1824  READ_BITMAPSET_FIELD(rewindPlanIDs);
1825  READ_NODE_FIELD(rowMarks);
1826  READ_NODE_FIELD(relationOids);
1827  READ_NODE_FIELD(invalItems);
1828  READ_NODE_FIELD(paramExecTypes);
1829  READ_NODE_FIELD(utilityStmt);
1830  READ_LOCATION_FIELD(stmt_location);
1831  READ_INT_FIELD(stmt_len);
1832 
1833  READ_DONE();
1834 }
1835 
1836 /*
1837  * ReadCommonPlan
1838  * Assign the basic stuff of all nodes that inherit from Plan
1839  */
1840 static void
1841 ReadCommonPlan(Plan *local_node)
1842 {
1843  READ_TEMP_LOCALS();
1844 
1845  READ_FLOAT_FIELD(startup_cost);
1846  READ_FLOAT_FIELD(total_cost);
1847  READ_FLOAT_FIELD(plan_rows);
1848  READ_INT_FIELD(plan_width);
1849  READ_BOOL_FIELD(parallel_aware);
1850  READ_BOOL_FIELD(parallel_safe);
1851  READ_BOOL_FIELD(async_capable);
1852  READ_INT_FIELD(plan_node_id);
1853  READ_NODE_FIELD(targetlist);
1854  READ_NODE_FIELD(qual);
1855  READ_NODE_FIELD(lefttree);
1856  READ_NODE_FIELD(righttree);
1857  READ_NODE_FIELD(initPlan);
1858  READ_BITMAPSET_FIELD(extParam);
1859  READ_BITMAPSET_FIELD(allParam);
1860 }
1861 
1862 /*
1863  * _readPlan
1864  */
1865 static Plan *
1867 {
1869 
1870  ReadCommonPlan(local_node);
1871 
1872  READ_DONE();
1873 }
1874 
1875 /*
1876  * _readResult
1877  */
1878 static Result *
1880 {
1882 
1883  ReadCommonPlan(&local_node->plan);
1884 
1885  READ_NODE_FIELD(resconstantqual);
1886 
1887  READ_DONE();
1888 }
1889 
1890 /*
1891  * _readProjectSet
1892  */
1893 static ProjectSet *
1895 {
1897 
1898  ReadCommonPlan(&local_node->plan);
1899 
1900  READ_DONE();
1901 }
1902 
1903 /*
1904  * _readModifyTable
1905  */
1906 static ModifyTable *
1908 {
1910 
1911  ReadCommonPlan(&local_node->plan);
1912 
1913  READ_ENUM_FIELD(operation, CmdType);
1914  READ_BOOL_FIELD(canSetTag);
1915  READ_UINT_FIELD(nominalRelation);
1916  READ_UINT_FIELD(rootRelation);
1917  READ_BOOL_FIELD(partColsUpdated);
1918  READ_NODE_FIELD(resultRelations);
1919  READ_NODE_FIELD(updateColnosLists);
1920  READ_NODE_FIELD(withCheckOptionLists);
1921  READ_NODE_FIELD(returningLists);
1922  READ_NODE_FIELD(fdwPrivLists);
1923  READ_BITMAPSET_FIELD(fdwDirectModifyPlans);
1924  READ_NODE_FIELD(rowMarks);
1925  READ_INT_FIELD(epqParam);
1926  READ_ENUM_FIELD(onConflictAction, OnConflictAction);
1927  READ_NODE_FIELD(arbiterIndexes);
1928  READ_NODE_FIELD(onConflictSet);
1929  READ_NODE_FIELD(onConflictCols);
1930  READ_NODE_FIELD(onConflictWhere);
1931  READ_UINT_FIELD(exclRelRTI);
1932  READ_NODE_FIELD(exclRelTlist);
1933  READ_NODE_FIELD(mergeActionLists);
1934 
1935  READ_DONE();
1936 }
1937 
1938 /*
1939  * _readAppend
1940  */
1941 static Append *
1943 {
1945 
1946  ReadCommonPlan(&local_node->plan);
1947 
1948  READ_BITMAPSET_FIELD(apprelids);
1949  READ_NODE_FIELD(appendplans);
1950  READ_INT_FIELD(nasyncplans);
1951  READ_INT_FIELD(first_partial_plan);
1952  READ_NODE_FIELD(part_prune_info);
1953 
1954  READ_DONE();
1955 }
1956 
1957 /*
1958  * _readMergeAppend
1959  */
1960 static MergeAppend *
1962 {
1964 
1965  ReadCommonPlan(&local_node->plan);
1966 
1967  READ_BITMAPSET_FIELD(apprelids);
1968  READ_NODE_FIELD(mergeplans);
1969  READ_INT_FIELD(numCols);
1970  READ_ATTRNUMBER_ARRAY(sortColIdx, local_node->numCols);
1971  READ_OID_ARRAY(sortOperators, local_node->numCols);
1972  READ_OID_ARRAY(collations, local_node->numCols);
1973  READ_BOOL_ARRAY(nullsFirst, local_node->numCols);
1974  READ_NODE_FIELD(part_prune_info);
1975 
1976  READ_DONE();
1977 }
1978 
1979 /*
1980  * _readRecursiveUnion
1981  */
1982 static RecursiveUnion *
1984 {
1986 
1987  ReadCommonPlan(&local_node->plan);
1988 
1989  READ_INT_FIELD(wtParam);
1990  READ_INT_FIELD(numCols);
1991  READ_ATTRNUMBER_ARRAY(dupColIdx, local_node->numCols);
1992  READ_OID_ARRAY(dupOperators, local_node->numCols);
1993  READ_OID_ARRAY(dupCollations, local_node->numCols);
1994  READ_LONG_FIELD(numGroups);
1995 
1996  READ_DONE();
1997 }
1998 
1999 /*
2000  * _readBitmapAnd
2001  */
2002 static BitmapAnd *
2004 {
2006 
2007  ReadCommonPlan(&local_node->plan);
2008 
2009  READ_NODE_FIELD(bitmapplans);
2010 
2011  READ_DONE();
2012 }
2013 
2014 /*
2015  * _readBitmapOr
2016  */
2017 static BitmapOr *
2019 {
2021 
2022  ReadCommonPlan(&local_node->plan);
2023 
2024  READ_BOOL_FIELD(isshared);
2025  READ_NODE_FIELD(bitmapplans);
2026 
2027  READ_DONE();
2028 }
2029 
2030 /*
2031  * ReadCommonScan
2032  * Assign the basic stuff of all nodes that inherit from Scan
2033  */
2034 static void
2035 ReadCommonScan(Scan *local_node)
2036 {
2037  READ_TEMP_LOCALS();
2038 
2039  ReadCommonPlan(&local_node->plan);
2040 
2041  READ_UINT_FIELD(scanrelid);
2042 }
2043 
2044 /*
2045  * _readScan
2046  */
2047 static Scan *
2049 {
2051 
2052  ReadCommonScan(local_node);
2053 
2054  READ_DONE();
2055 }
2056 
2057 /*
2058  * _readSeqScan
2059  */
2060 static SeqScan *
2062 {
2064 
2065  ReadCommonScan(&local_node->scan);
2066 
2067  READ_DONE();
2068 }
2069 
2070 /*
2071  * _readSampleScan
2072  */
2073 static SampleScan *
2075 {
2077 
2078  ReadCommonScan(&local_node->scan);
2079 
2080  READ_NODE_FIELD(tablesample);
2081 
2082  READ_DONE();
2083 }
2084 
2085 /*
2086  * _readIndexScan
2087  */
2088 static IndexScan *
2090 {
2092 
2093  ReadCommonScan(&local_node->scan);
2094 
2095  READ_OID_FIELD(indexid);
2096  READ_NODE_FIELD(indexqual);
2097  READ_NODE_FIELD(indexqualorig);
2098  READ_NODE_FIELD(indexorderby);
2099  READ_NODE_FIELD(indexorderbyorig);
2100  READ_NODE_FIELD(indexorderbyops);
2101  READ_ENUM_FIELD(indexorderdir, ScanDirection);
2102 
2103  READ_DONE();
2104 }
2105 
2106 /*
2107  * _readIndexOnlyScan
2108  */
2109 static IndexOnlyScan *
2111 {
2113 
2114  ReadCommonScan(&local_node->scan);
2115 
2116  READ_OID_FIELD(indexid);
2117  READ_NODE_FIELD(indexqual);
2118  READ_NODE_FIELD(recheckqual);
2119  READ_NODE_FIELD(indexorderby);
2120  READ_NODE_FIELD(indextlist);
2121  READ_ENUM_FIELD(indexorderdir, ScanDirection);
2122 
2123  READ_DONE();
2124 }
2125 
2126 /*
2127  * _readBitmapIndexScan
2128  */
2129 static BitmapIndexScan *
2131 {
2133 
2134  ReadCommonScan(&local_node->scan);
2135 
2136  READ_OID_FIELD(indexid);
2137  READ_BOOL_FIELD(isshared);
2138  READ_NODE_FIELD(indexqual);
2139  READ_NODE_FIELD(indexqualorig);
2140 
2141  READ_DONE();
2142 }
2143 
2144 /*
2145  * _readBitmapHeapScan
2146  */
2147 static BitmapHeapScan *
2149 {
2151 
2152  ReadCommonScan(&local_node->scan);
2153 
2154  READ_NODE_FIELD(bitmapqualorig);
2155 
2156  READ_DONE();
2157 }
2158 
2159 /*
2160  * _readTidScan
2161  */
2162 static TidScan *
2164 {
2166 
2167  ReadCommonScan(&local_node->scan);
2168 
2169  READ_NODE_FIELD(tidquals);
2170 
2171  READ_DONE();
2172 }
2173 
2174 /*
2175  * _readTidRangeScan
2176  */
2177 static TidRangeScan *
2179 {
2181 
2182  ReadCommonScan(&local_node->scan);
2183 
2184  READ_NODE_FIELD(tidrangequals);
2185 
2186  READ_DONE();
2187 }
2188 
2189 /*
2190  * _readSubqueryScan
2191  */
2192 static SubqueryScan *
2194 {
2196 
2197  ReadCommonScan(&local_node->scan);
2198 
2199  READ_NODE_FIELD(subplan);
2200  READ_ENUM_FIELD(scanstatus, SubqueryScanStatus);
2201 
2202  READ_DONE();
2203 }
2204 
2205 /*
2206  * _readFunctionScan
2207  */
2208 static FunctionScan *
2210 {
2212 
2213  ReadCommonScan(&local_node->scan);
2214 
2216  READ_BOOL_FIELD(funcordinality);
2217 
2218  READ_DONE();
2219 }
2220 
2221 /*
2222  * _readValuesScan
2223  */
2224 static ValuesScan *
2226 {
2228 
2229  ReadCommonScan(&local_node->scan);
2230 
2231  READ_NODE_FIELD(values_lists);
2232 
2233  READ_DONE();
2234 }
2235 
2236 /*
2237  * _readTableFuncScan
2238  */
2239 static TableFuncScan *
2241 {
2243 
2244  ReadCommonScan(&local_node->scan);
2245 
2246  READ_NODE_FIELD(tablefunc);
2247 
2248  READ_DONE();
2249 }
2250 
2251 /*
2252  * _readCteScan
2253  */
2254 static CteScan *
2256 {
2258 
2259  ReadCommonScan(&local_node->scan);
2260 
2261  READ_INT_FIELD(ctePlanId);
2262  READ_INT_FIELD(cteParam);
2263 
2264  READ_DONE();
2265 }
2266 
2267 /*
2268  * _readNamedTuplestoreScan
2269  */
2270 static NamedTuplestoreScan *
2272 {
2274 
2275  ReadCommonScan(&local_node->scan);
2276 
2277  READ_STRING_FIELD(enrname);
2278 
2279  READ_DONE();
2280 }
2281 
2282 /*
2283  * _readWorkTableScan
2284  */
2285 static WorkTableScan *
2287 {
2289 
2290  ReadCommonScan(&local_node->scan);
2291 
2292  READ_INT_FIELD(wtParam);
2293 
2294  READ_DONE();
2295 }
2296 
2297 /*
2298  * _readForeignScan
2299  */
2300 static ForeignScan *
2302 {
2304 
2305  ReadCommonScan(&local_node->scan);
2306 
2307  READ_ENUM_FIELD(operation, CmdType);
2308  READ_UINT_FIELD(resultRelation);
2309  READ_OID_FIELD(fs_server);
2310  READ_NODE_FIELD(fdw_exprs);
2311  READ_NODE_FIELD(fdw_private);
2312  READ_NODE_FIELD(fdw_scan_tlist);
2313  READ_NODE_FIELD(fdw_recheck_quals);
2314  READ_BITMAPSET_FIELD(fs_relids);
2315  READ_BOOL_FIELD(fsSystemCol);
2316 
2317  READ_DONE();
2318 }
2319 
2320 /*
2321  * _readCustomScan
2322  */
2323 static CustomScan *
2325 {
2327  char *custom_name;
2328  const CustomScanMethods *methods;
2329 
2330  ReadCommonScan(&local_node->scan);
2331 
2332  READ_UINT_FIELD(flags);
2333  READ_NODE_FIELD(custom_plans);
2334  READ_NODE_FIELD(custom_exprs);
2335  READ_NODE_FIELD(custom_private);
2336  READ_NODE_FIELD(custom_scan_tlist);
2337  READ_BITMAPSET_FIELD(custom_relids);
2338 
2339  /* Lookup CustomScanMethods by CustomName */
2340  token = pg_strtok(&length); /* skip methods: */
2341  token = pg_strtok(&length); /* CustomName */
2342  custom_name = nullable_string(token, length);
2343  methods = GetCustomScanMethods(custom_name, false);
2344  local_node->methods = methods;
2345 
2346  READ_DONE();
2347 }
2348 
2349 /*
2350  * ReadCommonJoin
2351  * Assign the basic stuff of all nodes that inherit from Join
2352  */
2353 static void
2354 ReadCommonJoin(Join *local_node)
2355 {
2356  READ_TEMP_LOCALS();
2357 
2358  ReadCommonPlan(&local_node->plan);
2359 
2360  READ_ENUM_FIELD(jointype, JoinType);
2361  READ_BOOL_FIELD(inner_unique);
2362  READ_NODE_FIELD(joinqual);
2363 }
2364 
2365 /*
2366  * _readJoin
2367  */
2368 static Join *
2370 {
2372 
2373  ReadCommonJoin(local_node);
2374 
2375  READ_DONE();
2376 }
2377 
2378 /*
2379  * _readNestLoop
2380  */
2381 static NestLoop *
2383 {
2385 
2386  ReadCommonJoin(&local_node->join);
2387 
2388  READ_NODE_FIELD(nestParams);
2389 
2390  READ_DONE();
2391 }
2392 
2393 /*
2394  * _readMergeJoin
2395  */
2396 static MergeJoin *
2398 {
2399  int numCols;
2400 
2402 
2403  ReadCommonJoin(&local_node->join);
2404 
2405  READ_BOOL_FIELD(skip_mark_restore);
2406  READ_NODE_FIELD(mergeclauses);
2407 
2408  numCols = list_length(local_node->mergeclauses);
2409 
2410  READ_OID_ARRAY(mergeFamilies, numCols);
2411  READ_OID_ARRAY(mergeCollations, numCols);
2412  READ_INT_ARRAY(mergeStrategies, numCols);
2413  READ_BOOL_ARRAY(mergeNullsFirst, numCols);
2414 
2415  READ_DONE();
2416 }
2417 
2418 /*
2419  * _readHashJoin
2420  */
2421 static HashJoin *
2423 {
2425 
2426  ReadCommonJoin(&local_node->join);
2427 
2428  READ_NODE_FIELD(hashclauses);
2429  READ_NODE_FIELD(hashoperators);
2430  READ_NODE_FIELD(hashcollations);
2431  READ_NODE_FIELD(hashkeys);
2432 
2433  READ_DONE();
2434 }
2435 
2436 /*
2437  * _readMaterial
2438  */
2439 static Material *
2441 {
2443 
2444  ReadCommonPlan(&local_node->plan);
2445 
2446  READ_DONE();
2447 }
2448 
2449 /*
2450  * _readMemoize
2451  */
2452 static Memoize *
2454 {
2456 
2457  ReadCommonPlan(&local_node->plan);
2458 
2459  READ_INT_FIELD(numKeys);
2460  READ_OID_ARRAY(hashOperators, local_node->numKeys);
2461  READ_OID_ARRAY(collations, local_node->numKeys);
2462  READ_NODE_FIELD(param_exprs);
2463  READ_BOOL_FIELD(singlerow);
2464  READ_BOOL_FIELD(binary_mode);
2465  READ_UINT_FIELD(est_entries);
2466  READ_BITMAPSET_FIELD(keyparamids);
2467 
2468  READ_DONE();
2469 }
2470 
2471 /*
2472  * ReadCommonSort
2473  * Assign the basic stuff of all nodes that inherit from Sort
2474  */
2475 static void
2476 ReadCommonSort(Sort *local_node)
2477 {
2478  READ_TEMP_LOCALS();
2479 
2480  ReadCommonPlan(&local_node->plan);
2481 
2482  READ_INT_FIELD(numCols);
2483  READ_ATTRNUMBER_ARRAY(sortColIdx, local_node->numCols);
2484  READ_OID_ARRAY(sortOperators, local_node->numCols);
2485  READ_OID_ARRAY(collations, local_node->numCols);
2486  READ_BOOL_ARRAY(nullsFirst, local_node->numCols);
2487 }
2488 
2489 /*
2490  * _readSort
2491  */
2492 static Sort *
2494 {
2496 
2497  ReadCommonSort(local_node);
2498 
2499  READ_DONE();
2500 }
2501 
2502 /*
2503  * _readIncrementalSort
2504  */
2505 static IncrementalSort *
2507 {
2509 
2510  ReadCommonSort(&local_node->sort);
2511 
2512  READ_INT_FIELD(nPresortedCols);
2513 
2514  READ_DONE();
2515 }
2516 
2517 /*
2518  * _readGroup
2519  */
2520 static Group *
2522 {
2523  READ_LOCALS(Group);
2524 
2525  ReadCommonPlan(&local_node->plan);
2526 
2527  READ_INT_FIELD(numCols);
2528  READ_ATTRNUMBER_ARRAY(grpColIdx, local_node->numCols);
2529  READ_OID_ARRAY(grpOperators, local_node->numCols);
2530  READ_OID_ARRAY(grpCollations, local_node->numCols);
2531 
2532  READ_DONE();
2533 }
2534 
2535 /*
2536  * _readAgg
2537  */
2538 static Agg *
2540 {
2541  READ_LOCALS(Agg);
2542 
2543  ReadCommonPlan(&local_node->plan);
2544 
2545  READ_ENUM_FIELD(aggstrategy, AggStrategy);
2546  READ_ENUM_FIELD(aggsplit, AggSplit);
2547  READ_INT_FIELD(numCols);
2548  READ_ATTRNUMBER_ARRAY(grpColIdx, local_node->numCols);
2549  READ_OID_ARRAY(grpOperators, local_node->numCols);
2550  READ_OID_ARRAY(grpCollations, local_node->numCols);
2551  READ_LONG_FIELD(numGroups);
2552  READ_UINT64_FIELD(transitionSpace);
2553  READ_BITMAPSET_FIELD(aggParams);
2554  READ_NODE_FIELD(groupingSets);
2555  READ_NODE_FIELD(chain);
2556 
2557  READ_DONE();
2558 }
2559 
2560 /*
2561  * _readWindowAgg
2562  */
2563 static WindowAgg *
2565 {
2567 
2568  ReadCommonPlan(&local_node->plan);
2569 
2570  READ_UINT_FIELD(winref);
2571  READ_INT_FIELD(partNumCols);
2572  READ_ATTRNUMBER_ARRAY(partColIdx, local_node->partNumCols);
2573  READ_OID_ARRAY(partOperators, local_node->partNumCols);
2574  READ_OID_ARRAY(partCollations, local_node->partNumCols);
2575  READ_INT_FIELD(ordNumCols);
2576  READ_ATTRNUMBER_ARRAY(ordColIdx, local_node->ordNumCols);
2577  READ_OID_ARRAY(ordOperators, local_node->ordNumCols);
2578  READ_OID_ARRAY(ordCollations, local_node->ordNumCols);
2579  READ_INT_FIELD(frameOptions);
2580  READ_NODE_FIELD(startOffset);
2581  READ_NODE_FIELD(endOffset);
2582  READ_NODE_FIELD(runCondition);
2583  READ_NODE_FIELD(runConditionOrig);
2584  READ_OID_FIELD(startInRangeFunc);
2585  READ_OID_FIELD(endInRangeFunc);
2586  READ_OID_FIELD(inRangeColl);
2587  READ_BOOL_FIELD(inRangeAsc);
2588  READ_BOOL_FIELD(inRangeNullsFirst);
2589  READ_BOOL_FIELD(topWindow);
2590 
2591  READ_DONE();
2592 }
2593 
2594 /*
2595  * _readUnique
2596  */
2597 static Unique *
2599 {
2601 
2602  ReadCommonPlan(&local_node->plan);
2603 
2604  READ_INT_FIELD(numCols);
2605  READ_ATTRNUMBER_ARRAY(uniqColIdx, local_node->numCols);
2606  READ_OID_ARRAY(uniqOperators, local_node->numCols);
2607  READ_OID_ARRAY(uniqCollations, local_node->numCols);
2608 
2609  READ_DONE();
2610 }
2611 
2612 /*
2613  * _readGather
2614  */
2615 static Gather *
2617 {
2619 
2620  ReadCommonPlan(&local_node->plan);
2621 
2622  READ_INT_FIELD(num_workers);
2623  READ_INT_FIELD(rescan_param);
2624  READ_BOOL_FIELD(single_copy);
2625  READ_BOOL_FIELD(invisible);
2626  READ_BITMAPSET_FIELD(initParam);
2627 
2628  READ_DONE();
2629 }
2630 
2631 /*
2632  * _readGatherMerge
2633  */
2634 static GatherMerge *
2636 {
2638 
2639  ReadCommonPlan(&local_node->plan);
2640 
2641  READ_INT_FIELD(num_workers);
2642  READ_INT_FIELD(rescan_param);
2643  READ_INT_FIELD(numCols);
2644  READ_ATTRNUMBER_ARRAY(sortColIdx, local_node->numCols);
2645  READ_OID_ARRAY(sortOperators, local_node->numCols);
2646  READ_OID_ARRAY(collations, local_node->numCols);
2647  READ_BOOL_ARRAY(nullsFirst, local_node->numCols);
2648  READ_BITMAPSET_FIELD(initParam);
2649 
2650  READ_DONE();
2651 }
2652 
2653 /*
2654  * _readHash
2655  */
2656 static Hash *
2658 {
2659  READ_LOCALS(Hash);
2660 
2661  ReadCommonPlan(&local_node->plan);
2662 
2663  READ_NODE_FIELD(hashkeys);
2664  READ_OID_FIELD(skewTable);
2665  READ_INT_FIELD(skewColumn);
2666  READ_BOOL_FIELD(skewInherit);
2667  READ_FLOAT_FIELD(rows_total);
2668 
2669  READ_DONE();
2670 }
2671 
2672 /*
2673  * _readSetOp
2674  */
2675 static SetOp *
2677 {
2678  READ_LOCALS(SetOp);
2679 
2680  ReadCommonPlan(&local_node->plan);
2681 
2682  READ_ENUM_FIELD(cmd, SetOpCmd);
2683  READ_ENUM_FIELD(strategy, SetOpStrategy);
2684  READ_INT_FIELD(numCols);
2685  READ_ATTRNUMBER_ARRAY(dupColIdx, local_node->numCols);
2686  READ_OID_ARRAY(dupOperators, local_node->numCols);
2687  READ_OID_ARRAY(dupCollations, local_node->numCols);
2688  READ_INT_FIELD(flagColIdx);
2689  READ_INT_FIELD(firstFlag);
2690  READ_LONG_FIELD(numGroups);
2691 
2692  READ_DONE();
2693 }
2694 
2695 /*
2696  * _readLockRows
2697  */
2698 static LockRows *
2700 {
2702 
2703  ReadCommonPlan(&local_node->plan);
2704 
2705  READ_NODE_FIELD(rowMarks);
2706  READ_INT_FIELD(epqParam);
2707 
2708  READ_DONE();
2709 }
2710 
2711 /*
2712  * _readLimit
2713  */
2714 static Limit *
2716 {
2717  READ_LOCALS(Limit);
2718 
2719  ReadCommonPlan(&local_node->plan);
2720 
2721  READ_NODE_FIELD(limitOffset);
2722  READ_NODE_FIELD(limitCount);
2723  READ_ENUM_FIELD(limitOption, LimitOption);
2724  READ_INT_FIELD(uniqNumCols);
2725  READ_ATTRNUMBER_ARRAY(uniqColIdx, local_node->uniqNumCols);
2726  READ_OID_ARRAY(uniqOperators, local_node->uniqNumCols);
2727  READ_OID_ARRAY(uniqCollations, local_node->uniqNumCols);
2728 
2729  READ_DONE();
2730 }
2731 
2732 /*
2733  * _readNestLoopParam
2734  */
2735 static NestLoopParam *
2737 {
2739 
2740  READ_INT_FIELD(paramno);
2741  READ_NODE_FIELD(paramval);
2742 
2743  READ_DONE();
2744 }
2745 
2746 /*
2747  * _readPlanRowMark
2748  */
2749 static PlanRowMark *
2751 {
2753 
2754  READ_UINT_FIELD(rti);
2755  READ_UINT_FIELD(prti);
2756  READ_UINT_FIELD(rowmarkId);
2757  READ_ENUM_FIELD(markType, RowMarkType);
2758  READ_INT_FIELD(allMarkTypes);
2760  READ_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2761  READ_BOOL_FIELD(isParent);
2762 
2763  READ_DONE();
2764 }
2765 
2766 static PartitionPruneInfo *
2768 {
2770 
2771  READ_NODE_FIELD(prune_infos);
2772  READ_BITMAPSET_FIELD(other_subplans);
2773 
2774  READ_DONE();
2775 }
2776 
2777 static PartitionedRelPruneInfo *
2779 {
2781 
2782  READ_UINT_FIELD(rtindex);
2783  READ_BITMAPSET_FIELD(present_parts);
2784  READ_INT_FIELD(nparts);
2785  READ_INT_ARRAY(subplan_map, local_node->nparts);
2786  READ_INT_ARRAY(subpart_map, local_node->nparts);
2787  READ_OID_ARRAY(relid_map, local_node->nparts);
2788  READ_NODE_FIELD(initial_pruning_steps);
2789  READ_NODE_FIELD(exec_pruning_steps);
2790  READ_BITMAPSET_FIELD(execparamids);
2791 
2792  READ_DONE();
2793 }
2794 
2795 static PartitionPruneStepOp *
2797 {
2799 
2800  READ_INT_FIELD(step.step_id);
2801  READ_INT_FIELD(opstrategy);
2802  READ_NODE_FIELD(exprs);
2803  READ_NODE_FIELD(cmpfns);
2804  READ_BITMAPSET_FIELD(nullkeys);
2805 
2806  READ_DONE();
2807 }
2808 
2811 {
2813 
2814  READ_INT_FIELD(step.step_id);
2816  READ_NODE_FIELD(source_stepids);
2817 
2818  READ_DONE();
2819 }
2820 
2821 /*
2822  * _readPlanInvalItem
2823  */
2824 static PlanInvalItem *
2826 {
2828 
2829  READ_INT_FIELD(cacheId);
2830  READ_UINT_FIELD(hashValue);
2831 
2832  READ_DONE();
2833 }
2834 
2835 /*
2836  * _readSubPlan
2837  */
2838 static SubPlan *
2840 {
2842 
2843  READ_ENUM_FIELD(subLinkType, SubLinkType);
2844  READ_NODE_FIELD(testexpr);
2845  READ_NODE_FIELD(paramIds);
2846  READ_INT_FIELD(plan_id);
2847  READ_STRING_FIELD(plan_name);
2848  READ_OID_FIELD(firstColType);
2849  READ_INT_FIELD(firstColTypmod);
2850  READ_OID_FIELD(firstColCollation);
2851  READ_BOOL_FIELD(useHashTable);
2852  READ_BOOL_FIELD(unknownEqFalse);
2853  READ_BOOL_FIELD(parallel_safe);
2854  READ_NODE_FIELD(setParam);
2855  READ_NODE_FIELD(parParam);
2857  READ_FLOAT_FIELD(startup_cost);
2858  READ_FLOAT_FIELD(per_call_cost);
2859 
2860  READ_DONE();
2861 }
2862 
2863 /*
2864  * _readAlternativeSubPlan
2865  */
2866 static AlternativeSubPlan *
2868 {
2870 
2871  READ_NODE_FIELD(subplans);
2872 
2873  READ_DONE();
2874 }
2875 
2876 /*
2877  * _readExtensibleNode
2878  */
2879 static ExtensibleNode *
2881 {
2882  const ExtensibleNodeMethods *methods;
2883  ExtensibleNode *local_node;
2884  const char *extnodename;
2885 
2886  READ_TEMP_LOCALS();
2887 
2888  token = pg_strtok(&length); /* skip :extnodename */
2889  token = pg_strtok(&length); /* get extnodename */
2890 
2891  extnodename = nullable_string(token, length);
2892  if (!extnodename)
2893  elog(ERROR, "extnodename has to be supplied");
2894  methods = GetExtensibleNodeMethods(extnodename, false);
2895 
2896  local_node = (ExtensibleNode *) newNode(methods->node_size,
2898  local_node->extnodename = extnodename;
2899 
2900  /* deserialize the private fields */
2901  methods->nodeRead(local_node);
2902 
2903  READ_DONE();
2904 }
2905 
2906 /*
2907  * _readPartitionBoundSpec
2908  */
2909 static PartitionBoundSpec *
2911 {
2913 
2914  READ_CHAR_FIELD(strategy);
2915  READ_BOOL_FIELD(is_default);
2916  READ_INT_FIELD(modulus);
2917  READ_INT_FIELD(remainder);
2918  READ_NODE_FIELD(listdatums);
2919  READ_NODE_FIELD(lowerdatums);
2920  READ_NODE_FIELD(upperdatums);
2921  READ_LOCATION_FIELD(location);
2922 
2923  READ_DONE();
2924 }
2925 
2926 /*
2927  * _readPartitionRangeDatum
2928  */
2929 static PartitionRangeDatum *
2931 {
2933 
2936  READ_LOCATION_FIELD(location);
2937 
2938  READ_DONE();
2939 }
2940 
2941 /*
2942  * parseNodeString
2943  *
2944  * Given a character string representing a node tree, parseNodeString creates
2945  * the internal node structure.
2946  *
2947  * The string to be read must already have been loaded into pg_strtok().
2948  */
2949 Node *
2951 {
2952  void *return_value;
2953 
2954  READ_TEMP_LOCALS();
2955 
2956  /* Guard against stack overflow due to overly complex expressions */
2958 
2959  token = pg_strtok(&length);
2960 
2961 #define MATCH(tokname, namelen) \
2962  (length == namelen && memcmp(token, tokname, namelen) == 0)
2963 
2964  if (MATCH("QUERY", 5))
2965  return_value = _readQuery();
2966  else if (MATCH("WITHCHECKOPTION", 15))
2967  return_value = _readWithCheckOption();
2968  else if (MATCH("SORTGROUPCLAUSE", 15))
2969  return_value = _readSortGroupClause();
2970  else if (MATCH("GROUPINGSET", 11))
2971  return_value = _readGroupingSet();
2972  else if (MATCH("WINDOWCLAUSE", 12))
2973  return_value = _readWindowClause();
2974  else if (MATCH("ROWMARKCLAUSE", 13))
2975  return_value = _readRowMarkClause();
2976  else if (MATCH("CTESEARCHCLAUSE", 15))
2977  return_value = _readCTESearchClause();
2978  else if (MATCH("CTECYCLECLAUSE", 14))
2979  return_value = _readCTECycleClause();
2980  else if (MATCH("COMMONTABLEEXPR", 15))
2981  return_value = _readCommonTableExpr();
2982  else if (MATCH("MERGEWHENCLAUSE", 15))
2983  return_value = _readMergeWhenClause();
2984  else if (MATCH("MERGEACTION", 11))
2985  return_value = _readMergeAction();
2986  else if (MATCH("SETOPERATIONSTMT", 16))
2987  return_value = _readSetOperationStmt();
2988  else if (MATCH("ALIAS", 5))
2989  return_value = _readAlias();
2990  else if (MATCH("RANGEVAR", 8))
2991  return_value = _readRangeVar();
2992  else if (MATCH("INTOCLAUSE", 10))
2993  return_value = _readIntoClause();
2994  else if (MATCH("TABLEFUNC", 9))
2995  return_value = _readTableFunc();
2996  else if (MATCH("VAR", 3))
2997  return_value = _readVar();
2998  else if (MATCH("CONST", 5))
2999  return_value = _readConst();
3000  else if (MATCH("PARAM", 5))
3001  return_value = _readParam();
3002  else if (MATCH("AGGREF", 6))
3003  return_value = _readAggref();
3004  else if (MATCH("GROUPINGFUNC", 12))
3005  return_value = _readGroupingFunc();
3006  else if (MATCH("WINDOWFUNC", 10))
3007  return_value = _readWindowFunc();
3008  else if (MATCH("SUBSCRIPTINGREF", 15))
3009  return_value = _readSubscriptingRef();
3010  else if (MATCH("FUNCEXPR", 8))
3011  return_value = _readFuncExpr();
3012  else if (MATCH("NAMEDARGEXPR", 12))
3013  return_value = _readNamedArgExpr();
3014  else if (MATCH("OPEXPR", 6))
3015  return_value = _readOpExpr();
3016  else if (MATCH("DISTINCTEXPR", 12))
3017  return_value = _readDistinctExpr();
3018  else if (MATCH("NULLIFEXPR", 10))
3019  return_value = _readNullIfExpr();
3020  else if (MATCH("SCALARARRAYOPEXPR", 17))
3021  return_value = _readScalarArrayOpExpr();
3022  else if (MATCH("BOOLEXPR", 8))
3023  return_value = _readBoolExpr();
3024  else if (MATCH("SUBLINK", 7))
3025  return_value = _readSubLink();
3026  else if (MATCH("FIELDSELECT", 11))
3027  return_value = _readFieldSelect();
3028  else if (MATCH("FIELDSTORE", 10))
3029  return_value = _readFieldStore();
3030  else if (MATCH("RELABELTYPE", 11))
3031  return_value = _readRelabelType();
3032  else if (MATCH("COERCEVIAIO", 11))
3033  return_value = _readCoerceViaIO();
3034  else if (MATCH("ARRAYCOERCEEXPR", 15))
3035  return_value = _readArrayCoerceExpr();
3036  else if (MATCH("CONVERTROWTYPEEXPR", 18))
3037  return_value = _readConvertRowtypeExpr();
3038  else if (MATCH("COLLATEEXPR", 11))
3039  return_value = _readCollateExpr();
3040  else if (MATCH("CASEEXPR", 8))
3041  return_value = _readCaseExpr();
3042  else if (MATCH("CASEWHEN", 8))
3043  return_value = _readCaseWhen();
3044  else if (MATCH("CASETESTEXPR", 12))
3045  return_value = _readCaseTestExpr();
3046  else if (MATCH("ARRAYEXPR", 9))
3047  return_value = _readArrayExpr();
3048  else if (MATCH("ROWEXPR", 7))
3049  return_value = _readRowExpr();
3050  else if (MATCH("ROWCOMPAREEXPR", 14))
3051  return_value = _readRowCompareExpr();
3052  else if (MATCH("COALESCEEXPR", 12))
3053  return_value = _readCoalesceExpr();
3054  else if (MATCH("MINMAXEXPR", 10))
3055  return_value = _readMinMaxExpr();
3056  else if (MATCH("SQLVALUEFUNCTION", 16))
3057  return_value = _readSQLValueFunction();
3058  else if (MATCH("XMLEXPR", 7))
3059  return_value = _readXmlExpr();
3060  else if (MATCH("NULLTEST", 8))
3061  return_value = _readNullTest();
3062  else if (MATCH("BOOLEANTEST", 11))
3063  return_value = _readBooleanTest();
3064  else if (MATCH("COERCETODOMAIN", 14))
3065  return_value = _readCoerceToDomain();
3066  else if (MATCH("COERCETODOMAINVALUE", 19))
3067  return_value = _readCoerceToDomainValue();
3068  else if (MATCH("SETTODEFAULT", 12))
3069  return_value = _readSetToDefault();
3070  else if (MATCH("CURRENTOFEXPR", 13))
3071  return_value = _readCurrentOfExpr();
3072  else if (MATCH("NEXTVALUEEXPR", 13))
3073  return_value = _readNextValueExpr();
3074  else if (MATCH("INFERENCEELEM", 13))
3075  return_value = _readInferenceElem();
3076  else if (MATCH("TARGETENTRY", 11))
3077  return_value = _readTargetEntry();
3078  else if (MATCH("RANGETBLREF", 11))
3079  return_value = _readRangeTblRef();
3080  else if (MATCH("JOINEXPR", 8))
3081  return_value = _readJoinExpr();
3082  else if (MATCH("FROMEXPR", 8))
3083  return_value = _readFromExpr();
3084  else if (MATCH("ONCONFLICTEXPR", 14))
3085  return_value = _readOnConflictExpr();
3086  else if (MATCH("APPENDRELINFO", 13))
3087  return_value = _readAppendRelInfo();
3088  else if (MATCH("RANGETBLENTRY", 13))
3089  return_value = _readRangeTblEntry();
3090  else if (MATCH("RANGETBLFUNCTION", 16))
3091  return_value = _readRangeTblFunction();
3092  else if (MATCH("TABLESAMPLECLAUSE", 17))
3093  return_value = _readTableSampleClause();
3094  else if (MATCH("NOTIFYSTMT", 10))
3095  return_value = _readNotifyStmt();
3096  else if (MATCH("DEFELEM", 7))
3097  return_value = _readDefElem();
3098  else if (MATCH("DECLARECURSORSTMT", 17))
3099  return_value = _readDeclareCursorStmt();
3100  else if (MATCH("PLANNEDSTMT", 11))
3101  return_value = _readPlannedStmt();
3102  else if (MATCH("PLAN", 4))
3103  return_value = _readPlan();
3104  else if (MATCH("RESULT", 6))
3105  return_value = _readResult();
3106  else if (MATCH("PROJECTSET", 10))
3107  return_value = _readProjectSet();
3108  else if (MATCH("MODIFYTABLE", 11))
3109  return_value = _readModifyTable();
3110  else if (MATCH("APPEND", 6))
3111  return_value = _readAppend();
3112  else if (MATCH("MERGEAPPEND", 11))
3113  return_value = _readMergeAppend();
3114  else if (MATCH("RECURSIVEUNION", 14))
3115  return_value = _readRecursiveUnion();
3116  else if (MATCH("BITMAPAND", 9))
3117  return_value = _readBitmapAnd();
3118  else if (MATCH("BITMAPOR", 8))
3119  return_value = _readBitmapOr();
3120  else if (MATCH("SCAN", 4))
3121  return_value = _readScan();
3122  else if (MATCH("SEQSCAN", 7))
3123  return_value = _readSeqScan();
3124  else if (MATCH("SAMPLESCAN", 10))
3125  return_value = _readSampleScan();
3126  else if (MATCH("INDEXSCAN", 9))
3127  return_value = _readIndexScan();
3128  else if (MATCH("INDEXONLYSCAN", 13))
3129  return_value = _readIndexOnlyScan();
3130  else if (MATCH("BITMAPINDEXSCAN", 15))
3131  return_value = _readBitmapIndexScan();
3132  else if (MATCH("BITMAPHEAPSCAN", 14))
3133  return_value = _readBitmapHeapScan();
3134  else if (MATCH("TIDSCAN", 7))
3135  return_value = _readTidScan();
3136  else if (MATCH("TIDRANGESCAN", 12))
3137  return_value = _readTidRangeScan();
3138  else if (MATCH("SUBQUERYSCAN", 12))
3139  return_value = _readSubqueryScan();
3140  else if (MATCH("FUNCTIONSCAN", 12))
3141  return_value = _readFunctionScan();
3142  else if (MATCH("VALUESSCAN", 10))
3143  return_value = _readValuesScan();
3144  else if (MATCH("TABLEFUNCSCAN", 13))
3145  return_value = _readTableFuncScan();
3146  else if (MATCH("CTESCAN", 7))
3147  return_value = _readCteScan();
3148  else if (MATCH("NAMEDTUPLESTORESCAN", 19))
3149  return_value = _readNamedTuplestoreScan();
3150  else if (MATCH("WORKTABLESCAN", 13))
3151  return_value = _readWorkTableScan();
3152  else if (MATCH("FOREIGNSCAN", 11))
3153  return_value = _readForeignScan();
3154  else if (MATCH("CUSTOMSCAN", 10))
3155  return_value = _readCustomScan();
3156  else if (MATCH("JOIN", 4))
3157  return_value = _readJoin();
3158  else if (MATCH("NESTLOOP", 8))
3159  return_value = _readNestLoop();
3160  else if (MATCH("MERGEJOIN", 9))
3161  return_value = _readMergeJoin();
3162  else if (MATCH("HASHJOIN", 8))
3163  return_value = _readHashJoin();
3164  else if (MATCH("MATERIAL", 8))
3165  return_value = _readMaterial();
3166  else if (MATCH("MEMOIZE", 7))
3167  return_value = _readMemoize();
3168  else if (MATCH("SORT", 4))
3169  return_value = _readSort();
3170  else if (MATCH("INCREMENTALSORT", 15))
3171  return_value = _readIncrementalSort();
3172  else if (MATCH("GROUP", 5))
3173  return_value = _readGroup();
3174  else if (MATCH("AGG", 3))
3175  return_value = _readAgg();
3176  else if (MATCH("WINDOWAGG", 9))
3177  return_value = _readWindowAgg();
3178  else if (MATCH("UNIQUE", 6))
3179  return_value = _readUnique();
3180  else if (MATCH("GATHER", 6))
3181  return_value = _readGather();
3182  else if (MATCH("GATHERMERGE", 11))
3183  return_value = _readGatherMerge();
3184  else if (MATCH("HASH", 4))
3185  return_value = _readHash();
3186  else if (MATCH("SETOP", 5))
3187  return_value = _readSetOp();
3188  else if (MATCH("LOCKROWS", 8))
3189  return_value = _readLockRows();
3190  else if (MATCH("LIMIT", 5))
3191  return_value = _readLimit();
3192  else if (MATCH("NESTLOOPPARAM", 13))
3193  return_value = _readNestLoopParam();
3194  else if (MATCH("PLANROWMARK", 11))
3195  return_value = _readPlanRowMark();
3196  else if (MATCH("PARTITIONPRUNEINFO", 18))
3197  return_value = _readPartitionPruneInfo();
3198  else if (MATCH("PARTITIONEDRELPRUNEINFO", 23))
3199  return_value = _readPartitionedRelPruneInfo();
3200  else if (MATCH("PARTITIONPRUNESTEPOP", 20))
3201  return_value = _readPartitionPruneStepOp();
3202  else if (MATCH("PARTITIONPRUNESTEPCOMBINE", 25))
3203  return_value = _readPartitionPruneStepCombine();
3204  else if (MATCH("PLANINVALITEM", 13))
3205  return_value = _readPlanInvalItem();
3206  else if (MATCH("SUBPLAN", 7))
3207  return_value = _readSubPlan();
3208  else if (MATCH("ALTERNATIVESUBPLAN", 18))
3209  return_value = _readAlternativeSubPlan();
3210  else if (MATCH("EXTENSIBLENODE", 14))
3211  return_value = _readExtensibleNode();
3212  else if (MATCH("PARTITIONBOUNDSPEC", 18))
3213  return_value = _readPartitionBoundSpec();
3214  else if (MATCH("PARTITIONRANGEDATUM", 19))
3215  return_value = _readPartitionRangeDatum();
3216  else if (MATCH("JSONFORMAT", 10))
3217  return_value = _readJsonFormat();
3218  else if (MATCH("JSONRETURNING", 13))
3219  return_value = _readJsonReturning();
3220  else if (MATCH("JSONVALUEEXPR", 13))
3221  return_value = _readJsonValueExpr();
3222  else if (MATCH("JSONCONSTRUCTOREXPR", 19))
3223  return_value = _readJsonConstructorExpr();
3224  else if (MATCH("JSONISPREDICATE", 15))
3225  return_value = _readJsonIsPredicate();
3226  else if (MATCH("JSONBEHAVIOR", 12))
3227  return_value = _readJsonBehavior();
3228  else if (MATCH("JSONEXPR", 8))
3229  return_value = _readJsonExpr();
3230  else if (MATCH("JSONCOERCION", 12))
3231  return_value = _readJsonCoercion();
3232  else if (MATCH("JSONITEMCOERCIONS", 17))
3233  return_value = _readJsonItemCoercions();
3234  else if (MATCH("JSONTABLEPARENT", 15))
3235  return_value = _readJsonTableParent();
3236  else if (MATCH("JSONTABLESIBLING", 16))
3237  return_value = _readJsonTableSibling();
3238  else
3239  {
3240  elog(ERROR, "badly formatted node string \"%.32s\"...", token);
3241  return_value = NULL; /* keep compiler quiet */
3242  }
3243 
3244  return (Node *) return_value;
3245 }
3246 
3247 
3248 /*
3249  * readDatum
3250  *
3251  * Given a string representation of a constant, recreate the appropriate
3252  * Datum. The string representation embeds length info, but not byValue,
3253  * so we must be told that.
3254  */
3255 Datum
3256 readDatum(bool typbyval)
3257 {
3258  Size length,
3259  i;
3260  int tokenLength;
3261  const char *token;
3262  Datum res;
3263  char *s;
3264 
3265  /*
3266  * read the actual length of the value
3267  */
3268  token = pg_strtok(&tokenLength);
3269  length = atoui(token);
3270 
3271  token = pg_strtok(&tokenLength); /* read the '[' */
3272  if (token == NULL || token[0] != '[')
3273  elog(ERROR, "expected \"[\" to start datum, but got \"%s\"; length = %zu",
3274  token ? token : "[NULL]", length);
3275 
3276  if (typbyval)
3277  {
3278  if (length > (Size) sizeof(Datum))
3279  elog(ERROR, "byval datum but length = %zu", length);
3280  res = (Datum) 0;
3281  s = (char *) (&res);
3282  for (i = 0; i < (Size) sizeof(Datum); i++)
3283  {
3284  token = pg_strtok(&tokenLength);
3285  s[i] = (char) atoi(token);
3286  }
3287  }
3288  else if (length <= 0)
3289  res = (Datum) NULL;
3290  else
3291  {
3292  s = (char *) palloc(length);
3293  for (i = 0; i < length; i++)
3294  {
3295  token = pg_strtok(&tokenLength);
3296  s[i] = (char) atoi(token);
3297  }
3298  res = PointerGetDatum(s);
3299  }
3300 
3301  token = pg_strtok(&tokenLength); /* read the ']' */
3302  if (token == NULL || token[0] != ']')
3303  elog(ERROR, "expected \"]\" to end datum, but got \"%s\"; length = %zu",
3304  token ? token : "[NULL]", length);
3305 
3306  return res;
3307 }
3308 
3309 /*
3310  * readAttrNumberCols
3311  */
3312 AttrNumber *
3314 {
3315  int tokenLength,
3316  i;
3317  const char *token;
3318  AttrNumber *attr_vals;
3319 
3320  if (numCols <= 0)
3321  return NULL;
3322 
3323  attr_vals = (AttrNumber *) palloc(numCols * sizeof(AttrNumber));
3324  for (i = 0; i < numCols; i++)
3325  {
3326  token = pg_strtok(&tokenLength);
3327  attr_vals[i] = atoi(token);
3328  }
3329 
3330  return attr_vals;
3331 }
3332 
3333 /*
3334  * readOidCols
3335  */
3336 Oid *
3337 readOidCols(int numCols)
3338 {
3339  int tokenLength,
3340  i;
3341  const char *token;
3342  Oid *oid_vals;
3343 
3344  if (numCols <= 0)
3345  return NULL;
3346 
3347  oid_vals = (Oid *) palloc(numCols * sizeof(Oid));
3348  for (i = 0; i < numCols; i++)
3349  {
3350  token = pg_strtok(&tokenLength);
3351  oid_vals[i] = atooid(token);
3352  }
3353 
3354  return oid_vals;
3355 }
3356 
3357 /*
3358  * readIntCols
3359  */
3360 int *
3361 readIntCols(int numCols)
3362 {
3363  int tokenLength,
3364  i;
3365  const char *token;
3366  int *int_vals;
3367 
3368  if (numCols <= 0)
3369  return NULL;
3370 
3371  int_vals = (int *) palloc(numCols * sizeof(int));
3372  for (i = 0; i < numCols; i++)
3373  {
3374  token = pg_strtok(&tokenLength);
3375  int_vals[i] = atoi(token);
3376  }
3377 
3378  return int_vals;
3379 }
3380 
3381 /*
3382  * readBoolCols
3383  */
3384 bool *
3385 readBoolCols(int numCols)
3386 {
3387  int tokenLength,
3388  i;
3389  const char *token;
3390  bool *bool_vals;
3391 
3392  if (numCols <= 0)
3393  return NULL;
3394 
3395  bool_vals = (bool *) palloc(numCols * sizeof(bool));
3396  for (i = 0; i < numCols; i++)
3397  {
3398  token = pg_strtok(&tokenLength);
3399  bool_vals[i] = strtobool(token);
3400  }
3401 
3402  return bool_vals;
3403 }
int16 AttrNumber
Definition: attnum.h:21
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition: bitmapset.c:738
static Datum values[MAXATTR]
Definition: bootstrap.c:156
size_t Size
Definition: c.h:540
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
const char * name
Definition: encode.c:561
const CustomScanMethods * GetCustomScanMethods(const char *CustomName, bool missing_ok)
Definition: extensible.c:137
const ExtensibleNodeMethods * GetExtensibleNodeMethods(const char *extnodename, bool missing_ok)
Definition: extensible.c:125
Datum format_type(PG_FUNCTION_ARGS)
Definition: format_type.c:60
static struct @151 value
long val
Definition: informix.c:664
int i
Definition: isn.c:73
LockWaitPolicy
Definition: lockoptions.h:37
LockClauseStrength
Definition: lockoptions.h:22
void * palloc(Size size)
Definition: mcxt.c:1068
#define newNode(size, tag)
Definition: nodes.h:611
SetOpCmd
Definition: nodes.h:850
SetOpStrategy
Definition: nodes.h:858
OnConflictAction
Definition: nodes.h:870
CmdType
Definition: nodes.h:719
AggStrategy
Definition: nodes.h:806
@ T_ExtensibleNode
Definition: nodes.h:324
AggSplit
Definition: nodes.h:828
LimitOption
Definition: nodes.h:883
JoinType
Definition: nodes.h:744
WCOKind
Definition: parsenodes.h:1225
GroupingSetKind
Definition: parsenodes.h:1363
SetOperation
Definition: parsenodes.h:1989
QuerySource
Definition: parsenodes.h:41
RTEKind
Definition: parsenodes.h:997
@ RTE_JOIN
Definition: parsenodes.h:1000
@ RTE_CTE
Definition: parsenodes.h:1004
@ RTE_NAMEDTUPLESTORE
Definition: parsenodes.h:1005
@ RTE_VALUES
Definition: parsenodes.h:1003
@ RTE_SUBQUERY
Definition: parsenodes.h:999
@ RTE_RESULT
Definition: parsenodes.h:1006
@ RTE_FUNCTION
Definition: parsenodes.h:1001
@ RTE_TABLEFUNC
Definition: parsenodes.h:1002
@ RTE_RELATION
Definition: parsenodes.h:998
DefElemAction
Definition: parsenodes.h:754
PartitionRangeDatumKind
Definition: parsenodes.h:871
OverridingKind
Definition: parsenodes.h:33
CTEMaterialize
Definition: parsenodes.h:1489
void * arg
static char format
NameData relname
Definition: pg_class.h:38
int32 encoding
Definition: pg_database.h:41
static int list_length(const List *l)
Definition: pg_list.h:149
long date
Definition: pgtypes_date.h:9
int64 timestamp
SubqueryScanStatus
Definition: plannodes.h:550
PartitionPruneCombineOp
Definition: plannodes.h:1302
RowMarkType
Definition: plannodes.h:1106
void check_stack_depth(void)
Definition: postgres.c:3500
uintptr_t Datum
Definition: postgres.h:411
#define PointerGetDatum(X)
Definition: postgres.h:600
unsigned int Oid
Definition: postgres_ext.h:31
#define atooid(x)
Definition: postgres_ext.h:42
BoolTestType
Definition: primnodes.h:1542
SubLinkType
Definition: primnodes.h:691
JsonFormatType
Definition: primnodes.h:1274
MinMaxOp
Definition: primnodes.h:1147
TableFuncType
Definition: primnodes.h:77
@ AND_EXPR
Definition: primnodes.h:628
@ OR_EXPR
Definition: primnodes.h:628
@ NOT_EXPR
Definition: primnodes.h:628
JsonEncoding
Definition: primnodes.h:1262
XmlOptionType
Definition: primnodes.h:1226
SQLValueFunctionOp
Definition: primnodes.h:1175
ParamKind
Definition: primnodes.h:266
JsonWrapper
Definition: primnodes.h:1306
XmlExprOp
Definition: primnodes.h:1214
RowCompareType
Definition: primnodes.h:1110
JsonBehaviorType
Definition: primnodes.h:1289
OnCommitAction
Definition: primnodes.h:48
JsonExprOp
Definition: primnodes.h:1250
CoercionForm
Definition: primnodes.h:491
NullTestType
Definition: primnodes.h:1519
JsonValueType
Definition: primnodes.h:1381
JsonConstructorType
Definition: primnodes.h:1349
const char * pg_strtok(int *length)
Definition: read.c:152
static MergeAction * _readMergeAction(void)
Definition: readfuncs.c:500
static PlannedStmt * _readPlannedStmt(void)
Definition: readfuncs.c:1806
static JsonCoercion * _readJsonCoercion(void)
Definition: readfuncs.c:1571
static PartitionedRelPruneInfo * _readPartitionedRelPruneInfo(void)
Definition: readfuncs.c:2778
static CollateExpr * _readCollateExpr(void)
Definition: readfuncs.c:1039
static CoerceViaIO * _readCoerceViaIO(void)
Definition: readfuncs.c:987
static PlanInvalItem * _readPlanInvalItem(void)
Definition: readfuncs.c:2825
static WithCheckOption * _readWithCheckOption(void)
Definition: readfuncs.c:327
static Alias * _readAlias(void)
Definition: readfuncs.c:540
static NestLoopParam * _readNestLoopParam(void)
Definition: readfuncs.c:2736
static PartitionPruneStepOp * _readPartitionPruneStepOp(void)
Definition: readfuncs.c:2796
static RangeTblFunction * _readRangeTblFunction(void)
Definition: readfuncs.c:1751
static JsonValueExpr * _readJsonValueExpr(void)
Definition: readfuncs.c:1468
static void ReadCommonPlan(Plan *local_node)
Definition: readfuncs.c:1841
static PartitionPruneInfo * _readPartitionPruneInfo(void)
Definition: readfuncs.c:2767
static Result * _readResult(void)
Definition: readfuncs.c:1879
#define READ_INT_FIELD(fldname)
Definition: readfuncs.c:66
static AlternativeSubPlan * _readAlternativeSubPlan(void)
Definition: readfuncs.c:2867
static JsonConstructorExpr * _readJsonConstructorExpr(void)
Definition: readfuncs.c:1483
static PartitionRangeDatum * _readPartitionRangeDatum(void)
Definition: readfuncs.c:2930
static WorkTableScan * _readWorkTableScan(void)
Definition: readfuncs.c:2286
static CoerceToDomain * _readCoerceToDomain(void)
Definition: readfuncs.c:1257
static IndexScan * _readIndexScan(void)
Definition: readfuncs.c:2089
static ArrayCoerceExpr * _readArrayCoerceExpr(void)
Definition: readfuncs.c:1004
static Group * _readGroup(void)
Definition: readfuncs.c:2521
static WindowAgg * _readWindowAgg(void)
Definition: readfuncs.c:2564
static NamedArgExpr * _readNamedArgExpr(void)
Definition: readfuncs.c:792
static RowExpr * _readRowExpr(void)
Definition: readfuncs.c:1120
static CoerceToDomainValue * _readCoerceToDomainValue(void)
Definition: readfuncs.c:1275
#define READ_UINT_FIELD(fldname)
Definition: readfuncs.c:72
#define READ_NODE_FIELD(fldname)
Definition: readfuncs.c:141
static RangeTblEntry * _readRangeTblEntry(void)
Definition: readfuncs.c:1657
static JsonTableParent * _readJsonTableParent(void)
Definition: readfuncs.c:1540
static FieldStore * _readFieldStore(void)
Definition: readfuncs.c:953
#define READ_CHAR_FIELD(fldname)
Definition: readfuncs.c:96
static ScalarArrayOpExpr * _readScalarArrayOpExpr(void)
Definition: readfuncs.c:868
static TableFunc * _readTableFunc(void)
Definition: readfuncs.c:571
static SetOp * _readSetOp(void)
Definition: readfuncs.c:2676
static TableFuncScan * _readTableFuncScan(void)
Definition: readfuncs.c:2240
static CoalesceExpr * _readCoalesceExpr(void)
Definition: readfuncs.c:1155
static TableSampleClause * _readTableSampleClause(void)
Definition: readfuncs.c:1770
static DefElem * _readDefElem(void)
Definition: readfuncs.c:1785
static RangeTblRef * _readRangeTblRef(void)
Definition: readfuncs.c:1370
static BooleanTest * _readBooleanTest(void)
Definition: readfuncs.c:1242
static FuncExpr * _readFuncExpr(void)
Definition: readfuncs.c:771
static JsonFormat * _readJsonFormat(void)
Definition: readfuncs.c:1438
static BitmapOr * _readBitmapOr(void)
Definition: readfuncs.c:2018
Node * parseNodeString(void)
Definition: readfuncs.c:2950
static Const * _readConst(void)
Definition: readfuncs.c:637
static JoinExpr * _readJoinExpr(void)
Definition: readfuncs.c:1383
static Sort * _readSort(void)
Definition: readfuncs.c:2493
static Aggref * _readAggref(void)
Definition: readfuncs.c:680
static SQLValueFunction * _readSQLValueFunction(void)
Definition: readfuncs.c:1189
int * readIntCols(int numCols)
Definition: readfuncs.c:3361
static RowMarkClause * _readRowMarkClause(void)
Definition: readfuncs.c:403
static IncrementalSort * _readIncrementalSort(void)
Definition: readfuncs.c:2506
#define READ_LOCALS_NO_FIELDS(nodeTypeName)
Definition: readfuncs.c:52
static AppendRelInfo * _readAppendRelInfo(void)
Definition: readfuncs.c:1633
static Plan * _readPlan(void)
Definition: readfuncs.c:1866
static RangeVar * _readRangeVar(void)
Definition: readfuncs.c:551
static CaseWhen * _readCaseWhen(void)
Definition: readfuncs.c:1072
#define READ_BOOL_ARRAY(fldname, len)
Definition: readfuncs.c:168
#define READ_BITMAPSET_FIELD(fldname)
Definition: readfuncs.c:147
static Scan * _readScan(void)
Definition: readfuncs.c:2048
#define READ_OID_FIELD(fldname)
Definition: readfuncs.c:90
static Memoize * _readMemoize(void)
Definition: readfuncs.c:2453
#define READ_LOCATION_FIELD(fldname)
Definition: readfuncs.c:133
static ConvertRowtypeExpr * _readConvertRowtypeExpr(void)
Definition: readfuncs.c:1023
static Gather * _readGather(void)
Definition: readfuncs.c:2616
static IntoClause * _readIntoClause(void)
Definition: readfuncs.c:596
static TidScan * _readTidScan(void)
Definition: readfuncs.c:2163
static CTESearchClause * _readCTESearchClause(void)
Definition: readfuncs.c:419
static InferenceElem * _readInferenceElem(void)
Definition: readfuncs.c:1336
static NextValueExpr * _readNextValueExpr(void)
Definition: readfuncs.c:1322
static NamedTuplestoreScan * _readNamedTuplestoreScan(void)
Definition: readfuncs.c:2271
static WindowFunc * _readWindowFunc(void)
Definition: readfuncs.c:728
static NestLoop * _readNestLoop(void)
Definition: readfuncs.c:2382
static JsonItemCoercions * _readJsonItemCoercions(void)
Definition: readfuncs.c:1587
static Agg * _readAgg(void)
Definition: readfuncs.c:2539
static CustomScan * _readCustomScan(void)
Definition: readfuncs.c:2324
static MergeAppend * _readMergeAppend(void)
Definition: readfuncs.c:1961
static Var * _readVar(void)
Definition: readfuncs.c:616
static CommonTableExpr * _readCommonTableExpr(void)
Definition: readfuncs.c:457
static SampleScan * _readSampleScan(void)
Definition: readfuncs.c:2074
static void ReadCommonScan(Scan *local_node)
Definition: readfuncs.c:2035
static TargetEntry * _readTargetEntry(void)
Definition: readfuncs.c:1351
#define READ_STRING_FIELD(fldname)
Definition: readfuncs.c:121
static OnConflictExpr * _readOnConflictExpr(void)
Definition: readfuncs.c:1418
static BoolExpr * _readBoolExpr(void)
Definition: readfuncs.c:888
static ModifyTable * _readModifyTable(void)
Definition: readfuncs.c:1907
static CTECycleClause * _readCTECycleClause(void)
Definition: readfuncs.c:435
static WindowClause * _readWindowClause(void)
Definition: readfuncs.c:376
AttrNumber * readAttrNumberCols(int numCols)
Definition: readfuncs.c:3313
static void ReadCommonSort(Sort *local_node)
Definition: readfuncs.c:2476
#define READ_FLOAT_FIELD(fldname)
Definition: readfuncs.c:109
static JsonReturning * _readJsonReturning(void)
Definition: readfuncs.c:1453
static BitmapIndexScan * _readBitmapIndexScan(void)
Definition: readfuncs.c:2130
static Query * _readQuery(void)
Definition: readfuncs.c:245
#define nullable_string(token, length)
Definition: readfuncs.c:187
static CurrentOfExpr * _readCurrentOfExpr(void)
Definition: readfuncs.c:1307
static MergeWhenClause * _readMergeWhenClause(void)
Definition: readfuncs.c:482
static SeqScan * _readSeqScan(void)
Definition: readfuncs.c:2061
static LockRows * _readLockRows(void)
Definition: readfuncs.c:2699
static DistinctExpr * _readDistinctExpr(void)
Definition: readfuncs.c:828
Datum readDatum(bool typbyval)
Definition: readfuncs.c:3256
static GroupingFunc * _readGroupingFunc(void)
Definition: readfuncs.c:711
static JsonIsPredicate * _readJsonIsPredicate()
Definition: readfuncs.c:1609
static DeclareCursorStmt * _readDeclareCursorStmt(void)
Definition: readfuncs.c:312
static FromExpr * _readFromExpr(void)
Definition: readfuncs.c:1404
static NotifyStmt * _readNotifyStmt(void)
Definition: readfuncs.c:298
static Hash * _readHash(void)
Definition: readfuncs.c:2657
static JsonExpr * _readJsonExpr(void)
Definition: readfuncs.c:1517
#define READ_LONG_FIELD(fldname)
Definition: readfuncs.c:84
static PlanRowMark * _readPlanRowMark(void)
Definition: readfuncs.c:2750
static IndexOnlyScan * _readIndexOnlyScan(void)
Definition: readfuncs.c:2110
static JsonBehavior * _readJsonBehavior(void)
Definition: readfuncs.c:1503
static JsonTableSibling * _readJsonTableSibling(void)
Definition: readfuncs.c:1556
static PartitionPruneStepCombine * _readPartitionPruneStepCombine(void)
Definition: readfuncs.c:2810
static ExtensibleNode * _readExtensibleNode(void)
Definition: readfuncs.c:2880
#define READ_BOOL_FIELD(fldname)
Definition: readfuncs.c:115
static RecursiveUnion * _readRecursiveUnion(void)
Definition: readfuncs.c:1983
static ArrayExpr * _readArrayExpr(void)
Definition: readfuncs.c:1102
static Append * _readAppend(void)
Definition: readfuncs.c:1942
static ValuesScan * _readValuesScan(void)
Definition: readfuncs.c:2225
static XmlExpr * _readXmlExpr(void)
Definition: readfuncs.c:1205
#define READ_ATTRNUMBER_ARRAY(fldname, len)
Definition: readfuncs.c:153
#define MATCH(tokname, namelen)
Bitmapset * readBitmapset(void)
Definition: readfuncs.c:236
#define atoui(x)
Definition: readfuncs.c:183
bool * readBoolCols(int numCols)
Definition: readfuncs.c:3385
static FunctionScan * _readFunctionScan(void)
Definition: readfuncs.c:2209
static SetToDefault * _readSetToDefault(void)
Definition: readfuncs.c:1291
static MergeJoin * _readMergeJoin(void)
Definition: readfuncs.c:2397
static BitmapHeapScan * _readBitmapHeapScan(void)
Definition: readfuncs.c:2148
static FieldSelect * _readFieldSelect(void)
Definition: readfuncs.c:936
static Join * _readJoin(void)
Definition: readfuncs.c:2369
Oid * readOidCols(int numCols)
Definition: readfuncs.c:3337
static SubscriptingRef * _readSubscriptingRef(void)
Definition: readfuncs.c:750
#define strtobool(x)
Definition: readfuncs.c:185
static void ReadCommonJoin(Join *local_node)
Definition: readfuncs.c:2354
static Bitmapset * _readBitmapset(void)
Definition: readfuncs.c:195
static NullIfExpr * _readNullIfExpr(void)
Definition: readfuncs.c:848
#define READ_UINT64_FIELD(fldname)
Definition: readfuncs.c:78
static ProjectSet * _readProjectSet(void)
Definition: readfuncs.c:1894
static GatherMerge * _readGatherMerge(void)
Definition: readfuncs.c:2635
static CteScan * _readCteScan(void)
Definition: readfuncs.c:2255
static SetOperationStmt * _readSetOperationStmt(void)
Definition: readfuncs.c:518
static CaseTestExpr * _readCaseTestExpr(void)
Definition: readfuncs.c:1087
static RelabelType * _readRelabelType(void)
Definition: readfuncs.c:969
static RowCompareExpr * _readRowCompareExpr(void)
Definition: readfuncs.c:1137
static SubPlan * _readSubPlan(void)
Definition: readfuncs.c:2839
static PartitionBoundSpec * _readPartitionBoundSpec(void)
Definition: readfuncs.c:2910
static NullTest * _readNullTest(void)
Definition: readfuncs.c:1226
static Material * _readMaterial(void)
Definition: readfuncs.c:2440
static CaseExpr * _readCaseExpr(void)
Definition: readfuncs.c:1054
static Param * _readParam(void)
Definition: readfuncs.c:662
static GroupingSet * _readGroupingSet(void)
Definition: readfuncs.c:361
#define READ_ENUM_FIELD(fldname, enumtype)
Definition: readfuncs.c:103
static HashJoin * _readHashJoin(void)
Definition: readfuncs.c:2422
static SubLink * _readSubLink(void)
Definition: readfuncs.c:914
#define READ_TEMP_LOCALS()
Definition: readfuncs.c:56
static SubqueryScan * _readSubqueryScan(void)
Definition: readfuncs.c:2193
#define READ_LOCALS(nodeTypeName)
Definition: readfuncs.c:61
static BitmapAnd * _readBitmapAnd(void)
Definition: readfuncs.c:2003
static TidRangeScan * _readTidRangeScan(void)
Definition: readfuncs.c:2178
#define READ_INT_ARRAY(fldname, len)
Definition: readfuncs.c:163
#define READ_DONE()
Definition: readfuncs.c:173
static OpExpr * _readOpExpr(void)
Definition: readfuncs.c:808
static SortGroupClause * _readSortGroupClause(void)
Definition: readfuncs.c:344
#define READ_OID_ARRAY(fldname, len)
Definition: readfuncs.c:158
static Unique * _readUnique(void)
Definition: readfuncs.c:2598
static MinMaxExpr * _readMinMaxExpr(void)
Definition: readfuncs.c:1171
static ForeignScan * _readForeignScan(void)
Definition: readfuncs.c:2301
static Limit * _readLimit(void)
Definition: readfuncs.c:2715
static const struct fns functions
Definition: regcomp.c:313
ScanDirection
Definition: sdir.h:23
Definition: plannodes.h:895
void(* nodeRead)(struct ExtensibleNode *node)
Definition: extensible.h:70
const char * extnodename
Definition: extensible.h:35
Plan plan
Definition: plannodes.h:736
Definition: nodes.h:574
Plan plan
Definition: plannodes.h:346
int numCols
Definition: plannodes.h:848
Plan plan
Definition: plannodes.h:847
List * coltypmods
Definition: primnodes.h:98
List * coltypes
Definition: primnodes.h:97
List * colcollations
Definition: primnodes.h:99
Definition: primnodes.h:196
int xmloption
Definition: xml.c:98