1 /*-------------------------------------------------------------------------
2  *
3  * equalfuncs.c
4  *	  Equality functions to compare node trees.
5  *
6  * NOTE: we currently support comparing all node types found in parse
7  * trees.  We do not support comparing executor state trees; there
8  * is no need for that, and no point in maintaining all the code that
9  * would be needed.  We also do not support comparing Path trees, mainly
10  * because the circular linkages between RelOptInfo and Path nodes can't
11  * be handled easily in a simple depth-first traversal.
12  *
13  * Currently, in fact, equal() doesn't know how to compare Plan trees
14  * either.  This might need to be fixed someday.
15  *
16  * NOTE: it is intentional that parse location fields (in nodes that have
17  * one) are not compared.  This is because we want, for example, a variable
18  * "x" to be considered equal() to another reference to "x" in the query.
19  *
20  *
21  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
22  * Portions Copyright (c) 1994, Regents of the University of California
23  *
24  * IDENTIFICATION
25  *	  src/backend/nodes/equalfuncs.c
26  *
27  *-------------------------------------------------------------------------
28  */
29 
30 #include "postgres.h"
31 
32 #include "miscadmin.h"
33 #include "nodes/extensible.h"
34 #include "nodes/relation.h"
35 #include "utils/datum.h"
36 
37 
38 /*
39  * Macros to simplify comparison of different kinds of fields.  Use these
40  * wherever possible to reduce the chance for silly typos.  Note that these
41  * hard-wire the convention that the local variables in an Equal routine are
42  * named 'a' and 'b'.
43  */
44 
45 /* Compare a simple scalar field (int, float, bool, enum, etc) */
46 #define COMPARE_SCALAR_FIELD(fldname) \
47 	do { \
48 		if (a->fldname != b->fldname) \
49 			return false; \
50 	} while (0)
51 
52 /* Compare a field that is a pointer to some kind of Node or Node tree */
53 #define COMPARE_NODE_FIELD(fldname) \
54 	do { \
55 		if (!equal(a->fldname, b->fldname)) \
56 			return false; \
57 	} while (0)
58 
59 /* Compare a field that is a pointer to a Bitmapset */
60 #define COMPARE_BITMAPSET_FIELD(fldname) \
61 	do { \
62 		if (!bms_equal(a->fldname, b->fldname)) \
63 			return false; \
64 	} while (0)
65 
66 /* Compare a field that is a pointer to a C string, or perhaps NULL */
67 #define COMPARE_STRING_FIELD(fldname) \
68 	do { \
69 		if (!equalstr(a->fldname, b->fldname)) \
70 			return false; \
71 	} while (0)
72 
73 /* Macro for comparing string fields that might be NULL */
74 #define equalstr(a, b)	\
75 	(((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
76 
77 /* Compare a field that is a pointer to a simple palloc'd object of size sz */
78 #define COMPARE_POINTER_FIELD(fldname, sz) \
79 	do { \
80 		if (memcmp(a->fldname, b->fldname, (sz)) != 0) \
81 			return false; \
82 	} while (0)
83 
84 /* Compare a parse location field (this is a no-op, per note above) */
85 #define COMPARE_LOCATION_FIELD(fldname) \
86 	((void) 0)
87 
88 /* Compare a CoercionForm field (also a no-op, per comment in primnodes.h) */
89 #define COMPARE_COERCIONFORM_FIELD(fldname) \
90 	((void) 0)
91 
92 
93 /*
94  *	Stuff from primnodes.h
95  */
96 
97 static bool
_equalAlias(const Alias * a,const Alias * b)98 _equalAlias(const Alias *a, const Alias *b)
99 {
100 	COMPARE_STRING_FIELD(aliasname);
101 	COMPARE_NODE_FIELD(colnames);
102 
103 	return true;
104 }
105 
106 static bool
_equalRangeVar(const RangeVar * a,const RangeVar * b)107 _equalRangeVar(const RangeVar *a, const RangeVar *b)
108 {
109 	COMPARE_STRING_FIELD(catalogname);
110 	COMPARE_STRING_FIELD(schemaname);
111 	COMPARE_STRING_FIELD(relname);
112 	COMPARE_SCALAR_FIELD(inh);
113 	COMPARE_SCALAR_FIELD(relpersistence);
114 	COMPARE_NODE_FIELD(alias);
115 	COMPARE_LOCATION_FIELD(location);
116 
117 	return true;
118 }
119 
120 static bool
_equalTableFunc(const TableFunc * a,const TableFunc * b)121 _equalTableFunc(const TableFunc *a, const TableFunc *b)
122 {
123 	COMPARE_NODE_FIELD(ns_uris);
124 	COMPARE_NODE_FIELD(ns_names);
125 	COMPARE_NODE_FIELD(docexpr);
126 	COMPARE_NODE_FIELD(rowexpr);
127 	COMPARE_NODE_FIELD(colnames);
128 	COMPARE_NODE_FIELD(coltypes);
129 	COMPARE_NODE_FIELD(coltypmods);
130 	COMPARE_NODE_FIELD(colcollations);
131 	COMPARE_NODE_FIELD(colexprs);
132 	COMPARE_NODE_FIELD(coldefexprs);
133 	COMPARE_BITMAPSET_FIELD(notnulls);
134 	COMPARE_SCALAR_FIELD(ordinalitycol);
135 	COMPARE_LOCATION_FIELD(location);
136 
137 	return true;
138 }
139 
140 static bool
_equalIntoClause(const IntoClause * a,const IntoClause * b)141 _equalIntoClause(const IntoClause *a, const IntoClause *b)
142 {
143 	COMPARE_NODE_FIELD(rel);
144 	COMPARE_NODE_FIELD(colNames);
145 	COMPARE_NODE_FIELD(options);
146 	COMPARE_SCALAR_FIELD(onCommit);
147 	COMPARE_STRING_FIELD(tableSpaceName);
148 	COMPARE_NODE_FIELD(viewQuery);
149 	COMPARE_SCALAR_FIELD(skipData);
150 
151 	return true;
152 }
153 
154 /*
155  * We don't need an _equalExpr because Expr is an abstract supertype which
156  * should never actually get instantiated.  Also, since it has no common
157  * fields except NodeTag, there's no need for a helper routine to factor
158  * out comparing the common fields...
159  */
160 
161 static bool
_equalVar(const Var * a,const Var * b)162 _equalVar(const Var *a, const Var *b)
163 {
164 	COMPARE_SCALAR_FIELD(varno);
165 	COMPARE_SCALAR_FIELD(varattno);
166 	COMPARE_SCALAR_FIELD(vartype);
167 	COMPARE_SCALAR_FIELD(vartypmod);
168 	COMPARE_SCALAR_FIELD(varcollid);
169 	COMPARE_SCALAR_FIELD(varlevelsup);
170 	COMPARE_SCALAR_FIELD(varnoold);
171 	COMPARE_SCALAR_FIELD(varoattno);
172 	COMPARE_LOCATION_FIELD(location);
173 
174 	return true;
175 }
176 
177 static bool
_equalConst(const Const * a,const Const * b)178 _equalConst(const Const *a, const Const *b)
179 {
180 	COMPARE_SCALAR_FIELD(consttype);
181 	COMPARE_SCALAR_FIELD(consttypmod);
182 	COMPARE_SCALAR_FIELD(constcollid);
183 	COMPARE_SCALAR_FIELD(constlen);
184 	COMPARE_SCALAR_FIELD(constisnull);
185 	COMPARE_SCALAR_FIELD(constbyval);
186 	COMPARE_LOCATION_FIELD(location);
187 
188 	/*
189 	 * We treat all NULL constants of the same type as equal. Someday this
190 	 * might need to change?  But datumIsEqual doesn't work on nulls, so...
191 	 */
192 	if (a->constisnull)
193 		return true;
194 	return datumIsEqual(a->constvalue, b->constvalue,
195 						a->constbyval, a->constlen);
196 }
197 
198 static bool
_equalParam(const Param * a,const Param * b)199 _equalParam(const Param *a, const Param *b)
200 {
201 	COMPARE_SCALAR_FIELD(paramkind);
202 	COMPARE_SCALAR_FIELD(paramid);
203 	COMPARE_SCALAR_FIELD(paramtype);
204 	COMPARE_SCALAR_FIELD(paramtypmod);
205 	COMPARE_SCALAR_FIELD(paramcollid);
206 	COMPARE_LOCATION_FIELD(location);
207 
208 	return true;
209 }
210 
211 static bool
_equalAggref(const Aggref * a,const Aggref * b)212 _equalAggref(const Aggref *a, const Aggref *b)
213 {
214 	COMPARE_SCALAR_FIELD(aggfnoid);
215 	COMPARE_SCALAR_FIELD(aggtype);
216 	COMPARE_SCALAR_FIELD(aggcollid);
217 	COMPARE_SCALAR_FIELD(inputcollid);
218 	/* ignore aggtranstype since it might not be set yet */
219 	COMPARE_NODE_FIELD(aggargtypes);
220 	COMPARE_NODE_FIELD(aggdirectargs);
221 	COMPARE_NODE_FIELD(args);
222 	COMPARE_NODE_FIELD(aggorder);
223 	COMPARE_NODE_FIELD(aggdistinct);
224 	COMPARE_NODE_FIELD(aggfilter);
225 	COMPARE_SCALAR_FIELD(aggstar);
226 	COMPARE_SCALAR_FIELD(aggvariadic);
227 	COMPARE_SCALAR_FIELD(aggkind);
228 	COMPARE_SCALAR_FIELD(agglevelsup);
229 	COMPARE_SCALAR_FIELD(aggsplit);
230 	COMPARE_LOCATION_FIELD(location);
231 
232 	return true;
233 }
234 
235 static bool
_equalGroupingFunc(const GroupingFunc * a,const GroupingFunc * b)236 _equalGroupingFunc(const GroupingFunc *a, const GroupingFunc *b)
237 {
238 	COMPARE_NODE_FIELD(args);
239 
240 	/*
241 	 * We must not compare the refs or cols field
242 	 */
243 
244 	COMPARE_SCALAR_FIELD(agglevelsup);
245 	COMPARE_LOCATION_FIELD(location);
246 
247 	return true;
248 }
249 
250 static bool
_equalWindowFunc(const WindowFunc * a,const WindowFunc * b)251 _equalWindowFunc(const WindowFunc *a, const WindowFunc *b)
252 {
253 	COMPARE_SCALAR_FIELD(winfnoid);
254 	COMPARE_SCALAR_FIELD(wintype);
255 	COMPARE_SCALAR_FIELD(wincollid);
256 	COMPARE_SCALAR_FIELD(inputcollid);
257 	COMPARE_NODE_FIELD(args);
258 	COMPARE_NODE_FIELD(aggfilter);
259 	COMPARE_SCALAR_FIELD(winref);
260 	COMPARE_SCALAR_FIELD(winstar);
261 	COMPARE_SCALAR_FIELD(winagg);
262 	COMPARE_LOCATION_FIELD(location);
263 
264 	return true;
265 }
266 
267 static bool
_equalArrayRef(const ArrayRef * a,const ArrayRef * b)268 _equalArrayRef(const ArrayRef *a, const ArrayRef *b)
269 {
270 	COMPARE_SCALAR_FIELD(refarraytype);
271 	COMPARE_SCALAR_FIELD(refelemtype);
272 	COMPARE_SCALAR_FIELD(reftypmod);
273 	COMPARE_SCALAR_FIELD(refcollid);
274 	COMPARE_NODE_FIELD(refupperindexpr);
275 	COMPARE_NODE_FIELD(reflowerindexpr);
276 	COMPARE_NODE_FIELD(refexpr);
277 	COMPARE_NODE_FIELD(refassgnexpr);
278 
279 	return true;
280 }
281 
282 static bool
_equalFuncExpr(const FuncExpr * a,const FuncExpr * b)283 _equalFuncExpr(const FuncExpr *a, const FuncExpr *b)
284 {
285 	COMPARE_SCALAR_FIELD(funcid);
286 	COMPARE_SCALAR_FIELD(funcresulttype);
287 	COMPARE_SCALAR_FIELD(funcretset);
288 	COMPARE_SCALAR_FIELD(funcvariadic);
289 	COMPARE_COERCIONFORM_FIELD(funcformat);
290 	COMPARE_SCALAR_FIELD(funccollid);
291 	COMPARE_SCALAR_FIELD(inputcollid);
292 	COMPARE_NODE_FIELD(args);
293 	COMPARE_LOCATION_FIELD(location);
294 
295 	return true;
296 }
297 
298 static bool
_equalNamedArgExpr(const NamedArgExpr * a,const NamedArgExpr * b)299 _equalNamedArgExpr(const NamedArgExpr *a, const NamedArgExpr *b)
300 {
301 	COMPARE_NODE_FIELD(arg);
302 	COMPARE_STRING_FIELD(name);
303 	COMPARE_SCALAR_FIELD(argnumber);
304 	COMPARE_LOCATION_FIELD(location);
305 
306 	return true;
307 }
308 
309 static bool
_equalOpExpr(const OpExpr * a,const OpExpr * b)310 _equalOpExpr(const OpExpr *a, const OpExpr *b)
311 {
312 	COMPARE_SCALAR_FIELD(opno);
313 
314 	/*
315 	 * Special-case opfuncid: it is allowable for it to differ if one node
316 	 * contains zero and the other doesn't.  This just means that the one node
317 	 * isn't as far along in the parse/plan pipeline and hasn't had the
318 	 * opfuncid cache filled yet.
319 	 */
320 	if (a->opfuncid != b->opfuncid &&
321 		a->opfuncid != 0 &&
322 		b->opfuncid != 0)
323 		return false;
324 
325 	COMPARE_SCALAR_FIELD(opresulttype);
326 	COMPARE_SCALAR_FIELD(opretset);
327 	COMPARE_SCALAR_FIELD(opcollid);
328 	COMPARE_SCALAR_FIELD(inputcollid);
329 	COMPARE_NODE_FIELD(args);
330 	COMPARE_LOCATION_FIELD(location);
331 
332 	return true;
333 }
334 
335 static bool
_equalDistinctExpr(const DistinctExpr * a,const DistinctExpr * b)336 _equalDistinctExpr(const DistinctExpr *a, const DistinctExpr *b)
337 {
338 	COMPARE_SCALAR_FIELD(opno);
339 
340 	/*
341 	 * Special-case opfuncid: it is allowable for it to differ if one node
342 	 * contains zero and the other doesn't.  This just means that the one node
343 	 * isn't as far along in the parse/plan pipeline and hasn't had the
344 	 * opfuncid cache filled yet.
345 	 */
346 	if (a->opfuncid != b->opfuncid &&
347 		a->opfuncid != 0 &&
348 		b->opfuncid != 0)
349 		return false;
350 
351 	COMPARE_SCALAR_FIELD(opresulttype);
352 	COMPARE_SCALAR_FIELD(opretset);
353 	COMPARE_SCALAR_FIELD(opcollid);
354 	COMPARE_SCALAR_FIELD(inputcollid);
355 	COMPARE_NODE_FIELD(args);
356 	COMPARE_LOCATION_FIELD(location);
357 
358 	return true;
359 }
360 
361 static bool
_equalNullIfExpr(const NullIfExpr * a,const NullIfExpr * b)362 _equalNullIfExpr(const NullIfExpr *a, const NullIfExpr *b)
363 {
364 	COMPARE_SCALAR_FIELD(opno);
365 
366 	/*
367 	 * Special-case opfuncid: it is allowable for it to differ if one node
368 	 * contains zero and the other doesn't.  This just means that the one node
369 	 * isn't as far along in the parse/plan pipeline and hasn't had the
370 	 * opfuncid cache filled yet.
371 	 */
372 	if (a->opfuncid != b->opfuncid &&
373 		a->opfuncid != 0 &&
374 		b->opfuncid != 0)
375 		return false;
376 
377 	COMPARE_SCALAR_FIELD(opresulttype);
378 	COMPARE_SCALAR_FIELD(opretset);
379 	COMPARE_SCALAR_FIELD(opcollid);
380 	COMPARE_SCALAR_FIELD(inputcollid);
381 	COMPARE_NODE_FIELD(args);
382 	COMPARE_LOCATION_FIELD(location);
383 
384 	return true;
385 }
386 
387 static bool
_equalScalarArrayOpExpr(const ScalarArrayOpExpr * a,const ScalarArrayOpExpr * b)388 _equalScalarArrayOpExpr(const ScalarArrayOpExpr *a, const ScalarArrayOpExpr *b)
389 {
390 	COMPARE_SCALAR_FIELD(opno);
391 
392 	/*
393 	 * Special-case opfuncid: it is allowable for it to differ if one node
394 	 * contains zero and the other doesn't.  This just means that the one node
395 	 * isn't as far along in the parse/plan pipeline and hasn't had the
396 	 * opfuncid cache filled yet.
397 	 */
398 	if (a->opfuncid != b->opfuncid &&
399 		a->opfuncid != 0 &&
400 		b->opfuncid != 0)
401 		return false;
402 
403 	COMPARE_SCALAR_FIELD(useOr);
404 	COMPARE_SCALAR_FIELD(inputcollid);
405 	COMPARE_NODE_FIELD(args);
406 	COMPARE_LOCATION_FIELD(location);
407 
408 	return true;
409 }
410 
411 static bool
_equalBoolExpr(const BoolExpr * a,const BoolExpr * b)412 _equalBoolExpr(const BoolExpr *a, const BoolExpr *b)
413 {
414 	COMPARE_SCALAR_FIELD(boolop);
415 	COMPARE_NODE_FIELD(args);
416 	COMPARE_LOCATION_FIELD(location);
417 
418 	return true;
419 }
420 
421 static bool
_equalSubLink(const SubLink * a,const SubLink * b)422 _equalSubLink(const SubLink *a, const SubLink *b)
423 {
424 	COMPARE_SCALAR_FIELD(subLinkType);
425 	COMPARE_SCALAR_FIELD(subLinkId);
426 	COMPARE_NODE_FIELD(testexpr);
427 	COMPARE_NODE_FIELD(operName);
428 	COMPARE_NODE_FIELD(subselect);
429 	COMPARE_LOCATION_FIELD(location);
430 
431 	return true;
432 }
433 
434 static bool
_equalSubPlan(const SubPlan * a,const SubPlan * b)435 _equalSubPlan(const SubPlan *a, const SubPlan *b)
436 {
437 	COMPARE_SCALAR_FIELD(subLinkType);
438 	COMPARE_NODE_FIELD(testexpr);
439 	COMPARE_NODE_FIELD(paramIds);
440 	COMPARE_SCALAR_FIELD(plan_id);
441 	COMPARE_STRING_FIELD(plan_name);
442 	COMPARE_SCALAR_FIELD(firstColType);
443 	COMPARE_SCALAR_FIELD(firstColTypmod);
444 	COMPARE_SCALAR_FIELD(firstColCollation);
445 	COMPARE_SCALAR_FIELD(useHashTable);
446 	COMPARE_SCALAR_FIELD(unknownEqFalse);
447 	COMPARE_SCALAR_FIELD(parallel_safe);
448 	COMPARE_NODE_FIELD(setParam);
449 	COMPARE_NODE_FIELD(parParam);
450 	COMPARE_NODE_FIELD(args);
451 	COMPARE_SCALAR_FIELD(startup_cost);
452 	COMPARE_SCALAR_FIELD(per_call_cost);
453 
454 	return true;
455 }
456 
457 static bool
_equalAlternativeSubPlan(const AlternativeSubPlan * a,const AlternativeSubPlan * b)458 _equalAlternativeSubPlan(const AlternativeSubPlan *a, const AlternativeSubPlan *b)
459 {
460 	COMPARE_NODE_FIELD(subplans);
461 
462 	return true;
463 }
464 
465 static bool
_equalFieldSelect(const FieldSelect * a,const FieldSelect * b)466 _equalFieldSelect(const FieldSelect *a, const FieldSelect *b)
467 {
468 	COMPARE_NODE_FIELD(arg);
469 	COMPARE_SCALAR_FIELD(fieldnum);
470 	COMPARE_SCALAR_FIELD(resulttype);
471 	COMPARE_SCALAR_FIELD(resulttypmod);
472 	COMPARE_SCALAR_FIELD(resultcollid);
473 
474 	return true;
475 }
476 
477 static bool
_equalFieldStore(const FieldStore * a,const FieldStore * b)478 _equalFieldStore(const FieldStore *a, const FieldStore *b)
479 {
480 	COMPARE_NODE_FIELD(arg);
481 	COMPARE_NODE_FIELD(newvals);
482 	COMPARE_NODE_FIELD(fieldnums);
483 	COMPARE_SCALAR_FIELD(resulttype);
484 
485 	return true;
486 }
487 
488 static bool
_equalRelabelType(const RelabelType * a,const RelabelType * b)489 _equalRelabelType(const RelabelType *a, const RelabelType *b)
490 {
491 	COMPARE_NODE_FIELD(arg);
492 	COMPARE_SCALAR_FIELD(resulttype);
493 	COMPARE_SCALAR_FIELD(resulttypmod);
494 	COMPARE_SCALAR_FIELD(resultcollid);
495 	COMPARE_COERCIONFORM_FIELD(relabelformat);
496 	COMPARE_LOCATION_FIELD(location);
497 
498 	return true;
499 }
500 
501 static bool
_equalCoerceViaIO(const CoerceViaIO * a,const CoerceViaIO * b)502 _equalCoerceViaIO(const CoerceViaIO *a, const CoerceViaIO *b)
503 {
504 	COMPARE_NODE_FIELD(arg);
505 	COMPARE_SCALAR_FIELD(resulttype);
506 	COMPARE_SCALAR_FIELD(resultcollid);
507 	COMPARE_COERCIONFORM_FIELD(coerceformat);
508 	COMPARE_LOCATION_FIELD(location);
509 
510 	return true;
511 }
512 
513 static bool
_equalArrayCoerceExpr(const ArrayCoerceExpr * a,const ArrayCoerceExpr * b)514 _equalArrayCoerceExpr(const ArrayCoerceExpr *a, const ArrayCoerceExpr *b)
515 {
516 	COMPARE_NODE_FIELD(arg);
517 	COMPARE_SCALAR_FIELD(elemfuncid);
518 	COMPARE_SCALAR_FIELD(resulttype);
519 	COMPARE_SCALAR_FIELD(resulttypmod);
520 	COMPARE_SCALAR_FIELD(resultcollid);
521 	COMPARE_SCALAR_FIELD(isExplicit);
522 	COMPARE_COERCIONFORM_FIELD(coerceformat);
523 	COMPARE_LOCATION_FIELD(location);
524 
525 	return true;
526 }
527 
528 static bool
_equalConvertRowtypeExpr(const ConvertRowtypeExpr * a,const ConvertRowtypeExpr * b)529 _equalConvertRowtypeExpr(const ConvertRowtypeExpr *a, const ConvertRowtypeExpr *b)
530 {
531 	COMPARE_NODE_FIELD(arg);
532 	COMPARE_SCALAR_FIELD(resulttype);
533 	COMPARE_COERCIONFORM_FIELD(convertformat);
534 	COMPARE_LOCATION_FIELD(location);
535 
536 	return true;
537 }
538 
539 static bool
_equalCollateExpr(const CollateExpr * a,const CollateExpr * b)540 _equalCollateExpr(const CollateExpr *a, const CollateExpr *b)
541 {
542 	COMPARE_NODE_FIELD(arg);
543 	COMPARE_SCALAR_FIELD(collOid);
544 	COMPARE_LOCATION_FIELD(location);
545 
546 	return true;
547 }
548 
549 static bool
_equalCaseExpr(const CaseExpr * a,const CaseExpr * b)550 _equalCaseExpr(const CaseExpr *a, const CaseExpr *b)
551 {
552 	COMPARE_SCALAR_FIELD(casetype);
553 	COMPARE_SCALAR_FIELD(casecollid);
554 	COMPARE_NODE_FIELD(arg);
555 	COMPARE_NODE_FIELD(args);
556 	COMPARE_NODE_FIELD(defresult);
557 	COMPARE_LOCATION_FIELD(location);
558 
559 	return true;
560 }
561 
562 static bool
_equalCaseWhen(const CaseWhen * a,const CaseWhen * b)563 _equalCaseWhen(const CaseWhen *a, const CaseWhen *b)
564 {
565 	COMPARE_NODE_FIELD(expr);
566 	COMPARE_NODE_FIELD(result);
567 	COMPARE_LOCATION_FIELD(location);
568 
569 	return true;
570 }
571 
572 static bool
_equalCaseTestExpr(const CaseTestExpr * a,const CaseTestExpr * b)573 _equalCaseTestExpr(const CaseTestExpr *a, const CaseTestExpr *b)
574 {
575 	COMPARE_SCALAR_FIELD(typeId);
576 	COMPARE_SCALAR_FIELD(typeMod);
577 	COMPARE_SCALAR_FIELD(collation);
578 
579 	return true;
580 }
581 
582 static bool
_equalArrayExpr(const ArrayExpr * a,const ArrayExpr * b)583 _equalArrayExpr(const ArrayExpr *a, const ArrayExpr *b)
584 {
585 	COMPARE_SCALAR_FIELD(array_typeid);
586 	COMPARE_SCALAR_FIELD(array_collid);
587 	COMPARE_SCALAR_FIELD(element_typeid);
588 	COMPARE_NODE_FIELD(elements);
589 	COMPARE_SCALAR_FIELD(multidims);
590 	COMPARE_LOCATION_FIELD(location);
591 
592 	return true;
593 }
594 
595 static bool
_equalRowExpr(const RowExpr * a,const RowExpr * b)596 _equalRowExpr(const RowExpr *a, const RowExpr *b)
597 {
598 	COMPARE_NODE_FIELD(args);
599 	COMPARE_SCALAR_FIELD(row_typeid);
600 	COMPARE_COERCIONFORM_FIELD(row_format);
601 	COMPARE_NODE_FIELD(colnames);
602 	COMPARE_LOCATION_FIELD(location);
603 
604 	return true;
605 }
606 
607 static bool
_equalRowCompareExpr(const RowCompareExpr * a,const RowCompareExpr * b)608 _equalRowCompareExpr(const RowCompareExpr *a, const RowCompareExpr *b)
609 {
610 	COMPARE_SCALAR_FIELD(rctype);
611 	COMPARE_NODE_FIELD(opnos);
612 	COMPARE_NODE_FIELD(opfamilies);
613 	COMPARE_NODE_FIELD(inputcollids);
614 	COMPARE_NODE_FIELD(largs);
615 	COMPARE_NODE_FIELD(rargs);
616 
617 	return true;
618 }
619 
620 static bool
_equalCoalesceExpr(const CoalesceExpr * a,const CoalesceExpr * b)621 _equalCoalesceExpr(const CoalesceExpr *a, const CoalesceExpr *b)
622 {
623 	COMPARE_SCALAR_FIELD(coalescetype);
624 	COMPARE_SCALAR_FIELD(coalescecollid);
625 	COMPARE_NODE_FIELD(args);
626 	COMPARE_LOCATION_FIELD(location);
627 
628 	return true;
629 }
630 
631 static bool
_equalMinMaxExpr(const MinMaxExpr * a,const MinMaxExpr * b)632 _equalMinMaxExpr(const MinMaxExpr *a, const MinMaxExpr *b)
633 {
634 	COMPARE_SCALAR_FIELD(minmaxtype);
635 	COMPARE_SCALAR_FIELD(minmaxcollid);
636 	COMPARE_SCALAR_FIELD(inputcollid);
637 	COMPARE_SCALAR_FIELD(op);
638 	COMPARE_NODE_FIELD(args);
639 	COMPARE_LOCATION_FIELD(location);
640 
641 	return true;
642 }
643 
644 static bool
_equalSQLValueFunction(const SQLValueFunction * a,const SQLValueFunction * b)645 _equalSQLValueFunction(const SQLValueFunction *a, const SQLValueFunction *b)
646 {
647 	COMPARE_SCALAR_FIELD(op);
648 	COMPARE_SCALAR_FIELD(type);
649 	COMPARE_SCALAR_FIELD(typmod);
650 	COMPARE_LOCATION_FIELD(location);
651 
652 	return true;
653 }
654 
655 static bool
_equalXmlExpr(const XmlExpr * a,const XmlExpr * b)656 _equalXmlExpr(const XmlExpr *a, const XmlExpr *b)
657 {
658 	COMPARE_SCALAR_FIELD(op);
659 	COMPARE_STRING_FIELD(name);
660 	COMPARE_NODE_FIELD(named_args);
661 	COMPARE_NODE_FIELD(arg_names);
662 	COMPARE_NODE_FIELD(args);
663 	COMPARE_SCALAR_FIELD(xmloption);
664 	COMPARE_SCALAR_FIELD(type);
665 	COMPARE_SCALAR_FIELD(typmod);
666 	COMPARE_LOCATION_FIELD(location);
667 
668 	return true;
669 }
670 
671 static bool
_equalNullTest(const NullTest * a,const NullTest * b)672 _equalNullTest(const NullTest *a, const NullTest *b)
673 {
674 	COMPARE_NODE_FIELD(arg);
675 	COMPARE_SCALAR_FIELD(nulltesttype);
676 	COMPARE_SCALAR_FIELD(argisrow);
677 	COMPARE_LOCATION_FIELD(location);
678 
679 	return true;
680 }
681 
682 static bool
_equalBooleanTest(const BooleanTest * a,const BooleanTest * b)683 _equalBooleanTest(const BooleanTest *a, const BooleanTest *b)
684 {
685 	COMPARE_NODE_FIELD(arg);
686 	COMPARE_SCALAR_FIELD(booltesttype);
687 	COMPARE_LOCATION_FIELD(location);
688 
689 	return true;
690 }
691 
692 static bool
_equalCoerceToDomain(const CoerceToDomain * a,const CoerceToDomain * b)693 _equalCoerceToDomain(const CoerceToDomain *a, const CoerceToDomain *b)
694 {
695 	COMPARE_NODE_FIELD(arg);
696 	COMPARE_SCALAR_FIELD(resulttype);
697 	COMPARE_SCALAR_FIELD(resulttypmod);
698 	COMPARE_SCALAR_FIELD(resultcollid);
699 	COMPARE_COERCIONFORM_FIELD(coercionformat);
700 	COMPARE_LOCATION_FIELD(location);
701 
702 	return true;
703 }
704 
705 static bool
_equalCoerceToDomainValue(const CoerceToDomainValue * a,const CoerceToDomainValue * b)706 _equalCoerceToDomainValue(const CoerceToDomainValue *a, const CoerceToDomainValue *b)
707 {
708 	COMPARE_SCALAR_FIELD(typeId);
709 	COMPARE_SCALAR_FIELD(typeMod);
710 	COMPARE_SCALAR_FIELD(collation);
711 	COMPARE_LOCATION_FIELD(location);
712 
713 	return true;
714 }
715 
716 static bool
_equalSetToDefault(const SetToDefault * a,const SetToDefault * b)717 _equalSetToDefault(const SetToDefault *a, const SetToDefault *b)
718 {
719 	COMPARE_SCALAR_FIELD(typeId);
720 	COMPARE_SCALAR_FIELD(typeMod);
721 	COMPARE_SCALAR_FIELD(collation);
722 	COMPARE_LOCATION_FIELD(location);
723 
724 	return true;
725 }
726 
727 static bool
_equalCurrentOfExpr(const CurrentOfExpr * a,const CurrentOfExpr * b)728 _equalCurrentOfExpr(const CurrentOfExpr *a, const CurrentOfExpr *b)
729 {
730 	COMPARE_SCALAR_FIELD(cvarno);
731 	COMPARE_STRING_FIELD(cursor_name);
732 	COMPARE_SCALAR_FIELD(cursor_param);
733 
734 	return true;
735 }
736 
737 static bool
_equalNextValueExpr(const NextValueExpr * a,const NextValueExpr * b)738 _equalNextValueExpr(const NextValueExpr *a, const NextValueExpr *b)
739 {
740 	COMPARE_SCALAR_FIELD(seqid);
741 	COMPARE_SCALAR_FIELD(typeId);
742 
743 	return true;
744 }
745 
746 static bool
_equalInferenceElem(const InferenceElem * a,const InferenceElem * b)747 _equalInferenceElem(const InferenceElem *a, const InferenceElem *b)
748 {
749 	COMPARE_NODE_FIELD(expr);
750 	COMPARE_SCALAR_FIELD(infercollid);
751 	COMPARE_SCALAR_FIELD(inferopclass);
752 
753 	return true;
754 }
755 
756 static bool
_equalTargetEntry(const TargetEntry * a,const TargetEntry * b)757 _equalTargetEntry(const TargetEntry *a, const TargetEntry *b)
758 {
759 	COMPARE_NODE_FIELD(expr);
760 	COMPARE_SCALAR_FIELD(resno);
761 	COMPARE_STRING_FIELD(resname);
762 	COMPARE_SCALAR_FIELD(ressortgroupref);
763 	COMPARE_SCALAR_FIELD(resorigtbl);
764 	COMPARE_SCALAR_FIELD(resorigcol);
765 	COMPARE_SCALAR_FIELD(resjunk);
766 
767 	return true;
768 }
769 
770 static bool
_equalRangeTblRef(const RangeTblRef * a,const RangeTblRef * b)771 _equalRangeTblRef(const RangeTblRef *a, const RangeTblRef *b)
772 {
773 	COMPARE_SCALAR_FIELD(rtindex);
774 
775 	return true;
776 }
777 
778 static bool
_equalJoinExpr(const JoinExpr * a,const JoinExpr * b)779 _equalJoinExpr(const JoinExpr *a, const JoinExpr *b)
780 {
781 	COMPARE_SCALAR_FIELD(jointype);
782 	COMPARE_SCALAR_FIELD(isNatural);
783 	COMPARE_NODE_FIELD(larg);
784 	COMPARE_NODE_FIELD(rarg);
785 	COMPARE_NODE_FIELD(usingClause);
786 	COMPARE_NODE_FIELD(quals);
787 	COMPARE_NODE_FIELD(alias);
788 	COMPARE_SCALAR_FIELD(rtindex);
789 
790 	return true;
791 }
792 
793 static bool
_equalFromExpr(const FromExpr * a,const FromExpr * b)794 _equalFromExpr(const FromExpr *a, const FromExpr *b)
795 {
796 	COMPARE_NODE_FIELD(fromlist);
797 	COMPARE_NODE_FIELD(quals);
798 
799 	return true;
800 }
801 
802 static bool
_equalOnConflictExpr(const OnConflictExpr * a,const OnConflictExpr * b)803 _equalOnConflictExpr(const OnConflictExpr *a, const OnConflictExpr *b)
804 {
805 	COMPARE_SCALAR_FIELD(action);
806 	COMPARE_NODE_FIELD(arbiterElems);
807 	COMPARE_NODE_FIELD(arbiterWhere);
808 	COMPARE_SCALAR_FIELD(constraint);
809 	COMPARE_NODE_FIELD(onConflictSet);
810 	COMPARE_NODE_FIELD(onConflictWhere);
811 	COMPARE_SCALAR_FIELD(exclRelIndex);
812 	COMPARE_NODE_FIELD(exclRelTlist);
813 
814 	return true;
815 }
816 
817 /*
818  * Stuff from relation.h
819  */
820 
821 static bool
_equalPathKey(const PathKey * a,const PathKey * b)822 _equalPathKey(const PathKey *a, const PathKey *b)
823 {
824 	/* We assume pointer equality is sufficient to compare the eclasses */
825 	COMPARE_SCALAR_FIELD(pk_eclass);
826 	COMPARE_SCALAR_FIELD(pk_opfamily);
827 	COMPARE_SCALAR_FIELD(pk_strategy);
828 	COMPARE_SCALAR_FIELD(pk_nulls_first);
829 
830 	return true;
831 }
832 
833 static bool
_equalRestrictInfo(const RestrictInfo * a,const RestrictInfo * b)834 _equalRestrictInfo(const RestrictInfo *a, const RestrictInfo *b)
835 {
836 	COMPARE_NODE_FIELD(clause);
837 	COMPARE_SCALAR_FIELD(is_pushed_down);
838 	COMPARE_SCALAR_FIELD(outerjoin_delayed);
839 	COMPARE_SCALAR_FIELD(security_level);
840 	COMPARE_BITMAPSET_FIELD(required_relids);
841 	COMPARE_BITMAPSET_FIELD(outer_relids);
842 	COMPARE_BITMAPSET_FIELD(nullable_relids);
843 
844 	/*
845 	 * We ignore all the remaining fields, since they may not be set yet, and
846 	 * should be derivable from the clause anyway.
847 	 */
848 
849 	return true;
850 }
851 
852 static bool
_equalPlaceHolderVar(const PlaceHolderVar * a,const PlaceHolderVar * b)853 _equalPlaceHolderVar(const PlaceHolderVar *a, const PlaceHolderVar *b)
854 {
855 	/*
856 	 * We intentionally do not compare phexpr.  Two PlaceHolderVars with the
857 	 * same ID and levelsup should be considered equal even if the contained
858 	 * expressions have managed to mutate to different states.  This will
859 	 * happen during final plan construction when there are nested PHVs, since
860 	 * the inner PHV will get replaced by a Param in some copies of the outer
861 	 * PHV.  Another way in which it can happen is that initplan sublinks
862 	 * could get replaced by differently-numbered Params when sublink folding
863 	 * is done.  (The end result of such a situation would be some
864 	 * unreferenced initplans, which is annoying but not really a problem.) On
865 	 * the same reasoning, there is no need to examine phrels.
866 	 *
867 	 * COMPARE_NODE_FIELD(phexpr);
868 	 *
869 	 * COMPARE_BITMAPSET_FIELD(phrels);
870 	 */
871 	COMPARE_SCALAR_FIELD(phid);
872 	COMPARE_SCALAR_FIELD(phlevelsup);
873 
874 	return true;
875 }
876 
877 static bool
_equalSpecialJoinInfo(const SpecialJoinInfo * a,const SpecialJoinInfo * b)878 _equalSpecialJoinInfo(const SpecialJoinInfo *a, const SpecialJoinInfo *b)
879 {
880 	COMPARE_BITMAPSET_FIELD(min_lefthand);
881 	COMPARE_BITMAPSET_FIELD(min_righthand);
882 	COMPARE_BITMAPSET_FIELD(syn_lefthand);
883 	COMPARE_BITMAPSET_FIELD(syn_righthand);
884 	COMPARE_SCALAR_FIELD(jointype);
885 	COMPARE_SCALAR_FIELD(lhs_strict);
886 	COMPARE_SCALAR_FIELD(delay_upper_joins);
887 	COMPARE_SCALAR_FIELD(semi_can_btree);
888 	COMPARE_SCALAR_FIELD(semi_can_hash);
889 	COMPARE_NODE_FIELD(semi_operators);
890 	COMPARE_NODE_FIELD(semi_rhs_exprs);
891 
892 	return true;
893 }
894 
895 static bool
_equalAppendRelInfo(const AppendRelInfo * a,const AppendRelInfo * b)896 _equalAppendRelInfo(const AppendRelInfo *a, const AppendRelInfo *b)
897 {
898 	COMPARE_SCALAR_FIELD(parent_relid);
899 	COMPARE_SCALAR_FIELD(child_relid);
900 	COMPARE_SCALAR_FIELD(parent_reltype);
901 	COMPARE_SCALAR_FIELD(child_reltype);
902 	COMPARE_NODE_FIELD(translated_vars);
903 	COMPARE_SCALAR_FIELD(parent_reloid);
904 
905 	return true;
906 }
907 
908 static bool
_equalPartitionedChildRelInfo(const PartitionedChildRelInfo * a,const PartitionedChildRelInfo * b)909 _equalPartitionedChildRelInfo(const PartitionedChildRelInfo *a, const PartitionedChildRelInfo *b)
910 {
911 	COMPARE_SCALAR_FIELD(parent_relid);
912 	COMPARE_NODE_FIELD(child_rels);
913 
914 	return true;
915 }
916 
917 static bool
_equalPlaceHolderInfo(const PlaceHolderInfo * a,const PlaceHolderInfo * b)918 _equalPlaceHolderInfo(const PlaceHolderInfo *a, const PlaceHolderInfo *b)
919 {
920 	COMPARE_SCALAR_FIELD(phid);
921 	COMPARE_NODE_FIELD(ph_var); /* should be redundant */
922 	COMPARE_BITMAPSET_FIELD(ph_eval_at);
923 	COMPARE_BITMAPSET_FIELD(ph_lateral);
924 	COMPARE_BITMAPSET_FIELD(ph_needed);
925 	COMPARE_SCALAR_FIELD(ph_width);
926 
927 	return true;
928 }
929 
930 /*
931  * Stuff from extensible.h
932  */
933 static bool
_equalExtensibleNode(const ExtensibleNode * a,const ExtensibleNode * b)934 _equalExtensibleNode(const ExtensibleNode *a, const ExtensibleNode *b)
935 {
936 	const ExtensibleNodeMethods *methods;
937 
938 	COMPARE_STRING_FIELD(extnodename);
939 
940 	/* At this point, we know extnodename is the same for both nodes. */
941 	methods = GetExtensibleNodeMethods(a->extnodename, false);
942 
943 	/* compare the private fields */
944 	if (!methods->nodeEqual(a, b))
945 		return false;
946 
947 	return true;
948 }
949 
950 /*
951  * Stuff from parsenodes.h
952  */
953 
954 static bool
_equalQuery(const Query * a,const Query * b)955 _equalQuery(const Query *a, const Query *b)
956 {
957 	COMPARE_SCALAR_FIELD(commandType);
958 	COMPARE_SCALAR_FIELD(querySource);
959 	/* we intentionally ignore queryId, since it might not be set */
960 	COMPARE_SCALAR_FIELD(canSetTag);
961 	COMPARE_NODE_FIELD(utilityStmt);
962 	COMPARE_SCALAR_FIELD(resultRelation);
963 	COMPARE_SCALAR_FIELD(hasAggs);
964 	COMPARE_SCALAR_FIELD(hasWindowFuncs);
965 	COMPARE_SCALAR_FIELD(hasTargetSRFs);
966 	COMPARE_SCALAR_FIELD(hasSubLinks);
967 	COMPARE_SCALAR_FIELD(hasDistinctOn);
968 	COMPARE_SCALAR_FIELD(hasRecursive);
969 	COMPARE_SCALAR_FIELD(hasModifyingCTE);
970 	COMPARE_SCALAR_FIELD(hasForUpdate);
971 	COMPARE_SCALAR_FIELD(hasRowSecurity);
972 	COMPARE_NODE_FIELD(cteList);
973 	COMPARE_NODE_FIELD(rtable);
974 	COMPARE_NODE_FIELD(jointree);
975 	COMPARE_NODE_FIELD(targetList);
976 	COMPARE_SCALAR_FIELD(override);
977 	COMPARE_NODE_FIELD(onConflict);
978 	COMPARE_NODE_FIELD(returningList);
979 	COMPARE_NODE_FIELD(groupClause);
980 	COMPARE_NODE_FIELD(groupingSets);
981 	COMPARE_NODE_FIELD(havingQual);
982 	COMPARE_NODE_FIELD(windowClause);
983 	COMPARE_NODE_FIELD(distinctClause);
984 	COMPARE_NODE_FIELD(sortClause);
985 	COMPARE_NODE_FIELD(limitOffset);
986 	COMPARE_NODE_FIELD(limitCount);
987 	COMPARE_NODE_FIELD(rowMarks);
988 	COMPARE_NODE_FIELD(setOperations);
989 	COMPARE_NODE_FIELD(constraintDeps);
990 	COMPARE_NODE_FIELD(withCheckOptions);
991 	COMPARE_LOCATION_FIELD(stmt_location);
992 	COMPARE_LOCATION_FIELD(stmt_len);
993 
994 	return true;
995 }
996 
997 static bool
_equalRawStmt(const RawStmt * a,const RawStmt * b)998 _equalRawStmt(const RawStmt *a, const RawStmt *b)
999 {
1000 	COMPARE_NODE_FIELD(stmt);
1001 	COMPARE_LOCATION_FIELD(stmt_location);
1002 	COMPARE_LOCATION_FIELD(stmt_len);
1003 
1004 	return true;
1005 }
1006 
1007 static bool
_equalInsertStmt(const InsertStmt * a,const InsertStmt * b)1008 _equalInsertStmt(const InsertStmt *a, const InsertStmt *b)
1009 {
1010 	COMPARE_NODE_FIELD(relation);
1011 	COMPARE_NODE_FIELD(cols);
1012 	COMPARE_NODE_FIELD(selectStmt);
1013 	COMPARE_NODE_FIELD(onConflictClause);
1014 	COMPARE_NODE_FIELD(returningList);
1015 	COMPARE_NODE_FIELD(withClause);
1016 	COMPARE_SCALAR_FIELD(override);
1017 
1018 	return true;
1019 }
1020 
1021 static bool
_equalDeleteStmt(const DeleteStmt * a,const DeleteStmt * b)1022 _equalDeleteStmt(const DeleteStmt *a, const DeleteStmt *b)
1023 {
1024 	COMPARE_NODE_FIELD(relation);
1025 	COMPARE_NODE_FIELD(usingClause);
1026 	COMPARE_NODE_FIELD(whereClause);
1027 	COMPARE_NODE_FIELD(returningList);
1028 	COMPARE_NODE_FIELD(withClause);
1029 
1030 	return true;
1031 }
1032 
1033 static bool
_equalUpdateStmt(const UpdateStmt * a,const UpdateStmt * b)1034 _equalUpdateStmt(const UpdateStmt *a, const UpdateStmt *b)
1035 {
1036 	COMPARE_NODE_FIELD(relation);
1037 	COMPARE_NODE_FIELD(targetList);
1038 	COMPARE_NODE_FIELD(whereClause);
1039 	COMPARE_NODE_FIELD(fromClause);
1040 	COMPARE_NODE_FIELD(returningList);
1041 	COMPARE_NODE_FIELD(withClause);
1042 
1043 	return true;
1044 }
1045 
1046 static bool
_equalSelectStmt(const SelectStmt * a,const SelectStmt * b)1047 _equalSelectStmt(const SelectStmt *a, const SelectStmt *b)
1048 {
1049 	COMPARE_NODE_FIELD(distinctClause);
1050 	COMPARE_NODE_FIELD(intoClause);
1051 	COMPARE_NODE_FIELD(targetList);
1052 	COMPARE_NODE_FIELD(fromClause);
1053 	COMPARE_NODE_FIELD(whereClause);
1054 	COMPARE_NODE_FIELD(groupClause);
1055 	COMPARE_NODE_FIELD(havingClause);
1056 	COMPARE_NODE_FIELD(windowClause);
1057 	COMPARE_NODE_FIELD(valuesLists);
1058 	COMPARE_NODE_FIELD(sortClause);
1059 	COMPARE_NODE_FIELD(limitOffset);
1060 	COMPARE_NODE_FIELD(limitCount);
1061 	COMPARE_NODE_FIELD(lockingClause);
1062 	COMPARE_NODE_FIELD(withClause);
1063 	COMPARE_SCALAR_FIELD(op);
1064 	COMPARE_SCALAR_FIELD(all);
1065 	COMPARE_NODE_FIELD(larg);
1066 	COMPARE_NODE_FIELD(rarg);
1067 
1068 	return true;
1069 }
1070 
1071 static bool
_equalSetOperationStmt(const SetOperationStmt * a,const SetOperationStmt * b)1072 _equalSetOperationStmt(const SetOperationStmt *a, const SetOperationStmt *b)
1073 {
1074 	COMPARE_SCALAR_FIELD(op);
1075 	COMPARE_SCALAR_FIELD(all);
1076 	COMPARE_NODE_FIELD(larg);
1077 	COMPARE_NODE_FIELD(rarg);
1078 	COMPARE_NODE_FIELD(colTypes);
1079 	COMPARE_NODE_FIELD(colTypmods);
1080 	COMPARE_NODE_FIELD(colCollations);
1081 	COMPARE_NODE_FIELD(groupClauses);
1082 
1083 	return true;
1084 }
1085 
1086 static bool
_equalAlterTableStmt(const AlterTableStmt * a,const AlterTableStmt * b)1087 _equalAlterTableStmt(const AlterTableStmt *a, const AlterTableStmt *b)
1088 {
1089 	COMPARE_NODE_FIELD(relation);
1090 	COMPARE_NODE_FIELD(cmds);
1091 	COMPARE_SCALAR_FIELD(relkind);
1092 	COMPARE_SCALAR_FIELD(missing_ok);
1093 
1094 	return true;
1095 }
1096 
1097 static bool
_equalAlterTableCmd(const AlterTableCmd * a,const AlterTableCmd * b)1098 _equalAlterTableCmd(const AlterTableCmd *a, const AlterTableCmd *b)
1099 {
1100 	COMPARE_SCALAR_FIELD(subtype);
1101 	COMPARE_STRING_FIELD(name);
1102 	COMPARE_NODE_FIELD(newowner);
1103 	COMPARE_NODE_FIELD(def);
1104 	COMPARE_SCALAR_FIELD(behavior);
1105 	COMPARE_SCALAR_FIELD(missing_ok);
1106 
1107 	return true;
1108 }
1109 
1110 static bool
_equalAlterCollationStmt(const AlterCollationStmt * a,const AlterCollationStmt * b)1111 _equalAlterCollationStmt(const AlterCollationStmt *a, const AlterCollationStmt *b)
1112 {
1113 	COMPARE_NODE_FIELD(collname);
1114 
1115 	return true;
1116 }
1117 
1118 static bool
_equalAlterDomainStmt(const AlterDomainStmt * a,const AlterDomainStmt * b)1119 _equalAlterDomainStmt(const AlterDomainStmt *a, const AlterDomainStmt *b)
1120 {
1121 	COMPARE_SCALAR_FIELD(subtype);
1122 	COMPARE_NODE_FIELD(typeName);
1123 	COMPARE_STRING_FIELD(name);
1124 	COMPARE_NODE_FIELD(def);
1125 	COMPARE_SCALAR_FIELD(behavior);
1126 	COMPARE_SCALAR_FIELD(missing_ok);
1127 
1128 	return true;
1129 }
1130 
1131 static bool
_equalGrantStmt(const GrantStmt * a,const GrantStmt * b)1132 _equalGrantStmt(const GrantStmt *a, const GrantStmt *b)
1133 {
1134 	COMPARE_SCALAR_FIELD(is_grant);
1135 	COMPARE_SCALAR_FIELD(targtype);
1136 	COMPARE_SCALAR_FIELD(objtype);
1137 	COMPARE_NODE_FIELD(objects);
1138 	COMPARE_NODE_FIELD(privileges);
1139 	COMPARE_NODE_FIELD(grantees);
1140 	COMPARE_SCALAR_FIELD(grant_option);
1141 	COMPARE_SCALAR_FIELD(behavior);
1142 
1143 	return true;
1144 }
1145 
1146 static bool
_equalObjectWithArgs(const ObjectWithArgs * a,const ObjectWithArgs * b)1147 _equalObjectWithArgs(const ObjectWithArgs *a, const ObjectWithArgs *b)
1148 {
1149 	COMPARE_NODE_FIELD(objname);
1150 	COMPARE_NODE_FIELD(objargs);
1151 	COMPARE_SCALAR_FIELD(args_unspecified);
1152 
1153 	return true;
1154 }
1155 
1156 static bool
_equalAccessPriv(const AccessPriv * a,const AccessPriv * b)1157 _equalAccessPriv(const AccessPriv *a, const AccessPriv *b)
1158 {
1159 	COMPARE_STRING_FIELD(priv_name);
1160 	COMPARE_NODE_FIELD(cols);
1161 
1162 	return true;
1163 }
1164 
1165 static bool
_equalGrantRoleStmt(const GrantRoleStmt * a,const GrantRoleStmt * b)1166 _equalGrantRoleStmt(const GrantRoleStmt *a, const GrantRoleStmt *b)
1167 {
1168 	COMPARE_NODE_FIELD(granted_roles);
1169 	COMPARE_NODE_FIELD(grantee_roles);
1170 	COMPARE_SCALAR_FIELD(is_grant);
1171 	COMPARE_SCALAR_FIELD(admin_opt);
1172 	COMPARE_NODE_FIELD(grantor);
1173 	COMPARE_SCALAR_FIELD(behavior);
1174 
1175 	return true;
1176 }
1177 
1178 static bool
_equalAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt * a,const AlterDefaultPrivilegesStmt * b)1179 _equalAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *a, const AlterDefaultPrivilegesStmt *b)
1180 {
1181 	COMPARE_NODE_FIELD(options);
1182 	COMPARE_NODE_FIELD(action);
1183 
1184 	return true;
1185 }
1186 
1187 static bool
_equalDeclareCursorStmt(const DeclareCursorStmt * a,const DeclareCursorStmt * b)1188 _equalDeclareCursorStmt(const DeclareCursorStmt *a, const DeclareCursorStmt *b)
1189 {
1190 	COMPARE_STRING_FIELD(portalname);
1191 	COMPARE_SCALAR_FIELD(options);
1192 	COMPARE_NODE_FIELD(query);
1193 
1194 	return true;
1195 }
1196 
1197 static bool
_equalClosePortalStmt(const ClosePortalStmt * a,const ClosePortalStmt * b)1198 _equalClosePortalStmt(const ClosePortalStmt *a, const ClosePortalStmt *b)
1199 {
1200 	COMPARE_STRING_FIELD(portalname);
1201 
1202 	return true;
1203 }
1204 
1205 static bool
_equalClusterStmt(const ClusterStmt * a,const ClusterStmt * b)1206 _equalClusterStmt(const ClusterStmt *a, const ClusterStmt *b)
1207 {
1208 	COMPARE_NODE_FIELD(relation);
1209 	COMPARE_STRING_FIELD(indexname);
1210 	COMPARE_SCALAR_FIELD(verbose);
1211 
1212 	return true;
1213 }
1214 
1215 static bool
_equalCopyStmt(const CopyStmt * a,const CopyStmt * b)1216 _equalCopyStmt(const CopyStmt *a, const CopyStmt *b)
1217 {
1218 	COMPARE_NODE_FIELD(relation);
1219 	COMPARE_NODE_FIELD(query);
1220 	COMPARE_NODE_FIELD(attlist);
1221 	COMPARE_SCALAR_FIELD(is_from);
1222 	COMPARE_SCALAR_FIELD(is_program);
1223 	COMPARE_STRING_FIELD(filename);
1224 	COMPARE_NODE_FIELD(options);
1225 
1226 	return true;
1227 }
1228 
1229 static bool
_equalCreateStmt(const CreateStmt * a,const CreateStmt * b)1230 _equalCreateStmt(const CreateStmt *a, const CreateStmt *b)
1231 {
1232 	COMPARE_NODE_FIELD(relation);
1233 	COMPARE_NODE_FIELD(tableElts);
1234 	COMPARE_NODE_FIELD(inhRelations);
1235 	COMPARE_NODE_FIELD(partbound);
1236 	COMPARE_NODE_FIELD(partspec);
1237 	COMPARE_NODE_FIELD(ofTypename);
1238 	COMPARE_NODE_FIELD(constraints);
1239 	COMPARE_NODE_FIELD(options);
1240 	COMPARE_SCALAR_FIELD(oncommit);
1241 	COMPARE_STRING_FIELD(tablespacename);
1242 	COMPARE_SCALAR_FIELD(if_not_exists);
1243 
1244 	return true;
1245 }
1246 
1247 static bool
_equalTableLikeClause(const TableLikeClause * a,const TableLikeClause * b)1248 _equalTableLikeClause(const TableLikeClause *a, const TableLikeClause *b)
1249 {
1250 	COMPARE_NODE_FIELD(relation);
1251 	COMPARE_SCALAR_FIELD(options);
1252 	COMPARE_SCALAR_FIELD(relationOid);
1253 
1254 	return true;
1255 }
1256 
1257 static bool
_equalDefineStmt(const DefineStmt * a,const DefineStmt * b)1258 _equalDefineStmt(const DefineStmt *a, const DefineStmt *b)
1259 {
1260 	COMPARE_SCALAR_FIELD(kind);
1261 	COMPARE_SCALAR_FIELD(oldstyle);
1262 	COMPARE_NODE_FIELD(defnames);
1263 	COMPARE_NODE_FIELD(args);
1264 	COMPARE_NODE_FIELD(definition);
1265 	COMPARE_SCALAR_FIELD(if_not_exists);
1266 
1267 	return true;
1268 }
1269 
1270 static bool
_equalDropStmt(const DropStmt * a,const DropStmt * b)1271 _equalDropStmt(const DropStmt *a, const DropStmt *b)
1272 {
1273 	COMPARE_NODE_FIELD(objects);
1274 	COMPARE_SCALAR_FIELD(removeType);
1275 	COMPARE_SCALAR_FIELD(behavior);
1276 	COMPARE_SCALAR_FIELD(missing_ok);
1277 	COMPARE_SCALAR_FIELD(concurrent);
1278 
1279 	return true;
1280 }
1281 
1282 static bool
_equalTruncateStmt(const TruncateStmt * a,const TruncateStmt * b)1283 _equalTruncateStmt(const TruncateStmt *a, const TruncateStmt *b)
1284 {
1285 	COMPARE_NODE_FIELD(relations);
1286 	COMPARE_SCALAR_FIELD(restart_seqs);
1287 	COMPARE_SCALAR_FIELD(behavior);
1288 
1289 	return true;
1290 }
1291 
1292 static bool
_equalCommentStmt(const CommentStmt * a,const CommentStmt * b)1293 _equalCommentStmt(const CommentStmt *a, const CommentStmt *b)
1294 {
1295 	COMPARE_SCALAR_FIELD(objtype);
1296 	COMPARE_NODE_FIELD(object);
1297 	COMPARE_STRING_FIELD(comment);
1298 
1299 	return true;
1300 }
1301 
1302 static bool
_equalSecLabelStmt(const SecLabelStmt * a,const SecLabelStmt * b)1303 _equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b)
1304 {
1305 	COMPARE_SCALAR_FIELD(objtype);
1306 	COMPARE_NODE_FIELD(object);
1307 	COMPARE_STRING_FIELD(provider);
1308 	COMPARE_STRING_FIELD(label);
1309 
1310 	return true;
1311 }
1312 
1313 static bool
_equalFetchStmt(const FetchStmt * a,const FetchStmt * b)1314 _equalFetchStmt(const FetchStmt *a, const FetchStmt *b)
1315 {
1316 	COMPARE_SCALAR_FIELD(direction);
1317 	COMPARE_SCALAR_FIELD(howMany);
1318 	COMPARE_STRING_FIELD(portalname);
1319 	COMPARE_SCALAR_FIELD(ismove);
1320 
1321 	return true;
1322 }
1323 
1324 static bool
_equalIndexStmt(const IndexStmt * a,const IndexStmt * b)1325 _equalIndexStmt(const IndexStmt *a, const IndexStmt *b)
1326 {
1327 	COMPARE_STRING_FIELD(idxname);
1328 	COMPARE_NODE_FIELD(relation);
1329 	COMPARE_STRING_FIELD(accessMethod);
1330 	COMPARE_STRING_FIELD(tableSpace);
1331 	COMPARE_NODE_FIELD(indexParams);
1332 	COMPARE_NODE_FIELD(options);
1333 	COMPARE_NODE_FIELD(whereClause);
1334 	COMPARE_NODE_FIELD(excludeOpNames);
1335 	COMPARE_STRING_FIELD(idxcomment);
1336 	COMPARE_SCALAR_FIELD(indexOid);
1337 	COMPARE_SCALAR_FIELD(oldNode);
1338 	COMPARE_SCALAR_FIELD(unique);
1339 	COMPARE_SCALAR_FIELD(primary);
1340 	COMPARE_SCALAR_FIELD(isconstraint);
1341 	COMPARE_SCALAR_FIELD(deferrable);
1342 	COMPARE_SCALAR_FIELD(initdeferred);
1343 	COMPARE_SCALAR_FIELD(transformed);
1344 	COMPARE_SCALAR_FIELD(concurrent);
1345 	COMPARE_SCALAR_FIELD(if_not_exists);
1346 
1347 	return true;
1348 }
1349 
1350 static bool
_equalCreateStatsStmt(const CreateStatsStmt * a,const CreateStatsStmt * b)1351 _equalCreateStatsStmt(const CreateStatsStmt *a, const CreateStatsStmt *b)
1352 {
1353 	COMPARE_NODE_FIELD(defnames);
1354 	COMPARE_NODE_FIELD(stat_types);
1355 	COMPARE_NODE_FIELD(exprs);
1356 	COMPARE_NODE_FIELD(relations);
1357 	COMPARE_SCALAR_FIELD(if_not_exists);
1358 
1359 	return true;
1360 }
1361 
1362 static bool
_equalCreateFunctionStmt(const CreateFunctionStmt * a,const CreateFunctionStmt * b)1363 _equalCreateFunctionStmt(const CreateFunctionStmt *a, const CreateFunctionStmt *b)
1364 {
1365 	COMPARE_SCALAR_FIELD(replace);
1366 	COMPARE_NODE_FIELD(funcname);
1367 	COMPARE_NODE_FIELD(parameters);
1368 	COMPARE_NODE_FIELD(returnType);
1369 	COMPARE_NODE_FIELD(options);
1370 	COMPARE_NODE_FIELD(withClause);
1371 
1372 	return true;
1373 }
1374 
1375 static bool
_equalFunctionParameter(const FunctionParameter * a,const FunctionParameter * b)1376 _equalFunctionParameter(const FunctionParameter *a, const FunctionParameter *b)
1377 {
1378 	COMPARE_STRING_FIELD(name);
1379 	COMPARE_NODE_FIELD(argType);
1380 	COMPARE_SCALAR_FIELD(mode);
1381 	COMPARE_NODE_FIELD(defexpr);
1382 
1383 	return true;
1384 }
1385 
1386 static bool
_equalAlterFunctionStmt(const AlterFunctionStmt * a,const AlterFunctionStmt * b)1387 _equalAlterFunctionStmt(const AlterFunctionStmt *a, const AlterFunctionStmt *b)
1388 {
1389 	COMPARE_NODE_FIELD(func);
1390 	COMPARE_NODE_FIELD(actions);
1391 
1392 	return true;
1393 }
1394 
1395 static bool
_equalDoStmt(const DoStmt * a,const DoStmt * b)1396 _equalDoStmt(const DoStmt *a, const DoStmt *b)
1397 {
1398 	COMPARE_NODE_FIELD(args);
1399 
1400 	return true;
1401 }
1402 
1403 static bool
_equalRenameStmt(const RenameStmt * a,const RenameStmt * b)1404 _equalRenameStmt(const RenameStmt *a, const RenameStmt *b)
1405 {
1406 	COMPARE_SCALAR_FIELD(renameType);
1407 	COMPARE_SCALAR_FIELD(relationType);
1408 	COMPARE_NODE_FIELD(relation);
1409 	COMPARE_NODE_FIELD(object);
1410 	COMPARE_STRING_FIELD(subname);
1411 	COMPARE_STRING_FIELD(newname);
1412 	COMPARE_SCALAR_FIELD(behavior);
1413 	COMPARE_SCALAR_FIELD(missing_ok);
1414 
1415 	return true;
1416 }
1417 
1418 static bool
_equalAlterObjectDependsStmt(const AlterObjectDependsStmt * a,const AlterObjectDependsStmt * b)1419 _equalAlterObjectDependsStmt(const AlterObjectDependsStmt *a, const AlterObjectDependsStmt *b)
1420 {
1421 	COMPARE_SCALAR_FIELD(objectType);
1422 	COMPARE_NODE_FIELD(relation);
1423 	COMPARE_NODE_FIELD(object);
1424 	COMPARE_NODE_FIELD(extname);
1425 
1426 	return true;
1427 }
1428 
1429 static bool
_equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt * a,const AlterObjectSchemaStmt * b)1430 _equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt *a, const AlterObjectSchemaStmt *b)
1431 {
1432 	COMPARE_SCALAR_FIELD(objectType);
1433 	COMPARE_NODE_FIELD(relation);
1434 	COMPARE_NODE_FIELD(object);
1435 	COMPARE_STRING_FIELD(newschema);
1436 	COMPARE_SCALAR_FIELD(missing_ok);
1437 
1438 	return true;
1439 }
1440 
1441 static bool
_equalAlterOwnerStmt(const AlterOwnerStmt * a,const AlterOwnerStmt * b)1442 _equalAlterOwnerStmt(const AlterOwnerStmt *a, const AlterOwnerStmt *b)
1443 {
1444 	COMPARE_SCALAR_FIELD(objectType);
1445 	COMPARE_NODE_FIELD(relation);
1446 	COMPARE_NODE_FIELD(object);
1447 	COMPARE_NODE_FIELD(newowner);
1448 
1449 	return true;
1450 }
1451 
1452 static bool
_equalAlterOperatorStmt(const AlterOperatorStmt * a,const AlterOperatorStmt * b)1453 _equalAlterOperatorStmt(const AlterOperatorStmt *a, const AlterOperatorStmt *b)
1454 {
1455 	COMPARE_NODE_FIELD(opername);
1456 	COMPARE_NODE_FIELD(options);
1457 
1458 	return true;
1459 }
1460 
1461 static bool
_equalRuleStmt(const RuleStmt * a,const RuleStmt * b)1462 _equalRuleStmt(const RuleStmt *a, const RuleStmt *b)
1463 {
1464 	COMPARE_NODE_FIELD(relation);
1465 	COMPARE_STRING_FIELD(rulename);
1466 	COMPARE_NODE_FIELD(whereClause);
1467 	COMPARE_SCALAR_FIELD(event);
1468 	COMPARE_SCALAR_FIELD(instead);
1469 	COMPARE_NODE_FIELD(actions);
1470 	COMPARE_SCALAR_FIELD(replace);
1471 
1472 	return true;
1473 }
1474 
1475 static bool
_equalNotifyStmt(const NotifyStmt * a,const NotifyStmt * b)1476 _equalNotifyStmt(const NotifyStmt *a, const NotifyStmt *b)
1477 {
1478 	COMPARE_STRING_FIELD(conditionname);
1479 	COMPARE_STRING_FIELD(payload);
1480 
1481 	return true;
1482 }
1483 
1484 static bool
_equalListenStmt(const ListenStmt * a,const ListenStmt * b)1485 _equalListenStmt(const ListenStmt *a, const ListenStmt *b)
1486 {
1487 	COMPARE_STRING_FIELD(conditionname);
1488 
1489 	return true;
1490 }
1491 
1492 static bool
_equalUnlistenStmt(const UnlistenStmt * a,const UnlistenStmt * b)1493 _equalUnlistenStmt(const UnlistenStmt *a, const UnlistenStmt *b)
1494 {
1495 	COMPARE_STRING_FIELD(conditionname);
1496 
1497 	return true;
1498 }
1499 
1500 static bool
_equalTransactionStmt(const TransactionStmt * a,const TransactionStmt * b)1501 _equalTransactionStmt(const TransactionStmt *a, const TransactionStmt *b)
1502 {
1503 	COMPARE_SCALAR_FIELD(kind);
1504 	COMPARE_NODE_FIELD(options);
1505 	COMPARE_STRING_FIELD(gid);
1506 
1507 	return true;
1508 }
1509 
1510 static bool
_equalCompositeTypeStmt(const CompositeTypeStmt * a,const CompositeTypeStmt * b)1511 _equalCompositeTypeStmt(const CompositeTypeStmt *a, const CompositeTypeStmt *b)
1512 {
1513 	COMPARE_NODE_FIELD(typevar);
1514 	COMPARE_NODE_FIELD(coldeflist);
1515 
1516 	return true;
1517 }
1518 
1519 static bool
_equalCreateEnumStmt(const CreateEnumStmt * a,const CreateEnumStmt * b)1520 _equalCreateEnumStmt(const CreateEnumStmt *a, const CreateEnumStmt *b)
1521 {
1522 	COMPARE_NODE_FIELD(typeName);
1523 	COMPARE_NODE_FIELD(vals);
1524 
1525 	return true;
1526 }
1527 
1528 static bool
_equalCreateRangeStmt(const CreateRangeStmt * a,const CreateRangeStmt * b)1529 _equalCreateRangeStmt(const CreateRangeStmt *a, const CreateRangeStmt *b)
1530 {
1531 	COMPARE_NODE_FIELD(typeName);
1532 	COMPARE_NODE_FIELD(params);
1533 
1534 	return true;
1535 }
1536 
1537 static bool
_equalAlterEnumStmt(const AlterEnumStmt * a,const AlterEnumStmt * b)1538 _equalAlterEnumStmt(const AlterEnumStmt *a, const AlterEnumStmt *b)
1539 {
1540 	COMPARE_NODE_FIELD(typeName);
1541 	COMPARE_STRING_FIELD(oldVal);
1542 	COMPARE_STRING_FIELD(newVal);
1543 	COMPARE_STRING_FIELD(newValNeighbor);
1544 	COMPARE_SCALAR_FIELD(newValIsAfter);
1545 	COMPARE_SCALAR_FIELD(skipIfNewValExists);
1546 
1547 	return true;
1548 }
1549 
1550 static bool
_equalViewStmt(const ViewStmt * a,const ViewStmt * b)1551 _equalViewStmt(const ViewStmt *a, const ViewStmt *b)
1552 {
1553 	COMPARE_NODE_FIELD(view);
1554 	COMPARE_NODE_FIELD(aliases);
1555 	COMPARE_NODE_FIELD(query);
1556 	COMPARE_SCALAR_FIELD(replace);
1557 	COMPARE_NODE_FIELD(options);
1558 	COMPARE_SCALAR_FIELD(withCheckOption);
1559 
1560 	return true;
1561 }
1562 
1563 static bool
_equalLoadStmt(const LoadStmt * a,const LoadStmt * b)1564 _equalLoadStmt(const LoadStmt *a, const LoadStmt *b)
1565 {
1566 	COMPARE_STRING_FIELD(filename);
1567 
1568 	return true;
1569 }
1570 
1571 static bool
_equalCreateDomainStmt(const CreateDomainStmt * a,const CreateDomainStmt * b)1572 _equalCreateDomainStmt(const CreateDomainStmt *a, const CreateDomainStmt *b)
1573 {
1574 	COMPARE_NODE_FIELD(domainname);
1575 	COMPARE_NODE_FIELD(typeName);
1576 	COMPARE_NODE_FIELD(collClause);
1577 	COMPARE_NODE_FIELD(constraints);
1578 
1579 	return true;
1580 }
1581 
1582 static bool
_equalCreateOpClassStmt(const CreateOpClassStmt * a,const CreateOpClassStmt * b)1583 _equalCreateOpClassStmt(const CreateOpClassStmt *a, const CreateOpClassStmt *b)
1584 {
1585 	COMPARE_NODE_FIELD(opclassname);
1586 	COMPARE_NODE_FIELD(opfamilyname);
1587 	COMPARE_STRING_FIELD(amname);
1588 	COMPARE_NODE_FIELD(datatype);
1589 	COMPARE_NODE_FIELD(items);
1590 	COMPARE_SCALAR_FIELD(isDefault);
1591 
1592 	return true;
1593 }
1594 
1595 static bool
_equalCreateOpClassItem(const CreateOpClassItem * a,const CreateOpClassItem * b)1596 _equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b)
1597 {
1598 	COMPARE_SCALAR_FIELD(itemtype);
1599 	COMPARE_NODE_FIELD(name);
1600 	COMPARE_SCALAR_FIELD(number);
1601 	COMPARE_NODE_FIELD(order_family);
1602 	COMPARE_NODE_FIELD(class_args);
1603 	COMPARE_NODE_FIELD(storedtype);
1604 
1605 	return true;
1606 }
1607 
1608 static bool
_equalCreateOpFamilyStmt(const CreateOpFamilyStmt * a,const CreateOpFamilyStmt * b)1609 _equalCreateOpFamilyStmt(const CreateOpFamilyStmt *a, const CreateOpFamilyStmt *b)
1610 {
1611 	COMPARE_NODE_FIELD(opfamilyname);
1612 	COMPARE_STRING_FIELD(amname);
1613 
1614 	return true;
1615 }
1616 
1617 static bool
_equalAlterOpFamilyStmt(const AlterOpFamilyStmt * a,const AlterOpFamilyStmt * b)1618 _equalAlterOpFamilyStmt(const AlterOpFamilyStmt *a, const AlterOpFamilyStmt *b)
1619 {
1620 	COMPARE_NODE_FIELD(opfamilyname);
1621 	COMPARE_STRING_FIELD(amname);
1622 	COMPARE_SCALAR_FIELD(isDrop);
1623 	COMPARE_NODE_FIELD(items);
1624 
1625 	return true;
1626 }
1627 
1628 static bool
_equalCreatedbStmt(const CreatedbStmt * a,const CreatedbStmt * b)1629 _equalCreatedbStmt(const CreatedbStmt *a, const CreatedbStmt *b)
1630 {
1631 	COMPARE_STRING_FIELD(dbname);
1632 	COMPARE_NODE_FIELD(options);
1633 
1634 	return true;
1635 }
1636 
1637 static bool
_equalAlterDatabaseStmt(const AlterDatabaseStmt * a,const AlterDatabaseStmt * b)1638 _equalAlterDatabaseStmt(const AlterDatabaseStmt *a, const AlterDatabaseStmt *b)
1639 {
1640 	COMPARE_STRING_FIELD(dbname);
1641 	COMPARE_NODE_FIELD(options);
1642 
1643 	return true;
1644 }
1645 
1646 static bool
_equalAlterDatabaseSetStmt(const AlterDatabaseSetStmt * a,const AlterDatabaseSetStmt * b)1647 _equalAlterDatabaseSetStmt(const AlterDatabaseSetStmt *a, const AlterDatabaseSetStmt *b)
1648 {
1649 	COMPARE_STRING_FIELD(dbname);
1650 	COMPARE_NODE_FIELD(setstmt);
1651 
1652 	return true;
1653 }
1654 
1655 static bool
_equalDropdbStmt(const DropdbStmt * a,const DropdbStmt * b)1656 _equalDropdbStmt(const DropdbStmt *a, const DropdbStmt *b)
1657 {
1658 	COMPARE_STRING_FIELD(dbname);
1659 	COMPARE_SCALAR_FIELD(missing_ok);
1660 
1661 	return true;
1662 }
1663 
1664 static bool
_equalVacuumStmt(const VacuumStmt * a,const VacuumStmt * b)1665 _equalVacuumStmt(const VacuumStmt *a, const VacuumStmt *b)
1666 {
1667 	COMPARE_SCALAR_FIELD(options);
1668 	COMPARE_NODE_FIELD(relation);
1669 	COMPARE_NODE_FIELD(va_cols);
1670 
1671 	return true;
1672 }
1673 
1674 static bool
_equalExplainStmt(const ExplainStmt * a,const ExplainStmt * b)1675 _equalExplainStmt(const ExplainStmt *a, const ExplainStmt *b)
1676 {
1677 	COMPARE_NODE_FIELD(query);
1678 	COMPARE_NODE_FIELD(options);
1679 
1680 	return true;
1681 }
1682 
1683 static bool
_equalCreateTableAsStmt(const CreateTableAsStmt * a,const CreateTableAsStmt * b)1684 _equalCreateTableAsStmt(const CreateTableAsStmt *a, const CreateTableAsStmt *b)
1685 {
1686 	COMPARE_NODE_FIELD(query);
1687 	COMPARE_NODE_FIELD(into);
1688 	COMPARE_SCALAR_FIELD(relkind);
1689 	COMPARE_SCALAR_FIELD(is_select_into);
1690 	COMPARE_SCALAR_FIELD(if_not_exists);
1691 
1692 	return true;
1693 }
1694 
1695 static bool
_equalRefreshMatViewStmt(const RefreshMatViewStmt * a,const RefreshMatViewStmt * b)1696 _equalRefreshMatViewStmt(const RefreshMatViewStmt *a, const RefreshMatViewStmt *b)
1697 {
1698 	COMPARE_SCALAR_FIELD(concurrent);
1699 	COMPARE_SCALAR_FIELD(skipData);
1700 	COMPARE_NODE_FIELD(relation);
1701 
1702 	return true;
1703 }
1704 
1705 static bool
_equalReplicaIdentityStmt(const ReplicaIdentityStmt * a,const ReplicaIdentityStmt * b)1706 _equalReplicaIdentityStmt(const ReplicaIdentityStmt *a, const ReplicaIdentityStmt *b)
1707 {
1708 	COMPARE_SCALAR_FIELD(identity_type);
1709 	COMPARE_STRING_FIELD(name);
1710 
1711 	return true;
1712 }
1713 
1714 static bool
_equalAlterSystemStmt(const AlterSystemStmt * a,const AlterSystemStmt * b)1715 _equalAlterSystemStmt(const AlterSystemStmt *a, const AlterSystemStmt *b)
1716 {
1717 	COMPARE_NODE_FIELD(setstmt);
1718 
1719 	return true;
1720 }
1721 
1722 
1723 static bool
_equalCreateSeqStmt(const CreateSeqStmt * a,const CreateSeqStmt * b)1724 _equalCreateSeqStmt(const CreateSeqStmt *a, const CreateSeqStmt *b)
1725 {
1726 	COMPARE_NODE_FIELD(sequence);
1727 	COMPARE_NODE_FIELD(options);
1728 	COMPARE_SCALAR_FIELD(ownerId);
1729 	COMPARE_SCALAR_FIELD(for_identity);
1730 	COMPARE_SCALAR_FIELD(if_not_exists);
1731 
1732 	return true;
1733 }
1734 
1735 static bool
_equalAlterSeqStmt(const AlterSeqStmt * a,const AlterSeqStmt * b)1736 _equalAlterSeqStmt(const AlterSeqStmt *a, const AlterSeqStmt *b)
1737 {
1738 	COMPARE_NODE_FIELD(sequence);
1739 	COMPARE_NODE_FIELD(options);
1740 	COMPARE_SCALAR_FIELD(for_identity);
1741 	COMPARE_SCALAR_FIELD(missing_ok);
1742 
1743 	return true;
1744 }
1745 
1746 static bool
_equalVariableSetStmt(const VariableSetStmt * a,const VariableSetStmt * b)1747 _equalVariableSetStmt(const VariableSetStmt *a, const VariableSetStmt *b)
1748 {
1749 	COMPARE_SCALAR_FIELD(kind);
1750 	COMPARE_STRING_FIELD(name);
1751 	COMPARE_NODE_FIELD(args);
1752 	COMPARE_SCALAR_FIELD(is_local);
1753 
1754 	return true;
1755 }
1756 
1757 static bool
_equalVariableShowStmt(const VariableShowStmt * a,const VariableShowStmt * b)1758 _equalVariableShowStmt(const VariableShowStmt *a, const VariableShowStmt *b)
1759 {
1760 	COMPARE_STRING_FIELD(name);
1761 
1762 	return true;
1763 }
1764 
1765 static bool
_equalDiscardStmt(const DiscardStmt * a,const DiscardStmt * b)1766 _equalDiscardStmt(const DiscardStmt *a, const DiscardStmt *b)
1767 {
1768 	COMPARE_SCALAR_FIELD(target);
1769 
1770 	return true;
1771 }
1772 
1773 static bool
_equalCreateTableSpaceStmt(const CreateTableSpaceStmt * a,const CreateTableSpaceStmt * b)1774 _equalCreateTableSpaceStmt(const CreateTableSpaceStmt *a, const CreateTableSpaceStmt *b)
1775 {
1776 	COMPARE_STRING_FIELD(tablespacename);
1777 	COMPARE_NODE_FIELD(owner);
1778 	COMPARE_STRING_FIELD(location);
1779 	COMPARE_NODE_FIELD(options);
1780 
1781 	return true;
1782 }
1783 
1784 static bool
_equalDropTableSpaceStmt(const DropTableSpaceStmt * a,const DropTableSpaceStmt * b)1785 _equalDropTableSpaceStmt(const DropTableSpaceStmt *a, const DropTableSpaceStmt *b)
1786 {
1787 	COMPARE_STRING_FIELD(tablespacename);
1788 	COMPARE_SCALAR_FIELD(missing_ok);
1789 
1790 	return true;
1791 }
1792 
1793 static bool
_equalAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt * a,const AlterTableSpaceOptionsStmt * b)1794 _equalAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *a,
1795 								 const AlterTableSpaceOptionsStmt *b)
1796 {
1797 	COMPARE_STRING_FIELD(tablespacename);
1798 	COMPARE_NODE_FIELD(options);
1799 	COMPARE_SCALAR_FIELD(isReset);
1800 
1801 	return true;
1802 }
1803 
1804 static bool
_equalAlterTableMoveAllStmt(const AlterTableMoveAllStmt * a,const AlterTableMoveAllStmt * b)1805 _equalAlterTableMoveAllStmt(const AlterTableMoveAllStmt *a,
1806 							const AlterTableMoveAllStmt *b)
1807 {
1808 	COMPARE_STRING_FIELD(orig_tablespacename);
1809 	COMPARE_SCALAR_FIELD(objtype);
1810 	COMPARE_NODE_FIELD(roles);
1811 	COMPARE_STRING_FIELD(new_tablespacename);
1812 	COMPARE_SCALAR_FIELD(nowait);
1813 
1814 	return true;
1815 }
1816 
1817 static bool
_equalCreateExtensionStmt(const CreateExtensionStmt * a,const CreateExtensionStmt * b)1818 _equalCreateExtensionStmt(const CreateExtensionStmt *a, const CreateExtensionStmt *b)
1819 {
1820 	COMPARE_STRING_FIELD(extname);
1821 	COMPARE_SCALAR_FIELD(if_not_exists);
1822 	COMPARE_NODE_FIELD(options);
1823 
1824 	return true;
1825 }
1826 
1827 static bool
_equalAlterExtensionStmt(const AlterExtensionStmt * a,const AlterExtensionStmt * b)1828 _equalAlterExtensionStmt(const AlterExtensionStmt *a, const AlterExtensionStmt *b)
1829 {
1830 	COMPARE_STRING_FIELD(extname);
1831 	COMPARE_NODE_FIELD(options);
1832 
1833 	return true;
1834 }
1835 
1836 static bool
_equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt * a,const AlterExtensionContentsStmt * b)1837 _equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const AlterExtensionContentsStmt *b)
1838 {
1839 	COMPARE_STRING_FIELD(extname);
1840 	COMPARE_SCALAR_FIELD(action);
1841 	COMPARE_SCALAR_FIELD(objtype);
1842 	COMPARE_NODE_FIELD(object);
1843 
1844 	return true;
1845 }
1846 
1847 static bool
_equalCreateFdwStmt(const CreateFdwStmt * a,const CreateFdwStmt * b)1848 _equalCreateFdwStmt(const CreateFdwStmt *a, const CreateFdwStmt *b)
1849 {
1850 	COMPARE_STRING_FIELD(fdwname);
1851 	COMPARE_NODE_FIELD(func_options);
1852 	COMPARE_NODE_FIELD(options);
1853 
1854 	return true;
1855 }
1856 
1857 static bool
_equalAlterFdwStmt(const AlterFdwStmt * a,const AlterFdwStmt * b)1858 _equalAlterFdwStmt(const AlterFdwStmt *a, const AlterFdwStmt *b)
1859 {
1860 	COMPARE_STRING_FIELD(fdwname);
1861 	COMPARE_NODE_FIELD(func_options);
1862 	COMPARE_NODE_FIELD(options);
1863 
1864 	return true;
1865 }
1866 
1867 static bool
_equalCreateForeignServerStmt(const CreateForeignServerStmt * a,const CreateForeignServerStmt * b)1868 _equalCreateForeignServerStmt(const CreateForeignServerStmt *a, const CreateForeignServerStmt *b)
1869 {
1870 	COMPARE_STRING_FIELD(servername);
1871 	COMPARE_STRING_FIELD(servertype);
1872 	COMPARE_STRING_FIELD(version);
1873 	COMPARE_STRING_FIELD(fdwname);
1874 	COMPARE_SCALAR_FIELD(if_not_exists);
1875 	COMPARE_NODE_FIELD(options);
1876 
1877 	return true;
1878 }
1879 
1880 static bool
_equalAlterForeignServerStmt(const AlterForeignServerStmt * a,const AlterForeignServerStmt * b)1881 _equalAlterForeignServerStmt(const AlterForeignServerStmt *a, const AlterForeignServerStmt *b)
1882 {
1883 	COMPARE_STRING_FIELD(servername);
1884 	COMPARE_STRING_FIELD(version);
1885 	COMPARE_NODE_FIELD(options);
1886 	COMPARE_SCALAR_FIELD(has_version);
1887 
1888 	return true;
1889 }
1890 
1891 static bool
_equalCreateUserMappingStmt(const CreateUserMappingStmt * a,const CreateUserMappingStmt * b)1892 _equalCreateUserMappingStmt(const CreateUserMappingStmt *a, const CreateUserMappingStmt *b)
1893 {
1894 	COMPARE_NODE_FIELD(user);
1895 	COMPARE_STRING_FIELD(servername);
1896 	COMPARE_SCALAR_FIELD(if_not_exists);
1897 	COMPARE_NODE_FIELD(options);
1898 
1899 	return true;
1900 }
1901 
1902 static bool
_equalAlterUserMappingStmt(const AlterUserMappingStmt * a,const AlterUserMappingStmt * b)1903 _equalAlterUserMappingStmt(const AlterUserMappingStmt *a, const AlterUserMappingStmt *b)
1904 {
1905 	COMPARE_NODE_FIELD(user);
1906 	COMPARE_STRING_FIELD(servername);
1907 	COMPARE_NODE_FIELD(options);
1908 
1909 	return true;
1910 }
1911 
1912 static bool
_equalDropUserMappingStmt(const DropUserMappingStmt * a,const DropUserMappingStmt * b)1913 _equalDropUserMappingStmt(const DropUserMappingStmt *a, const DropUserMappingStmt *b)
1914 {
1915 	COMPARE_NODE_FIELD(user);
1916 	COMPARE_STRING_FIELD(servername);
1917 	COMPARE_SCALAR_FIELD(missing_ok);
1918 
1919 	return true;
1920 }
1921 
1922 static bool
_equalCreateForeignTableStmt(const CreateForeignTableStmt * a,const CreateForeignTableStmt * b)1923 _equalCreateForeignTableStmt(const CreateForeignTableStmt *a, const CreateForeignTableStmt *b)
1924 {
1925 	if (!_equalCreateStmt(&a->base, &b->base))
1926 		return false;
1927 
1928 	COMPARE_STRING_FIELD(servername);
1929 	COMPARE_NODE_FIELD(options);
1930 
1931 	return true;
1932 }
1933 
1934 static bool
_equalImportForeignSchemaStmt(const ImportForeignSchemaStmt * a,const ImportForeignSchemaStmt * b)1935 _equalImportForeignSchemaStmt(const ImportForeignSchemaStmt *a, const ImportForeignSchemaStmt *b)
1936 {
1937 	COMPARE_STRING_FIELD(server_name);
1938 	COMPARE_STRING_FIELD(remote_schema);
1939 	COMPARE_STRING_FIELD(local_schema);
1940 	COMPARE_SCALAR_FIELD(list_type);
1941 	COMPARE_NODE_FIELD(table_list);
1942 	COMPARE_NODE_FIELD(options);
1943 
1944 	return true;
1945 }
1946 
1947 static bool
_equalCreateTransformStmt(const CreateTransformStmt * a,const CreateTransformStmt * b)1948 _equalCreateTransformStmt(const CreateTransformStmt *a, const CreateTransformStmt *b)
1949 {
1950 	COMPARE_SCALAR_FIELD(replace);
1951 	COMPARE_NODE_FIELD(type_name);
1952 	COMPARE_STRING_FIELD(lang);
1953 	COMPARE_NODE_FIELD(fromsql);
1954 	COMPARE_NODE_FIELD(tosql);
1955 
1956 	return true;
1957 }
1958 
1959 static bool
_equalCreateAmStmt(const CreateAmStmt * a,const CreateAmStmt * b)1960 _equalCreateAmStmt(const CreateAmStmt *a, const CreateAmStmt *b)
1961 {
1962 	COMPARE_STRING_FIELD(amname);
1963 	COMPARE_NODE_FIELD(handler_name);
1964 	COMPARE_SCALAR_FIELD(amtype);
1965 
1966 	return true;
1967 }
1968 
1969 static bool
_equalCreateTrigStmt(const CreateTrigStmt * a,const CreateTrigStmt * b)1970 _equalCreateTrigStmt(const CreateTrigStmt *a, const CreateTrigStmt *b)
1971 {
1972 	COMPARE_STRING_FIELD(trigname);
1973 	COMPARE_NODE_FIELD(relation);
1974 	COMPARE_NODE_FIELD(funcname);
1975 	COMPARE_NODE_FIELD(args);
1976 	COMPARE_SCALAR_FIELD(row);
1977 	COMPARE_SCALAR_FIELD(timing);
1978 	COMPARE_SCALAR_FIELD(events);
1979 	COMPARE_NODE_FIELD(columns);
1980 	COMPARE_NODE_FIELD(whenClause);
1981 	COMPARE_SCALAR_FIELD(isconstraint);
1982 	COMPARE_NODE_FIELD(transitionRels);
1983 	COMPARE_SCALAR_FIELD(deferrable);
1984 	COMPARE_SCALAR_FIELD(initdeferred);
1985 	COMPARE_NODE_FIELD(constrrel);
1986 
1987 	return true;
1988 }
1989 
1990 static bool
_equalCreateEventTrigStmt(const CreateEventTrigStmt * a,const CreateEventTrigStmt * b)1991 _equalCreateEventTrigStmt(const CreateEventTrigStmt *a, const CreateEventTrigStmt *b)
1992 {
1993 	COMPARE_STRING_FIELD(trigname);
1994 	COMPARE_STRING_FIELD(eventname);
1995 	COMPARE_NODE_FIELD(whenclause);
1996 	COMPARE_NODE_FIELD(funcname);
1997 
1998 	return true;
1999 }
2000 
2001 static bool
_equalAlterEventTrigStmt(const AlterEventTrigStmt * a,const AlterEventTrigStmt * b)2002 _equalAlterEventTrigStmt(const AlterEventTrigStmt *a, const AlterEventTrigStmt *b)
2003 {
2004 	COMPARE_STRING_FIELD(trigname);
2005 	COMPARE_SCALAR_FIELD(tgenabled);
2006 
2007 	return true;
2008 }
2009 
2010 static bool
_equalCreatePLangStmt(const CreatePLangStmt * a,const CreatePLangStmt * b)2011 _equalCreatePLangStmt(const CreatePLangStmt *a, const CreatePLangStmt *b)
2012 {
2013 	COMPARE_SCALAR_FIELD(replace);
2014 	COMPARE_STRING_FIELD(plname);
2015 	COMPARE_NODE_FIELD(plhandler);
2016 	COMPARE_NODE_FIELD(plinline);
2017 	COMPARE_NODE_FIELD(plvalidator);
2018 	COMPARE_SCALAR_FIELD(pltrusted);
2019 
2020 	return true;
2021 }
2022 
2023 static bool
_equalCreateRoleStmt(const CreateRoleStmt * a,const CreateRoleStmt * b)2024 _equalCreateRoleStmt(const CreateRoleStmt *a, const CreateRoleStmt *b)
2025 {
2026 	COMPARE_SCALAR_FIELD(stmt_type);
2027 	COMPARE_STRING_FIELD(role);
2028 	COMPARE_NODE_FIELD(options);
2029 
2030 	return true;
2031 }
2032 
2033 static bool
_equalAlterRoleStmt(const AlterRoleStmt * a,const AlterRoleStmt * b)2034 _equalAlterRoleStmt(const AlterRoleStmt *a, const AlterRoleStmt *b)
2035 {
2036 	COMPARE_NODE_FIELD(role);
2037 	COMPARE_NODE_FIELD(options);
2038 	COMPARE_SCALAR_FIELD(action);
2039 
2040 	return true;
2041 }
2042 
2043 static bool
_equalAlterRoleSetStmt(const AlterRoleSetStmt * a,const AlterRoleSetStmt * b)2044 _equalAlterRoleSetStmt(const AlterRoleSetStmt *a, const AlterRoleSetStmt *b)
2045 {
2046 	COMPARE_NODE_FIELD(role);
2047 	COMPARE_STRING_FIELD(database);
2048 	COMPARE_NODE_FIELD(setstmt);
2049 
2050 	return true;
2051 }
2052 
2053 static bool
_equalDropRoleStmt(const DropRoleStmt * a,const DropRoleStmt * b)2054 _equalDropRoleStmt(const DropRoleStmt *a, const DropRoleStmt *b)
2055 {
2056 	COMPARE_NODE_FIELD(roles);
2057 	COMPARE_SCALAR_FIELD(missing_ok);
2058 
2059 	return true;
2060 }
2061 
2062 static bool
_equalLockStmt(const LockStmt * a,const LockStmt * b)2063 _equalLockStmt(const LockStmt *a, const LockStmt *b)
2064 {
2065 	COMPARE_NODE_FIELD(relations);
2066 	COMPARE_SCALAR_FIELD(mode);
2067 	COMPARE_SCALAR_FIELD(nowait);
2068 
2069 	return true;
2070 }
2071 
2072 static bool
_equalConstraintsSetStmt(const ConstraintsSetStmt * a,const ConstraintsSetStmt * b)2073 _equalConstraintsSetStmt(const ConstraintsSetStmt *a, const ConstraintsSetStmt *b)
2074 {
2075 	COMPARE_NODE_FIELD(constraints);
2076 	COMPARE_SCALAR_FIELD(deferred);
2077 
2078 	return true;
2079 }
2080 
2081 static bool
_equalReindexStmt(const ReindexStmt * a,const ReindexStmt * b)2082 _equalReindexStmt(const ReindexStmt *a, const ReindexStmt *b)
2083 {
2084 	COMPARE_SCALAR_FIELD(kind);
2085 	COMPARE_NODE_FIELD(relation);
2086 	COMPARE_STRING_FIELD(name);
2087 	COMPARE_SCALAR_FIELD(options);
2088 
2089 	return true;
2090 }
2091 
2092 static bool
_equalCreateSchemaStmt(const CreateSchemaStmt * a,const CreateSchemaStmt * b)2093 _equalCreateSchemaStmt(const CreateSchemaStmt *a, const CreateSchemaStmt *b)
2094 {
2095 	COMPARE_STRING_FIELD(schemaname);
2096 	COMPARE_NODE_FIELD(authrole);
2097 	COMPARE_NODE_FIELD(schemaElts);
2098 	COMPARE_SCALAR_FIELD(if_not_exists);
2099 
2100 	return true;
2101 }
2102 
2103 static bool
_equalCreateConversionStmt(const CreateConversionStmt * a,const CreateConversionStmt * b)2104 _equalCreateConversionStmt(const CreateConversionStmt *a, const CreateConversionStmt *b)
2105 {
2106 	COMPARE_NODE_FIELD(conversion_name);
2107 	COMPARE_STRING_FIELD(for_encoding_name);
2108 	COMPARE_STRING_FIELD(to_encoding_name);
2109 	COMPARE_NODE_FIELD(func_name);
2110 	COMPARE_SCALAR_FIELD(def);
2111 
2112 	return true;
2113 }
2114 
2115 static bool
_equalCreateCastStmt(const CreateCastStmt * a,const CreateCastStmt * b)2116 _equalCreateCastStmt(const CreateCastStmt *a, const CreateCastStmt *b)
2117 {
2118 	COMPARE_NODE_FIELD(sourcetype);
2119 	COMPARE_NODE_FIELD(targettype);
2120 	COMPARE_NODE_FIELD(func);
2121 	COMPARE_SCALAR_FIELD(context);
2122 	COMPARE_SCALAR_FIELD(inout);
2123 
2124 	return true;
2125 }
2126 
2127 static bool
_equalPrepareStmt(const PrepareStmt * a,const PrepareStmt * b)2128 _equalPrepareStmt(const PrepareStmt *a, const PrepareStmt *b)
2129 {
2130 	COMPARE_STRING_FIELD(name);
2131 	COMPARE_NODE_FIELD(argtypes);
2132 	COMPARE_NODE_FIELD(query);
2133 
2134 	return true;
2135 }
2136 
2137 static bool
_equalExecuteStmt(const ExecuteStmt * a,const ExecuteStmt * b)2138 _equalExecuteStmt(const ExecuteStmt *a, const ExecuteStmt *b)
2139 {
2140 	COMPARE_STRING_FIELD(name);
2141 	COMPARE_NODE_FIELD(params);
2142 
2143 	return true;
2144 }
2145 
2146 static bool
_equalDeallocateStmt(const DeallocateStmt * a,const DeallocateStmt * b)2147 _equalDeallocateStmt(const DeallocateStmt *a, const DeallocateStmt *b)
2148 {
2149 	COMPARE_STRING_FIELD(name);
2150 
2151 	return true;
2152 }
2153 
2154 static bool
_equalDropOwnedStmt(const DropOwnedStmt * a,const DropOwnedStmt * b)2155 _equalDropOwnedStmt(const DropOwnedStmt *a, const DropOwnedStmt *b)
2156 {
2157 	COMPARE_NODE_FIELD(roles);
2158 	COMPARE_SCALAR_FIELD(behavior);
2159 
2160 	return true;
2161 }
2162 
2163 static bool
_equalReassignOwnedStmt(const ReassignOwnedStmt * a,const ReassignOwnedStmt * b)2164 _equalReassignOwnedStmt(const ReassignOwnedStmt *a, const ReassignOwnedStmt *b)
2165 {
2166 	COMPARE_NODE_FIELD(roles);
2167 	COMPARE_NODE_FIELD(newrole);
2168 
2169 	return true;
2170 }
2171 
2172 static bool
_equalAlterTSDictionaryStmt(const AlterTSDictionaryStmt * a,const AlterTSDictionaryStmt * b)2173 _equalAlterTSDictionaryStmt(const AlterTSDictionaryStmt *a, const AlterTSDictionaryStmt *b)
2174 {
2175 	COMPARE_NODE_FIELD(dictname);
2176 	COMPARE_NODE_FIELD(options);
2177 
2178 	return true;
2179 }
2180 
2181 static bool
_equalAlterTSConfigurationStmt(const AlterTSConfigurationStmt * a,const AlterTSConfigurationStmt * b)2182 _equalAlterTSConfigurationStmt(const AlterTSConfigurationStmt *a,
2183 							   const AlterTSConfigurationStmt *b)
2184 {
2185 	COMPARE_SCALAR_FIELD(kind);
2186 	COMPARE_NODE_FIELD(cfgname);
2187 	COMPARE_NODE_FIELD(tokentype);
2188 	COMPARE_NODE_FIELD(dicts);
2189 	COMPARE_SCALAR_FIELD(override);
2190 	COMPARE_SCALAR_FIELD(replace);
2191 	COMPARE_SCALAR_FIELD(missing_ok);
2192 
2193 	return true;
2194 }
2195 
2196 static bool
_equalCreatePublicationStmt(const CreatePublicationStmt * a,const CreatePublicationStmt * b)2197 _equalCreatePublicationStmt(const CreatePublicationStmt *a,
2198 							const CreatePublicationStmt *b)
2199 {
2200 	COMPARE_STRING_FIELD(pubname);
2201 	COMPARE_NODE_FIELD(options);
2202 	COMPARE_NODE_FIELD(tables);
2203 	COMPARE_SCALAR_FIELD(for_all_tables);
2204 
2205 	return true;
2206 }
2207 
2208 static bool
_equalAlterPublicationStmt(const AlterPublicationStmt * a,const AlterPublicationStmt * b)2209 _equalAlterPublicationStmt(const AlterPublicationStmt *a,
2210 						   const AlterPublicationStmt *b)
2211 {
2212 	COMPARE_STRING_FIELD(pubname);
2213 	COMPARE_NODE_FIELD(options);
2214 	COMPARE_NODE_FIELD(tables);
2215 	COMPARE_SCALAR_FIELD(for_all_tables);
2216 	COMPARE_SCALAR_FIELD(tableAction);
2217 
2218 	return true;
2219 }
2220 
2221 static bool
_equalCreateSubscriptionStmt(const CreateSubscriptionStmt * a,const CreateSubscriptionStmt * b)2222 _equalCreateSubscriptionStmt(const CreateSubscriptionStmt *a,
2223 							 const CreateSubscriptionStmt *b)
2224 {
2225 	COMPARE_STRING_FIELD(subname);
2226 	COMPARE_STRING_FIELD(conninfo);
2227 	COMPARE_NODE_FIELD(publication);
2228 	COMPARE_NODE_FIELD(options);
2229 
2230 	return true;
2231 }
2232 
2233 static bool
_equalAlterSubscriptionStmt(const AlterSubscriptionStmt * a,const AlterSubscriptionStmt * b)2234 _equalAlterSubscriptionStmt(const AlterSubscriptionStmt *a,
2235 							const AlterSubscriptionStmt *b)
2236 {
2237 	COMPARE_SCALAR_FIELD(kind);
2238 	COMPARE_STRING_FIELD(subname);
2239 	COMPARE_STRING_FIELD(conninfo);
2240 	COMPARE_NODE_FIELD(publication);
2241 	COMPARE_NODE_FIELD(options);
2242 
2243 	return true;
2244 }
2245 
2246 static bool
_equalDropSubscriptionStmt(const DropSubscriptionStmt * a,const DropSubscriptionStmt * b)2247 _equalDropSubscriptionStmt(const DropSubscriptionStmt *a,
2248 						   const DropSubscriptionStmt *b)
2249 {
2250 	COMPARE_STRING_FIELD(subname);
2251 	COMPARE_SCALAR_FIELD(missing_ok);
2252 	COMPARE_SCALAR_FIELD(behavior);
2253 
2254 	return true;
2255 }
2256 
2257 static bool
_equalCreatePolicyStmt(const CreatePolicyStmt * a,const CreatePolicyStmt * b)2258 _equalCreatePolicyStmt(const CreatePolicyStmt *a, const CreatePolicyStmt *b)
2259 {
2260 	COMPARE_STRING_FIELD(policy_name);
2261 	COMPARE_NODE_FIELD(table);
2262 	COMPARE_STRING_FIELD(cmd_name);
2263 	COMPARE_SCALAR_FIELD(permissive);
2264 	COMPARE_NODE_FIELD(roles);
2265 	COMPARE_NODE_FIELD(qual);
2266 	COMPARE_NODE_FIELD(with_check);
2267 
2268 	return true;
2269 }
2270 
2271 static bool
_equalAlterPolicyStmt(const AlterPolicyStmt * a,const AlterPolicyStmt * b)2272 _equalAlterPolicyStmt(const AlterPolicyStmt *a, const AlterPolicyStmt *b)
2273 {
2274 	COMPARE_STRING_FIELD(policy_name);
2275 	COMPARE_NODE_FIELD(table);
2276 	COMPARE_NODE_FIELD(roles);
2277 	COMPARE_NODE_FIELD(qual);
2278 	COMPARE_NODE_FIELD(with_check);
2279 
2280 	return true;
2281 }
2282 
2283 static bool
_equalAExpr(const A_Expr * a,const A_Expr * b)2284 _equalAExpr(const A_Expr *a, const A_Expr *b)
2285 {
2286 	COMPARE_SCALAR_FIELD(kind);
2287 	COMPARE_NODE_FIELD(name);
2288 	COMPARE_NODE_FIELD(lexpr);
2289 	COMPARE_NODE_FIELD(rexpr);
2290 	COMPARE_LOCATION_FIELD(location);
2291 
2292 	return true;
2293 }
2294 
2295 static bool
_equalColumnRef(const ColumnRef * a,const ColumnRef * b)2296 _equalColumnRef(const ColumnRef *a, const ColumnRef *b)
2297 {
2298 	COMPARE_NODE_FIELD(fields);
2299 	COMPARE_LOCATION_FIELD(location);
2300 
2301 	return true;
2302 }
2303 
2304 static bool
_equalParamRef(const ParamRef * a,const ParamRef * b)2305 _equalParamRef(const ParamRef *a, const ParamRef *b)
2306 {
2307 	COMPARE_SCALAR_FIELD(number);
2308 	COMPARE_LOCATION_FIELD(location);
2309 
2310 	return true;
2311 }
2312 
2313 static bool
_equalAConst(const A_Const * a,const A_Const * b)2314 _equalAConst(const A_Const *a, const A_Const *b)
2315 {
2316 	if (!equal(&a->val, &b->val))	/* hack for in-line Value field */
2317 		return false;
2318 	COMPARE_LOCATION_FIELD(location);
2319 
2320 	return true;
2321 }
2322 
2323 static bool
_equalFuncCall(const FuncCall * a,const FuncCall * b)2324 _equalFuncCall(const FuncCall *a, const FuncCall *b)
2325 {
2326 	COMPARE_NODE_FIELD(funcname);
2327 	COMPARE_NODE_FIELD(args);
2328 	COMPARE_NODE_FIELD(agg_order);
2329 	COMPARE_NODE_FIELD(agg_filter);
2330 	COMPARE_SCALAR_FIELD(agg_within_group);
2331 	COMPARE_SCALAR_FIELD(agg_star);
2332 	COMPARE_SCALAR_FIELD(agg_distinct);
2333 	COMPARE_SCALAR_FIELD(func_variadic);
2334 	COMPARE_NODE_FIELD(over);
2335 	COMPARE_LOCATION_FIELD(location);
2336 
2337 	return true;
2338 }
2339 
2340 static bool
_equalAStar(const A_Star * a,const A_Star * b)2341 _equalAStar(const A_Star *a, const A_Star *b)
2342 {
2343 	return true;
2344 }
2345 
2346 static bool
_equalAIndices(const A_Indices * a,const A_Indices * b)2347 _equalAIndices(const A_Indices *a, const A_Indices *b)
2348 {
2349 	COMPARE_SCALAR_FIELD(is_slice);
2350 	COMPARE_NODE_FIELD(lidx);
2351 	COMPARE_NODE_FIELD(uidx);
2352 
2353 	return true;
2354 }
2355 
2356 static bool
_equalA_Indirection(const A_Indirection * a,const A_Indirection * b)2357 _equalA_Indirection(const A_Indirection *a, const A_Indirection *b)
2358 {
2359 	COMPARE_NODE_FIELD(arg);
2360 	COMPARE_NODE_FIELD(indirection);
2361 
2362 	return true;
2363 }
2364 
2365 static bool
_equalA_ArrayExpr(const A_ArrayExpr * a,const A_ArrayExpr * b)2366 _equalA_ArrayExpr(const A_ArrayExpr *a, const A_ArrayExpr *b)
2367 {
2368 	COMPARE_NODE_FIELD(elements);
2369 	COMPARE_LOCATION_FIELD(location);
2370 
2371 	return true;
2372 }
2373 
2374 static bool
_equalResTarget(const ResTarget * a,const ResTarget * b)2375 _equalResTarget(const ResTarget *a, const ResTarget *b)
2376 {
2377 	COMPARE_STRING_FIELD(name);
2378 	COMPARE_NODE_FIELD(indirection);
2379 	COMPARE_NODE_FIELD(val);
2380 	COMPARE_LOCATION_FIELD(location);
2381 
2382 	return true;
2383 }
2384 
2385 static bool
_equalMultiAssignRef(const MultiAssignRef * a,const MultiAssignRef * b)2386 _equalMultiAssignRef(const MultiAssignRef *a, const MultiAssignRef *b)
2387 {
2388 	COMPARE_NODE_FIELD(source);
2389 	COMPARE_SCALAR_FIELD(colno);
2390 	COMPARE_SCALAR_FIELD(ncolumns);
2391 
2392 	return true;
2393 }
2394 
2395 static bool
_equalTypeName(const TypeName * a,const TypeName * b)2396 _equalTypeName(const TypeName *a, const TypeName *b)
2397 {
2398 	COMPARE_NODE_FIELD(names);
2399 	COMPARE_SCALAR_FIELD(typeOid);
2400 	COMPARE_SCALAR_FIELD(setof);
2401 	COMPARE_SCALAR_FIELD(pct_type);
2402 	COMPARE_NODE_FIELD(typmods);
2403 	COMPARE_SCALAR_FIELD(typemod);
2404 	COMPARE_NODE_FIELD(arrayBounds);
2405 	COMPARE_LOCATION_FIELD(location);
2406 
2407 	return true;
2408 }
2409 
2410 static bool
_equalTypeCast(const TypeCast * a,const TypeCast * b)2411 _equalTypeCast(const TypeCast *a, const TypeCast *b)
2412 {
2413 	COMPARE_NODE_FIELD(arg);
2414 	COMPARE_NODE_FIELD(typeName);
2415 	COMPARE_LOCATION_FIELD(location);
2416 
2417 	return true;
2418 }
2419 
2420 static bool
_equalCollateClause(const CollateClause * a,const CollateClause * b)2421 _equalCollateClause(const CollateClause *a, const CollateClause *b)
2422 {
2423 	COMPARE_NODE_FIELD(arg);
2424 	COMPARE_NODE_FIELD(collname);
2425 	COMPARE_LOCATION_FIELD(location);
2426 
2427 	return true;
2428 }
2429 
2430 static bool
_equalSortBy(const SortBy * a,const SortBy * b)2431 _equalSortBy(const SortBy *a, const SortBy *b)
2432 {
2433 	COMPARE_NODE_FIELD(node);
2434 	COMPARE_SCALAR_FIELD(sortby_dir);
2435 	COMPARE_SCALAR_FIELD(sortby_nulls);
2436 	COMPARE_NODE_FIELD(useOp);
2437 	COMPARE_LOCATION_FIELD(location);
2438 
2439 	return true;
2440 }
2441 
2442 static bool
_equalWindowDef(const WindowDef * a,const WindowDef * b)2443 _equalWindowDef(const WindowDef *a, const WindowDef *b)
2444 {
2445 	COMPARE_STRING_FIELD(name);
2446 	COMPARE_STRING_FIELD(refname);
2447 	COMPARE_NODE_FIELD(partitionClause);
2448 	COMPARE_NODE_FIELD(orderClause);
2449 	COMPARE_SCALAR_FIELD(frameOptions);
2450 	COMPARE_NODE_FIELD(startOffset);
2451 	COMPARE_NODE_FIELD(endOffset);
2452 	COMPARE_LOCATION_FIELD(location);
2453 
2454 	return true;
2455 }
2456 
2457 static bool
_equalRangeSubselect(const RangeSubselect * a,const RangeSubselect * b)2458 _equalRangeSubselect(const RangeSubselect *a, const RangeSubselect *b)
2459 {
2460 	COMPARE_SCALAR_FIELD(lateral);
2461 	COMPARE_NODE_FIELD(subquery);
2462 	COMPARE_NODE_FIELD(alias);
2463 
2464 	return true;
2465 }
2466 
2467 static bool
_equalRangeFunction(const RangeFunction * a,const RangeFunction * b)2468 _equalRangeFunction(const RangeFunction *a, const RangeFunction *b)
2469 {
2470 	COMPARE_SCALAR_FIELD(lateral);
2471 	COMPARE_SCALAR_FIELD(ordinality);
2472 	COMPARE_SCALAR_FIELD(is_rowsfrom);
2473 	COMPARE_NODE_FIELD(functions);
2474 	COMPARE_NODE_FIELD(alias);
2475 	COMPARE_NODE_FIELD(coldeflist);
2476 
2477 	return true;
2478 }
2479 
2480 static bool
_equalRangeTableSample(const RangeTableSample * a,const RangeTableSample * b)2481 _equalRangeTableSample(const RangeTableSample *a, const RangeTableSample *b)
2482 {
2483 	COMPARE_NODE_FIELD(relation);
2484 	COMPARE_NODE_FIELD(method);
2485 	COMPARE_NODE_FIELD(args);
2486 	COMPARE_NODE_FIELD(repeatable);
2487 	COMPARE_LOCATION_FIELD(location);
2488 
2489 	return true;
2490 }
2491 
2492 static bool
_equalRangeTableFunc(const RangeTableFunc * a,const RangeTableFunc * b)2493 _equalRangeTableFunc(const RangeTableFunc *a, const RangeTableFunc *b)
2494 {
2495 	COMPARE_SCALAR_FIELD(lateral);
2496 	COMPARE_NODE_FIELD(docexpr);
2497 	COMPARE_NODE_FIELD(rowexpr);
2498 	COMPARE_NODE_FIELD(namespaces);
2499 	COMPARE_NODE_FIELD(columns);
2500 	COMPARE_NODE_FIELD(alias);
2501 	COMPARE_LOCATION_FIELD(location);
2502 
2503 	return true;
2504 }
2505 
2506 static bool
_equalRangeTableFuncCol(const RangeTableFuncCol * a,const RangeTableFuncCol * b)2507 _equalRangeTableFuncCol(const RangeTableFuncCol *a, const RangeTableFuncCol *b)
2508 {
2509 	COMPARE_STRING_FIELD(colname);
2510 	COMPARE_NODE_FIELD(typeName);
2511 	COMPARE_SCALAR_FIELD(for_ordinality);
2512 	COMPARE_SCALAR_FIELD(is_not_null);
2513 	COMPARE_NODE_FIELD(colexpr);
2514 	COMPARE_NODE_FIELD(coldefexpr);
2515 	COMPARE_LOCATION_FIELD(location);
2516 
2517 	return true;
2518 }
2519 
2520 
2521 static bool
_equalIndexElem(const IndexElem * a,const IndexElem * b)2522 _equalIndexElem(const IndexElem *a, const IndexElem *b)
2523 {
2524 	COMPARE_STRING_FIELD(name);
2525 	COMPARE_NODE_FIELD(expr);
2526 	COMPARE_STRING_FIELD(indexcolname);
2527 	COMPARE_NODE_FIELD(collation);
2528 	COMPARE_NODE_FIELD(opclass);
2529 	COMPARE_SCALAR_FIELD(ordering);
2530 	COMPARE_SCALAR_FIELD(nulls_ordering);
2531 
2532 	return true;
2533 }
2534 
2535 static bool
_equalColumnDef(const ColumnDef * a,const ColumnDef * b)2536 _equalColumnDef(const ColumnDef *a, const ColumnDef *b)
2537 {
2538 	COMPARE_STRING_FIELD(colname);
2539 	COMPARE_NODE_FIELD(typeName);
2540 	COMPARE_SCALAR_FIELD(inhcount);
2541 	COMPARE_SCALAR_FIELD(is_local);
2542 	COMPARE_SCALAR_FIELD(is_not_null);
2543 	COMPARE_SCALAR_FIELD(is_from_type);
2544 	COMPARE_SCALAR_FIELD(storage);
2545 	COMPARE_NODE_FIELD(raw_default);
2546 	COMPARE_NODE_FIELD(cooked_default);
2547 	COMPARE_SCALAR_FIELD(identity);
2548 	COMPARE_NODE_FIELD(identitySequence);
2549 	COMPARE_NODE_FIELD(collClause);
2550 	COMPARE_SCALAR_FIELD(collOid);
2551 	COMPARE_NODE_FIELD(constraints);
2552 	COMPARE_NODE_FIELD(fdwoptions);
2553 	COMPARE_LOCATION_FIELD(location);
2554 
2555 	return true;
2556 }
2557 
2558 static bool
_equalConstraint(const Constraint * a,const Constraint * b)2559 _equalConstraint(const Constraint *a, const Constraint *b)
2560 {
2561 	COMPARE_SCALAR_FIELD(contype);
2562 	COMPARE_STRING_FIELD(conname);
2563 	COMPARE_SCALAR_FIELD(deferrable);
2564 	COMPARE_SCALAR_FIELD(initdeferred);
2565 	COMPARE_LOCATION_FIELD(location);
2566 	COMPARE_SCALAR_FIELD(is_no_inherit);
2567 	COMPARE_NODE_FIELD(raw_expr);
2568 	COMPARE_STRING_FIELD(cooked_expr);
2569 	COMPARE_SCALAR_FIELD(generated_when);
2570 	COMPARE_NODE_FIELD(keys);
2571 	COMPARE_NODE_FIELD(exclusions);
2572 	COMPARE_NODE_FIELD(options);
2573 	COMPARE_STRING_FIELD(indexname);
2574 	COMPARE_STRING_FIELD(indexspace);
2575 	COMPARE_STRING_FIELD(access_method);
2576 	COMPARE_NODE_FIELD(where_clause);
2577 	COMPARE_NODE_FIELD(pktable);
2578 	COMPARE_NODE_FIELD(fk_attrs);
2579 	COMPARE_NODE_FIELD(pk_attrs);
2580 	COMPARE_SCALAR_FIELD(fk_matchtype);
2581 	COMPARE_SCALAR_FIELD(fk_upd_action);
2582 	COMPARE_SCALAR_FIELD(fk_del_action);
2583 	COMPARE_NODE_FIELD(old_conpfeqop);
2584 	COMPARE_SCALAR_FIELD(old_pktable_oid);
2585 	COMPARE_SCALAR_FIELD(skip_validation);
2586 	COMPARE_SCALAR_FIELD(initially_valid);
2587 
2588 	return true;
2589 }
2590 
2591 static bool
_equalDefElem(const DefElem * a,const DefElem * b)2592 _equalDefElem(const DefElem *a, const DefElem *b)
2593 {
2594 	COMPARE_STRING_FIELD(defnamespace);
2595 	COMPARE_STRING_FIELD(defname);
2596 	COMPARE_NODE_FIELD(arg);
2597 	COMPARE_SCALAR_FIELD(defaction);
2598 	COMPARE_LOCATION_FIELD(location);
2599 
2600 	return true;
2601 }
2602 
2603 static bool
_equalLockingClause(const LockingClause * a,const LockingClause * b)2604 _equalLockingClause(const LockingClause *a, const LockingClause *b)
2605 {
2606 	COMPARE_NODE_FIELD(lockedRels);
2607 	COMPARE_SCALAR_FIELD(strength);
2608 	COMPARE_SCALAR_FIELD(waitPolicy);
2609 
2610 	return true;
2611 }
2612 
2613 static bool
_equalRangeTblEntry(const RangeTblEntry * a,const RangeTblEntry * b)2614 _equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b)
2615 {
2616 	COMPARE_SCALAR_FIELD(rtekind);
2617 	COMPARE_SCALAR_FIELD(relid);
2618 	COMPARE_SCALAR_FIELD(relkind);
2619 	COMPARE_NODE_FIELD(tablesample);
2620 	COMPARE_NODE_FIELD(subquery);
2621 	COMPARE_SCALAR_FIELD(security_barrier);
2622 	COMPARE_SCALAR_FIELD(jointype);
2623 	COMPARE_NODE_FIELD(joinaliasvars);
2624 	COMPARE_NODE_FIELD(functions);
2625 	COMPARE_SCALAR_FIELD(funcordinality);
2626 	COMPARE_NODE_FIELD(tablefunc);
2627 	COMPARE_NODE_FIELD(values_lists);
2628 	COMPARE_STRING_FIELD(ctename);
2629 	COMPARE_SCALAR_FIELD(ctelevelsup);
2630 	COMPARE_SCALAR_FIELD(self_reference);
2631 	COMPARE_NODE_FIELD(coltypes);
2632 	COMPARE_NODE_FIELD(coltypmods);
2633 	COMPARE_NODE_FIELD(colcollations);
2634 	COMPARE_STRING_FIELD(enrname);
2635 	COMPARE_SCALAR_FIELD(enrtuples);
2636 	COMPARE_NODE_FIELD(alias);
2637 	COMPARE_NODE_FIELD(eref);
2638 	COMPARE_SCALAR_FIELD(lateral);
2639 	COMPARE_SCALAR_FIELD(inh);
2640 	COMPARE_SCALAR_FIELD(inFromCl);
2641 	COMPARE_SCALAR_FIELD(requiredPerms);
2642 	COMPARE_SCALAR_FIELD(checkAsUser);
2643 	COMPARE_BITMAPSET_FIELD(selectedCols);
2644 	COMPARE_BITMAPSET_FIELD(insertedCols);
2645 	COMPARE_BITMAPSET_FIELD(updatedCols);
2646 	COMPARE_NODE_FIELD(securityQuals);
2647 
2648 	return true;
2649 }
2650 
2651 static bool
_equalRangeTblFunction(const RangeTblFunction * a,const RangeTblFunction * b)2652 _equalRangeTblFunction(const RangeTblFunction *a, const RangeTblFunction *b)
2653 {
2654 	COMPARE_NODE_FIELD(funcexpr);
2655 	COMPARE_SCALAR_FIELD(funccolcount);
2656 	COMPARE_NODE_FIELD(funccolnames);
2657 	COMPARE_NODE_FIELD(funccoltypes);
2658 	COMPARE_NODE_FIELD(funccoltypmods);
2659 	COMPARE_NODE_FIELD(funccolcollations);
2660 	COMPARE_BITMAPSET_FIELD(funcparams);
2661 
2662 	return true;
2663 }
2664 
2665 static bool
_equalTableSampleClause(const TableSampleClause * a,const TableSampleClause * b)2666 _equalTableSampleClause(const TableSampleClause *a, const TableSampleClause *b)
2667 {
2668 	COMPARE_SCALAR_FIELD(tsmhandler);
2669 	COMPARE_NODE_FIELD(args);
2670 	COMPARE_NODE_FIELD(repeatable);
2671 
2672 	return true;
2673 }
2674 
2675 static bool
_equalWithCheckOption(const WithCheckOption * a,const WithCheckOption * b)2676 _equalWithCheckOption(const WithCheckOption *a, const WithCheckOption *b)
2677 {
2678 	COMPARE_SCALAR_FIELD(kind);
2679 	COMPARE_STRING_FIELD(relname);
2680 	COMPARE_STRING_FIELD(polname);
2681 	COMPARE_NODE_FIELD(qual);
2682 	COMPARE_SCALAR_FIELD(cascaded);
2683 
2684 	return true;
2685 }
2686 
2687 static bool
_equalSortGroupClause(const SortGroupClause * a,const SortGroupClause * b)2688 _equalSortGroupClause(const SortGroupClause *a, const SortGroupClause *b)
2689 {
2690 	COMPARE_SCALAR_FIELD(tleSortGroupRef);
2691 	COMPARE_SCALAR_FIELD(eqop);
2692 	COMPARE_SCALAR_FIELD(sortop);
2693 	COMPARE_SCALAR_FIELD(nulls_first);
2694 	COMPARE_SCALAR_FIELD(hashable);
2695 
2696 	return true;
2697 }
2698 
2699 static bool
_equalGroupingSet(const GroupingSet * a,const GroupingSet * b)2700 _equalGroupingSet(const GroupingSet *a, const GroupingSet *b)
2701 {
2702 	COMPARE_SCALAR_FIELD(kind);
2703 	COMPARE_NODE_FIELD(content);
2704 	COMPARE_LOCATION_FIELD(location);
2705 
2706 	return true;
2707 }
2708 
2709 static bool
_equalWindowClause(const WindowClause * a,const WindowClause * b)2710 _equalWindowClause(const WindowClause *a, const WindowClause *b)
2711 {
2712 	COMPARE_STRING_FIELD(name);
2713 	COMPARE_STRING_FIELD(refname);
2714 	COMPARE_NODE_FIELD(partitionClause);
2715 	COMPARE_NODE_FIELD(orderClause);
2716 	COMPARE_SCALAR_FIELD(frameOptions);
2717 	COMPARE_NODE_FIELD(startOffset);
2718 	COMPARE_NODE_FIELD(endOffset);
2719 	COMPARE_SCALAR_FIELD(winref);
2720 	COMPARE_SCALAR_FIELD(copiedOrder);
2721 
2722 	return true;
2723 }
2724 
2725 static bool
_equalRowMarkClause(const RowMarkClause * a,const RowMarkClause * b)2726 _equalRowMarkClause(const RowMarkClause *a, const RowMarkClause *b)
2727 {
2728 	COMPARE_SCALAR_FIELD(rti);
2729 	COMPARE_SCALAR_FIELD(strength);
2730 	COMPARE_SCALAR_FIELD(waitPolicy);
2731 	COMPARE_SCALAR_FIELD(pushedDown);
2732 
2733 	return true;
2734 }
2735 
2736 static bool
_equalWithClause(const WithClause * a,const WithClause * b)2737 _equalWithClause(const WithClause *a, const WithClause *b)
2738 {
2739 	COMPARE_NODE_FIELD(ctes);
2740 	COMPARE_SCALAR_FIELD(recursive);
2741 	COMPARE_LOCATION_FIELD(location);
2742 
2743 	return true;
2744 }
2745 
2746 static bool
_equalInferClause(const InferClause * a,const InferClause * b)2747 _equalInferClause(const InferClause *a, const InferClause *b)
2748 {
2749 	COMPARE_NODE_FIELD(indexElems);
2750 	COMPARE_NODE_FIELD(whereClause);
2751 	COMPARE_STRING_FIELD(conname);
2752 	COMPARE_LOCATION_FIELD(location);
2753 
2754 	return true;
2755 }
2756 
2757 static bool
_equalOnConflictClause(const OnConflictClause * a,const OnConflictClause * b)2758 _equalOnConflictClause(const OnConflictClause *a, const OnConflictClause *b)
2759 {
2760 	COMPARE_SCALAR_FIELD(action);
2761 	COMPARE_NODE_FIELD(infer);
2762 	COMPARE_NODE_FIELD(targetList);
2763 	COMPARE_NODE_FIELD(whereClause);
2764 	COMPARE_LOCATION_FIELD(location);
2765 
2766 	return true;
2767 }
2768 
2769 static bool
_equalCommonTableExpr(const CommonTableExpr * a,const CommonTableExpr * b)2770 _equalCommonTableExpr(const CommonTableExpr *a, const CommonTableExpr *b)
2771 {
2772 	COMPARE_STRING_FIELD(ctename);
2773 	COMPARE_NODE_FIELD(aliascolnames);
2774 	COMPARE_NODE_FIELD(ctequery);
2775 	COMPARE_LOCATION_FIELD(location);
2776 	COMPARE_SCALAR_FIELD(cterecursive);
2777 	COMPARE_SCALAR_FIELD(cterefcount);
2778 	COMPARE_NODE_FIELD(ctecolnames);
2779 	COMPARE_NODE_FIELD(ctecoltypes);
2780 	COMPARE_NODE_FIELD(ctecoltypmods);
2781 	COMPARE_NODE_FIELD(ctecolcollations);
2782 
2783 	return true;
2784 }
2785 
2786 static bool
_equalXmlSerialize(const XmlSerialize * a,const XmlSerialize * b)2787 _equalXmlSerialize(const XmlSerialize *a, const XmlSerialize *b)
2788 {
2789 	COMPARE_SCALAR_FIELD(xmloption);
2790 	COMPARE_NODE_FIELD(expr);
2791 	COMPARE_NODE_FIELD(typeName);
2792 	COMPARE_LOCATION_FIELD(location);
2793 
2794 	return true;
2795 }
2796 
2797 static bool
_equalRoleSpec(const RoleSpec * a,const RoleSpec * b)2798 _equalRoleSpec(const RoleSpec *a, const RoleSpec *b)
2799 {
2800 	COMPARE_SCALAR_FIELD(roletype);
2801 	COMPARE_STRING_FIELD(rolename);
2802 	COMPARE_LOCATION_FIELD(location);
2803 
2804 	return true;
2805 }
2806 
2807 static bool
_equalTriggerTransition(const TriggerTransition * a,const TriggerTransition * b)2808 _equalTriggerTransition(const TriggerTransition *a, const TriggerTransition *b)
2809 {
2810 	COMPARE_STRING_FIELD(name);
2811 	COMPARE_SCALAR_FIELD(isNew);
2812 	COMPARE_SCALAR_FIELD(isTable);
2813 
2814 	return true;
2815 }
2816 
2817 static bool
_equalPartitionElem(const PartitionElem * a,const PartitionElem * b)2818 _equalPartitionElem(const PartitionElem *a, const PartitionElem *b)
2819 {
2820 	COMPARE_STRING_FIELD(name);
2821 	COMPARE_NODE_FIELD(expr);
2822 	COMPARE_NODE_FIELD(collation);
2823 	COMPARE_NODE_FIELD(opclass);
2824 	COMPARE_LOCATION_FIELD(location);
2825 
2826 	return true;
2827 }
2828 
2829 static bool
_equalPartitionSpec(const PartitionSpec * a,const PartitionSpec * b)2830 _equalPartitionSpec(const PartitionSpec *a, const PartitionSpec *b)
2831 {
2832 	COMPARE_STRING_FIELD(strategy);
2833 	COMPARE_NODE_FIELD(partParams);
2834 	COMPARE_LOCATION_FIELD(location);
2835 
2836 	return true;
2837 }
2838 
2839 static bool
_equalPartitionBoundSpec(const PartitionBoundSpec * a,const PartitionBoundSpec * b)2840 _equalPartitionBoundSpec(const PartitionBoundSpec *a, const PartitionBoundSpec *b)
2841 {
2842 	COMPARE_SCALAR_FIELD(strategy);
2843 	COMPARE_NODE_FIELD(listdatums);
2844 	COMPARE_NODE_FIELD(lowerdatums);
2845 	COMPARE_NODE_FIELD(upperdatums);
2846 	COMPARE_LOCATION_FIELD(location);
2847 
2848 	return true;
2849 }
2850 
2851 static bool
_equalPartitionRangeDatum(const PartitionRangeDatum * a,const PartitionRangeDatum * b)2852 _equalPartitionRangeDatum(const PartitionRangeDatum *a, const PartitionRangeDatum *b)
2853 {
2854 	COMPARE_SCALAR_FIELD(kind);
2855 	COMPARE_NODE_FIELD(value);
2856 	COMPARE_LOCATION_FIELD(location);
2857 
2858 	return true;
2859 }
2860 
2861 static bool
_equalPartitionCmd(const PartitionCmd * a,const PartitionCmd * b)2862 _equalPartitionCmd(const PartitionCmd *a, const PartitionCmd *b)
2863 {
2864 	COMPARE_NODE_FIELD(name);
2865 	COMPARE_NODE_FIELD(bound);
2866 
2867 	return true;
2868 }
2869 
2870 /*
2871  * Stuff from pg_list.h
2872  */
2873 
2874 static bool
_equalList(const List * a,const List * b)2875 _equalList(const List *a, const List *b)
2876 {
2877 	const ListCell *item_a;
2878 	const ListCell *item_b;
2879 
2880 	/*
2881 	 * Try to reject by simple scalar checks before grovelling through all the
2882 	 * list elements...
2883 	 */
2884 	COMPARE_SCALAR_FIELD(type);
2885 	COMPARE_SCALAR_FIELD(length);
2886 
2887 	/*
2888 	 * We place the switch outside the loop for the sake of efficiency; this
2889 	 * may not be worth doing...
2890 	 */
2891 	switch (a->type)
2892 	{
2893 		case T_List:
2894 			forboth(item_a, a, item_b, b)
2895 			{
2896 				if (!equal(lfirst(item_a), lfirst(item_b)))
2897 					return false;
2898 			}
2899 			break;
2900 		case T_IntList:
2901 			forboth(item_a, a, item_b, b)
2902 			{
2903 				if (lfirst_int(item_a) != lfirst_int(item_b))
2904 					return false;
2905 			}
2906 			break;
2907 		case T_OidList:
2908 			forboth(item_a, a, item_b, b)
2909 			{
2910 				if (lfirst_oid(item_a) != lfirst_oid(item_b))
2911 					return false;
2912 			}
2913 			break;
2914 		default:
2915 			elog(ERROR, "unrecognized list node type: %d",
2916 				 (int) a->type);
2917 			return false;		/* keep compiler quiet */
2918 	}
2919 
2920 	/*
2921 	 * If we got here, we should have run out of elements of both lists
2922 	 */
2923 	Assert(item_a == NULL);
2924 	Assert(item_b == NULL);
2925 
2926 	return true;
2927 }
2928 
2929 /*
2930  * Stuff from value.h
2931  */
2932 
2933 static bool
_equalValue(const Value * a,const Value * b)2934 _equalValue(const Value *a, const Value *b)
2935 {
2936 	COMPARE_SCALAR_FIELD(type);
2937 
2938 	switch (a->type)
2939 	{
2940 		case T_Integer:
2941 			COMPARE_SCALAR_FIELD(val.ival);
2942 			break;
2943 		case T_Float:
2944 		case T_String:
2945 		case T_BitString:
2946 			COMPARE_STRING_FIELD(val.str);
2947 			break;
2948 		case T_Null:
2949 			/* nothing to do */
2950 			break;
2951 		default:
2952 			elog(ERROR, "unrecognized node type: %d", (int) a->type);
2953 			break;
2954 	}
2955 
2956 	return true;
2957 }
2958 
2959 /*
2960  * equal
2961  *	  returns whether two nodes are equal
2962  */
2963 bool
equal(const void * a,const void * b)2964 equal(const void *a, const void *b)
2965 {
2966 	bool		retval;
2967 
2968 	if (a == b)
2969 		return true;
2970 
2971 	/*
2972 	 * note that a!=b, so only one of them can be NULL
2973 	 */
2974 	if (a == NULL || b == NULL)
2975 		return false;
2976 
2977 	/*
2978 	 * are they the same type of nodes?
2979 	 */
2980 	if (nodeTag(a) != nodeTag(b))
2981 		return false;
2982 
2983 	/* Guard against stack overflow due to overly complex expressions */
2984 	check_stack_depth();
2985 
2986 	switch (nodeTag(a))
2987 	{
2988 			/*
2989 			 * PRIMITIVE NODES
2990 			 */
2991 		case T_Alias:
2992 			retval = _equalAlias(a, b);
2993 			break;
2994 		case T_RangeVar:
2995 			retval = _equalRangeVar(a, b);
2996 			break;
2997 		case T_TableFunc:
2998 			retval = _equalTableFunc(a, b);
2999 			break;
3000 		case T_IntoClause:
3001 			retval = _equalIntoClause(a, b);
3002 			break;
3003 		case T_Var:
3004 			retval = _equalVar(a, b);
3005 			break;
3006 		case T_Const:
3007 			retval = _equalConst(a, b);
3008 			break;
3009 		case T_Param:
3010 			retval = _equalParam(a, b);
3011 			break;
3012 		case T_Aggref:
3013 			retval = _equalAggref(a, b);
3014 			break;
3015 		case T_GroupingFunc:
3016 			retval = _equalGroupingFunc(a, b);
3017 			break;
3018 		case T_WindowFunc:
3019 			retval = _equalWindowFunc(a, b);
3020 			break;
3021 		case T_ArrayRef:
3022 			retval = _equalArrayRef(a, b);
3023 			break;
3024 		case T_FuncExpr:
3025 			retval = _equalFuncExpr(a, b);
3026 			break;
3027 		case T_NamedArgExpr:
3028 			retval = _equalNamedArgExpr(a, b);
3029 			break;
3030 		case T_OpExpr:
3031 			retval = _equalOpExpr(a, b);
3032 			break;
3033 		case T_DistinctExpr:
3034 			retval = _equalDistinctExpr(a, b);
3035 			break;
3036 		case T_NullIfExpr:
3037 			retval = _equalNullIfExpr(a, b);
3038 			break;
3039 		case T_ScalarArrayOpExpr:
3040 			retval = _equalScalarArrayOpExpr(a, b);
3041 			break;
3042 		case T_BoolExpr:
3043 			retval = _equalBoolExpr(a, b);
3044 			break;
3045 		case T_SubLink:
3046 			retval = _equalSubLink(a, b);
3047 			break;
3048 		case T_SubPlan:
3049 			retval = _equalSubPlan(a, b);
3050 			break;
3051 		case T_AlternativeSubPlan:
3052 			retval = _equalAlternativeSubPlan(a, b);
3053 			break;
3054 		case T_FieldSelect:
3055 			retval = _equalFieldSelect(a, b);
3056 			break;
3057 		case T_FieldStore:
3058 			retval = _equalFieldStore(a, b);
3059 			break;
3060 		case T_RelabelType:
3061 			retval = _equalRelabelType(a, b);
3062 			break;
3063 		case T_CoerceViaIO:
3064 			retval = _equalCoerceViaIO(a, b);
3065 			break;
3066 		case T_ArrayCoerceExpr:
3067 			retval = _equalArrayCoerceExpr(a, b);
3068 			break;
3069 		case T_ConvertRowtypeExpr:
3070 			retval = _equalConvertRowtypeExpr(a, b);
3071 			break;
3072 		case T_CollateExpr:
3073 			retval = _equalCollateExpr(a, b);
3074 			break;
3075 		case T_CaseExpr:
3076 			retval = _equalCaseExpr(a, b);
3077 			break;
3078 		case T_CaseWhen:
3079 			retval = _equalCaseWhen(a, b);
3080 			break;
3081 		case T_CaseTestExpr:
3082 			retval = _equalCaseTestExpr(a, b);
3083 			break;
3084 		case T_ArrayExpr:
3085 			retval = _equalArrayExpr(a, b);
3086 			break;
3087 		case T_RowExpr:
3088 			retval = _equalRowExpr(a, b);
3089 			break;
3090 		case T_RowCompareExpr:
3091 			retval = _equalRowCompareExpr(a, b);
3092 			break;
3093 		case T_CoalesceExpr:
3094 			retval = _equalCoalesceExpr(a, b);
3095 			break;
3096 		case T_MinMaxExpr:
3097 			retval = _equalMinMaxExpr(a, b);
3098 			break;
3099 		case T_SQLValueFunction:
3100 			retval = _equalSQLValueFunction(a, b);
3101 			break;
3102 		case T_XmlExpr:
3103 			retval = _equalXmlExpr(a, b);
3104 			break;
3105 		case T_NullTest:
3106 			retval = _equalNullTest(a, b);
3107 			break;
3108 		case T_BooleanTest:
3109 			retval = _equalBooleanTest(a, b);
3110 			break;
3111 		case T_CoerceToDomain:
3112 			retval = _equalCoerceToDomain(a, b);
3113 			break;
3114 		case T_CoerceToDomainValue:
3115 			retval = _equalCoerceToDomainValue(a, b);
3116 			break;
3117 		case T_SetToDefault:
3118 			retval = _equalSetToDefault(a, b);
3119 			break;
3120 		case T_CurrentOfExpr:
3121 			retval = _equalCurrentOfExpr(a, b);
3122 			break;
3123 		case T_NextValueExpr:
3124 			retval = _equalNextValueExpr(a, b);
3125 			break;
3126 		case T_InferenceElem:
3127 			retval = _equalInferenceElem(a, b);
3128 			break;
3129 		case T_TargetEntry:
3130 			retval = _equalTargetEntry(a, b);
3131 			break;
3132 		case T_RangeTblRef:
3133 			retval = _equalRangeTblRef(a, b);
3134 			break;
3135 		case T_FromExpr:
3136 			retval = _equalFromExpr(a, b);
3137 			break;
3138 		case T_OnConflictExpr:
3139 			retval = _equalOnConflictExpr(a, b);
3140 			break;
3141 		case T_JoinExpr:
3142 			retval = _equalJoinExpr(a, b);
3143 			break;
3144 
3145 			/*
3146 			 * RELATION NODES
3147 			 */
3148 		case T_PathKey:
3149 			retval = _equalPathKey(a, b);
3150 			break;
3151 		case T_RestrictInfo:
3152 			retval = _equalRestrictInfo(a, b);
3153 			break;
3154 		case T_PlaceHolderVar:
3155 			retval = _equalPlaceHolderVar(a, b);
3156 			break;
3157 		case T_SpecialJoinInfo:
3158 			retval = _equalSpecialJoinInfo(a, b);
3159 			break;
3160 		case T_AppendRelInfo:
3161 			retval = _equalAppendRelInfo(a, b);
3162 			break;
3163 		case T_PartitionedChildRelInfo:
3164 			retval = _equalPartitionedChildRelInfo(a, b);
3165 			break;
3166 		case T_PlaceHolderInfo:
3167 			retval = _equalPlaceHolderInfo(a, b);
3168 			break;
3169 
3170 		case T_List:
3171 		case T_IntList:
3172 		case T_OidList:
3173 			retval = _equalList(a, b);
3174 			break;
3175 
3176 		case T_Integer:
3177 		case T_Float:
3178 		case T_String:
3179 		case T_BitString:
3180 		case T_Null:
3181 			retval = _equalValue(a, b);
3182 			break;
3183 
3184 			/*
3185 			 * EXTENSIBLE NODES
3186 			 */
3187 		case T_ExtensibleNode:
3188 			retval = _equalExtensibleNode(a, b);
3189 			break;
3190 
3191 			/*
3192 			 * PARSE NODES
3193 			 */
3194 		case T_Query:
3195 			retval = _equalQuery(a, b);
3196 			break;
3197 		case T_RawStmt:
3198 			retval = _equalRawStmt(a, b);
3199 			break;
3200 		case T_InsertStmt:
3201 			retval = _equalInsertStmt(a, b);
3202 			break;
3203 		case T_DeleteStmt:
3204 			retval = _equalDeleteStmt(a, b);
3205 			break;
3206 		case T_UpdateStmt:
3207 			retval = _equalUpdateStmt(a, b);
3208 			break;
3209 		case T_SelectStmt:
3210 			retval = _equalSelectStmt(a, b);
3211 			break;
3212 		case T_SetOperationStmt:
3213 			retval = _equalSetOperationStmt(a, b);
3214 			break;
3215 		case T_AlterTableStmt:
3216 			retval = _equalAlterTableStmt(a, b);
3217 			break;
3218 		case T_AlterTableCmd:
3219 			retval = _equalAlterTableCmd(a, b);
3220 			break;
3221 		case T_AlterCollationStmt:
3222 			retval = _equalAlterCollationStmt(a, b);
3223 			break;
3224 		case T_AlterDomainStmt:
3225 			retval = _equalAlterDomainStmt(a, b);
3226 			break;
3227 		case T_GrantStmt:
3228 			retval = _equalGrantStmt(a, b);
3229 			break;
3230 		case T_GrantRoleStmt:
3231 			retval = _equalGrantRoleStmt(a, b);
3232 			break;
3233 		case T_AlterDefaultPrivilegesStmt:
3234 			retval = _equalAlterDefaultPrivilegesStmt(a, b);
3235 			break;
3236 		case T_DeclareCursorStmt:
3237 			retval = _equalDeclareCursorStmt(a, b);
3238 			break;
3239 		case T_ClosePortalStmt:
3240 			retval = _equalClosePortalStmt(a, b);
3241 			break;
3242 		case T_ClusterStmt:
3243 			retval = _equalClusterStmt(a, b);
3244 			break;
3245 		case T_CopyStmt:
3246 			retval = _equalCopyStmt(a, b);
3247 			break;
3248 		case T_CreateStmt:
3249 			retval = _equalCreateStmt(a, b);
3250 			break;
3251 		case T_TableLikeClause:
3252 			retval = _equalTableLikeClause(a, b);
3253 			break;
3254 		case T_DefineStmt:
3255 			retval = _equalDefineStmt(a, b);
3256 			break;
3257 		case T_DropStmt:
3258 			retval = _equalDropStmt(a, b);
3259 			break;
3260 		case T_TruncateStmt:
3261 			retval = _equalTruncateStmt(a, b);
3262 			break;
3263 		case T_CommentStmt:
3264 			retval = _equalCommentStmt(a, b);
3265 			break;
3266 		case T_SecLabelStmt:
3267 			retval = _equalSecLabelStmt(a, b);
3268 			break;
3269 		case T_FetchStmt:
3270 			retval = _equalFetchStmt(a, b);
3271 			break;
3272 		case T_IndexStmt:
3273 			retval = _equalIndexStmt(a, b);
3274 			break;
3275 		case T_CreateStatsStmt:
3276 			retval = _equalCreateStatsStmt(a, b);
3277 			break;
3278 		case T_CreateFunctionStmt:
3279 			retval = _equalCreateFunctionStmt(a, b);
3280 			break;
3281 		case T_FunctionParameter:
3282 			retval = _equalFunctionParameter(a, b);
3283 			break;
3284 		case T_AlterFunctionStmt:
3285 			retval = _equalAlterFunctionStmt(a, b);
3286 			break;
3287 		case T_DoStmt:
3288 			retval = _equalDoStmt(a, b);
3289 			break;
3290 		case T_RenameStmt:
3291 			retval = _equalRenameStmt(a, b);
3292 			break;
3293 		case T_AlterObjectDependsStmt:
3294 			retval = _equalAlterObjectDependsStmt(a, b);
3295 			break;
3296 		case T_AlterObjectSchemaStmt:
3297 			retval = _equalAlterObjectSchemaStmt(a, b);
3298 			break;
3299 		case T_AlterOwnerStmt:
3300 			retval = _equalAlterOwnerStmt(a, b);
3301 			break;
3302 		case T_AlterOperatorStmt:
3303 			retval = _equalAlterOperatorStmt(a, b);
3304 			break;
3305 		case T_RuleStmt:
3306 			retval = _equalRuleStmt(a, b);
3307 			break;
3308 		case T_NotifyStmt:
3309 			retval = _equalNotifyStmt(a, b);
3310 			break;
3311 		case T_ListenStmt:
3312 			retval = _equalListenStmt(a, b);
3313 			break;
3314 		case T_UnlistenStmt:
3315 			retval = _equalUnlistenStmt(a, b);
3316 			break;
3317 		case T_TransactionStmt:
3318 			retval = _equalTransactionStmt(a, b);
3319 			break;
3320 		case T_CompositeTypeStmt:
3321 			retval = _equalCompositeTypeStmt(a, b);
3322 			break;
3323 		case T_CreateEnumStmt:
3324 			retval = _equalCreateEnumStmt(a, b);
3325 			break;
3326 		case T_CreateRangeStmt:
3327 			retval = _equalCreateRangeStmt(a, b);
3328 			break;
3329 		case T_AlterEnumStmt:
3330 			retval = _equalAlterEnumStmt(a, b);
3331 			break;
3332 		case T_ViewStmt:
3333 			retval = _equalViewStmt(a, b);
3334 			break;
3335 		case T_LoadStmt:
3336 			retval = _equalLoadStmt(a, b);
3337 			break;
3338 		case T_CreateDomainStmt:
3339 			retval = _equalCreateDomainStmt(a, b);
3340 			break;
3341 		case T_CreateOpClassStmt:
3342 			retval = _equalCreateOpClassStmt(a, b);
3343 			break;
3344 		case T_CreateOpClassItem:
3345 			retval = _equalCreateOpClassItem(a, b);
3346 			break;
3347 		case T_CreateOpFamilyStmt:
3348 			retval = _equalCreateOpFamilyStmt(a, b);
3349 			break;
3350 		case T_AlterOpFamilyStmt:
3351 			retval = _equalAlterOpFamilyStmt(a, b);
3352 			break;
3353 		case T_CreatedbStmt:
3354 			retval = _equalCreatedbStmt(a, b);
3355 			break;
3356 		case T_AlterDatabaseStmt:
3357 			retval = _equalAlterDatabaseStmt(a, b);
3358 			break;
3359 		case T_AlterDatabaseSetStmt:
3360 			retval = _equalAlterDatabaseSetStmt(a, b);
3361 			break;
3362 		case T_DropdbStmt:
3363 			retval = _equalDropdbStmt(a, b);
3364 			break;
3365 		case T_VacuumStmt:
3366 			retval = _equalVacuumStmt(a, b);
3367 			break;
3368 		case T_ExplainStmt:
3369 			retval = _equalExplainStmt(a, b);
3370 			break;
3371 		case T_CreateTableAsStmt:
3372 			retval = _equalCreateTableAsStmt(a, b);
3373 			break;
3374 		case T_RefreshMatViewStmt:
3375 			retval = _equalRefreshMatViewStmt(a, b);
3376 			break;
3377 		case T_ReplicaIdentityStmt:
3378 			retval = _equalReplicaIdentityStmt(a, b);
3379 			break;
3380 		case T_AlterSystemStmt:
3381 			retval = _equalAlterSystemStmt(a, b);
3382 			break;
3383 		case T_CreateSeqStmt:
3384 			retval = _equalCreateSeqStmt(a, b);
3385 			break;
3386 		case T_AlterSeqStmt:
3387 			retval = _equalAlterSeqStmt(a, b);
3388 			break;
3389 		case T_VariableSetStmt:
3390 			retval = _equalVariableSetStmt(a, b);
3391 			break;
3392 		case T_VariableShowStmt:
3393 			retval = _equalVariableShowStmt(a, b);
3394 			break;
3395 		case T_DiscardStmt:
3396 			retval = _equalDiscardStmt(a, b);
3397 			break;
3398 		case T_CreateTableSpaceStmt:
3399 			retval = _equalCreateTableSpaceStmt(a, b);
3400 			break;
3401 		case T_DropTableSpaceStmt:
3402 			retval = _equalDropTableSpaceStmt(a, b);
3403 			break;
3404 		case T_AlterTableSpaceOptionsStmt:
3405 			retval = _equalAlterTableSpaceOptionsStmt(a, b);
3406 			break;
3407 		case T_AlterTableMoveAllStmt:
3408 			retval = _equalAlterTableMoveAllStmt(a, b);
3409 			break;
3410 		case T_CreateExtensionStmt:
3411 			retval = _equalCreateExtensionStmt(a, b);
3412 			break;
3413 		case T_AlterExtensionStmt:
3414 			retval = _equalAlterExtensionStmt(a, b);
3415 			break;
3416 		case T_AlterExtensionContentsStmt:
3417 			retval = _equalAlterExtensionContentsStmt(a, b);
3418 			break;
3419 		case T_CreateFdwStmt:
3420 			retval = _equalCreateFdwStmt(a, b);
3421 			break;
3422 		case T_AlterFdwStmt:
3423 			retval = _equalAlterFdwStmt(a, b);
3424 			break;
3425 		case T_CreateForeignServerStmt:
3426 			retval = _equalCreateForeignServerStmt(a, b);
3427 			break;
3428 		case T_AlterForeignServerStmt:
3429 			retval = _equalAlterForeignServerStmt(a, b);
3430 			break;
3431 		case T_CreateUserMappingStmt:
3432 			retval = _equalCreateUserMappingStmt(a, b);
3433 			break;
3434 		case T_AlterUserMappingStmt:
3435 			retval = _equalAlterUserMappingStmt(a, b);
3436 			break;
3437 		case T_DropUserMappingStmt:
3438 			retval = _equalDropUserMappingStmt(a, b);
3439 			break;
3440 		case T_CreateForeignTableStmt:
3441 			retval = _equalCreateForeignTableStmt(a, b);
3442 			break;
3443 		case T_ImportForeignSchemaStmt:
3444 			retval = _equalImportForeignSchemaStmt(a, b);
3445 			break;
3446 		case T_CreateTransformStmt:
3447 			retval = _equalCreateTransformStmt(a, b);
3448 			break;
3449 		case T_CreateAmStmt:
3450 			retval = _equalCreateAmStmt(a, b);
3451 			break;
3452 		case T_CreateTrigStmt:
3453 			retval = _equalCreateTrigStmt(a, b);
3454 			break;
3455 		case T_CreateEventTrigStmt:
3456 			retval = _equalCreateEventTrigStmt(a, b);
3457 			break;
3458 		case T_AlterEventTrigStmt:
3459 			retval = _equalAlterEventTrigStmt(a, b);
3460 			break;
3461 		case T_CreatePLangStmt:
3462 			retval = _equalCreatePLangStmt(a, b);
3463 			break;
3464 		case T_CreateRoleStmt:
3465 			retval = _equalCreateRoleStmt(a, b);
3466 			break;
3467 		case T_AlterRoleStmt:
3468 			retval = _equalAlterRoleStmt(a, b);
3469 			break;
3470 		case T_AlterRoleSetStmt:
3471 			retval = _equalAlterRoleSetStmt(a, b);
3472 			break;
3473 		case T_DropRoleStmt:
3474 			retval = _equalDropRoleStmt(a, b);
3475 			break;
3476 		case T_LockStmt:
3477 			retval = _equalLockStmt(a, b);
3478 			break;
3479 		case T_ConstraintsSetStmt:
3480 			retval = _equalConstraintsSetStmt(a, b);
3481 			break;
3482 		case T_ReindexStmt:
3483 			retval = _equalReindexStmt(a, b);
3484 			break;
3485 		case T_CheckPointStmt:
3486 			retval = true;
3487 			break;
3488 		case T_CreateSchemaStmt:
3489 			retval = _equalCreateSchemaStmt(a, b);
3490 			break;
3491 		case T_CreateConversionStmt:
3492 			retval = _equalCreateConversionStmt(a, b);
3493 			break;
3494 		case T_CreateCastStmt:
3495 			retval = _equalCreateCastStmt(a, b);
3496 			break;
3497 		case T_PrepareStmt:
3498 			retval = _equalPrepareStmt(a, b);
3499 			break;
3500 		case T_ExecuteStmt:
3501 			retval = _equalExecuteStmt(a, b);
3502 			break;
3503 		case T_DeallocateStmt:
3504 			retval = _equalDeallocateStmt(a, b);
3505 			break;
3506 		case T_DropOwnedStmt:
3507 			retval = _equalDropOwnedStmt(a, b);
3508 			break;
3509 		case T_ReassignOwnedStmt:
3510 			retval = _equalReassignOwnedStmt(a, b);
3511 			break;
3512 		case T_AlterTSDictionaryStmt:
3513 			retval = _equalAlterTSDictionaryStmt(a, b);
3514 			break;
3515 		case T_AlterTSConfigurationStmt:
3516 			retval = _equalAlterTSConfigurationStmt(a, b);
3517 			break;
3518 		case T_CreatePolicyStmt:
3519 			retval = _equalCreatePolicyStmt(a, b);
3520 			break;
3521 		case T_AlterPolicyStmt:
3522 			retval = _equalAlterPolicyStmt(a, b);
3523 			break;
3524 		case T_CreatePublicationStmt:
3525 			retval = _equalCreatePublicationStmt(a, b);
3526 			break;
3527 		case T_AlterPublicationStmt:
3528 			retval = _equalAlterPublicationStmt(a, b);
3529 			break;
3530 		case T_CreateSubscriptionStmt:
3531 			retval = _equalCreateSubscriptionStmt(a, b);
3532 			break;
3533 		case T_AlterSubscriptionStmt:
3534 			retval = _equalAlterSubscriptionStmt(a, b);
3535 			break;
3536 		case T_DropSubscriptionStmt:
3537 			retval = _equalDropSubscriptionStmt(a, b);
3538 			break;
3539 		case T_A_Expr:
3540 			retval = _equalAExpr(a, b);
3541 			break;
3542 		case T_ColumnRef:
3543 			retval = _equalColumnRef(a, b);
3544 			break;
3545 		case T_ParamRef:
3546 			retval = _equalParamRef(a, b);
3547 			break;
3548 		case T_A_Const:
3549 			retval = _equalAConst(a, b);
3550 			break;
3551 		case T_FuncCall:
3552 			retval = _equalFuncCall(a, b);
3553 			break;
3554 		case T_A_Star:
3555 			retval = _equalAStar(a, b);
3556 			break;
3557 		case T_A_Indices:
3558 			retval = _equalAIndices(a, b);
3559 			break;
3560 		case T_A_Indirection:
3561 			retval = _equalA_Indirection(a, b);
3562 			break;
3563 		case T_A_ArrayExpr:
3564 			retval = _equalA_ArrayExpr(a, b);
3565 			break;
3566 		case T_ResTarget:
3567 			retval = _equalResTarget(a, b);
3568 			break;
3569 		case T_MultiAssignRef:
3570 			retval = _equalMultiAssignRef(a, b);
3571 			break;
3572 		case T_TypeCast:
3573 			retval = _equalTypeCast(a, b);
3574 			break;
3575 		case T_CollateClause:
3576 			retval = _equalCollateClause(a, b);
3577 			break;
3578 		case T_SortBy:
3579 			retval = _equalSortBy(a, b);
3580 			break;
3581 		case T_WindowDef:
3582 			retval = _equalWindowDef(a, b);
3583 			break;
3584 		case T_RangeSubselect:
3585 			retval = _equalRangeSubselect(a, b);
3586 			break;
3587 		case T_RangeFunction:
3588 			retval = _equalRangeFunction(a, b);
3589 			break;
3590 		case T_RangeTableSample:
3591 			retval = _equalRangeTableSample(a, b);
3592 			break;
3593 		case T_RangeTableFunc:
3594 			retval = _equalRangeTableFunc(a, b);
3595 			break;
3596 		case T_RangeTableFuncCol:
3597 			retval = _equalRangeTableFuncCol(a, b);
3598 			break;
3599 		case T_TypeName:
3600 			retval = _equalTypeName(a, b);
3601 			break;
3602 		case T_IndexElem:
3603 			retval = _equalIndexElem(a, b);
3604 			break;
3605 		case T_ColumnDef:
3606 			retval = _equalColumnDef(a, b);
3607 			break;
3608 		case T_Constraint:
3609 			retval = _equalConstraint(a, b);
3610 			break;
3611 		case T_DefElem:
3612 			retval = _equalDefElem(a, b);
3613 			break;
3614 		case T_LockingClause:
3615 			retval = _equalLockingClause(a, b);
3616 			break;
3617 		case T_RangeTblEntry:
3618 			retval = _equalRangeTblEntry(a, b);
3619 			break;
3620 		case T_RangeTblFunction:
3621 			retval = _equalRangeTblFunction(a, b);
3622 			break;
3623 		case T_TableSampleClause:
3624 			retval = _equalTableSampleClause(a, b);
3625 			break;
3626 		case T_WithCheckOption:
3627 			retval = _equalWithCheckOption(a, b);
3628 			break;
3629 		case T_SortGroupClause:
3630 			retval = _equalSortGroupClause(a, b);
3631 			break;
3632 		case T_GroupingSet:
3633 			retval = _equalGroupingSet(a, b);
3634 			break;
3635 		case T_WindowClause:
3636 			retval = _equalWindowClause(a, b);
3637 			break;
3638 		case T_RowMarkClause:
3639 			retval = _equalRowMarkClause(a, b);
3640 			break;
3641 		case T_WithClause:
3642 			retval = _equalWithClause(a, b);
3643 			break;
3644 		case T_InferClause:
3645 			retval = _equalInferClause(a, b);
3646 			break;
3647 		case T_OnConflictClause:
3648 			retval = _equalOnConflictClause(a, b);
3649 			break;
3650 		case T_CommonTableExpr:
3651 			retval = _equalCommonTableExpr(a, b);
3652 			break;
3653 		case T_ObjectWithArgs:
3654 			retval = _equalObjectWithArgs(a, b);
3655 			break;
3656 		case T_AccessPriv:
3657 			retval = _equalAccessPriv(a, b);
3658 			break;
3659 		case T_XmlSerialize:
3660 			retval = _equalXmlSerialize(a, b);
3661 			break;
3662 		case T_RoleSpec:
3663 			retval = _equalRoleSpec(a, b);
3664 			break;
3665 		case T_TriggerTransition:
3666 			retval = _equalTriggerTransition(a, b);
3667 			break;
3668 		case T_PartitionElem:
3669 			retval = _equalPartitionElem(a, b);
3670 			break;
3671 		case T_PartitionSpec:
3672 			retval = _equalPartitionSpec(a, b);
3673 			break;
3674 		case T_PartitionBoundSpec:
3675 			retval = _equalPartitionBoundSpec(a, b);
3676 			break;
3677 		case T_PartitionRangeDatum:
3678 			retval = _equalPartitionRangeDatum(a, b);
3679 			break;
3680 		case T_PartitionCmd:
3681 			retval = _equalPartitionCmd(a, b);
3682 			break;
3683 
3684 		default:
3685 			elog(ERROR, "unrecognized node type: %d",
3686 				 (int) nodeTag(a));
3687 			retval = false;		/* keep compiler quiet */
3688 			break;
3689 	}
3690 
3691 	return retval;
3692 }
3693