]> granicus.if.org Git - postgresql/blob - src/backend/nodes/equalfuncs.c
Remove unnecessary #include references, per pgrminclude script.
[postgresql] / src / backend / nodes / equalfuncs.c
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-2011, 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 "nodes/relation.h"
33 #include "utils/datum.h"
34
35
36 /*
37  * Macros to simplify comparison of different kinds of fields.  Use these
38  * wherever possible to reduce the chance for silly typos.      Note that these
39  * hard-wire the convention that the local variables in an Equal routine are
40  * named 'a' and 'b'.
41  */
42
43 /* Compare a simple scalar field (int, float, bool, enum, etc) */
44 #define COMPARE_SCALAR_FIELD(fldname) \
45         do { \
46                 if (a->fldname != b->fldname) \
47                         return false; \
48         } while (0)
49
50 /* Compare a field that is a pointer to some kind of Node or Node tree */
51 #define COMPARE_NODE_FIELD(fldname) \
52         do { \
53                 if (!equal(a->fldname, b->fldname)) \
54                         return false; \
55         } while (0)
56
57 /* Compare a field that is a pointer to a Bitmapset */
58 #define COMPARE_BITMAPSET_FIELD(fldname) \
59         do { \
60                 if (!bms_equal(a->fldname, b->fldname)) \
61                         return false; \
62         } while (0)
63
64 /* Compare a field that is a pointer to a C string, or perhaps NULL */
65 #define COMPARE_STRING_FIELD(fldname) \
66         do { \
67                 if (!equalstr(a->fldname, b->fldname)) \
68                         return false; \
69         } while (0)
70
71 /* Macro for comparing string fields that might be NULL */
72 #define equalstr(a, b)  \
73         (((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
74
75 /* Compare a field that is a pointer to a simple palloc'd object of size sz */
76 #define COMPARE_POINTER_FIELD(fldname, sz) \
77         do { \
78                 if (memcmp(a->fldname, b->fldname, (sz)) != 0) \
79                         return false; \
80         } while (0)
81
82 /* Compare a parse location field (this is a no-op, per note above) */
83 #define COMPARE_LOCATION_FIELD(fldname) \
84         ((void) 0)
85
86
87 /*
88  *      Stuff from primnodes.h
89  */
90
91 static bool
92 _equalAlias(Alias *a, Alias *b)
93 {
94         COMPARE_STRING_FIELD(aliasname);
95         COMPARE_NODE_FIELD(colnames);
96
97         return true;
98 }
99
100 static bool
101 _equalRangeVar(RangeVar *a, RangeVar *b)
102 {
103         COMPARE_STRING_FIELD(catalogname);
104         COMPARE_STRING_FIELD(schemaname);
105         COMPARE_STRING_FIELD(relname);
106         COMPARE_SCALAR_FIELD(inhOpt);
107         COMPARE_SCALAR_FIELD(relpersistence);
108         COMPARE_NODE_FIELD(alias);
109         COMPARE_LOCATION_FIELD(location);
110
111         return true;
112 }
113
114 static bool
115 _equalIntoClause(IntoClause *a, IntoClause *b)
116 {
117         COMPARE_NODE_FIELD(rel);
118         COMPARE_NODE_FIELD(colNames);
119         COMPARE_NODE_FIELD(options);
120         COMPARE_SCALAR_FIELD(onCommit);
121         COMPARE_STRING_FIELD(tableSpaceName);
122
123         return true;
124 }
125
126 /*
127  * We don't need an _equalExpr because Expr is an abstract supertype which
128  * should never actually get instantiated.      Also, since it has no common
129  * fields except NodeTag, there's no need for a helper routine to factor
130  * out comparing the common fields...
131  */
132
133 static bool
134 _equalVar(Var *a, Var *b)
135 {
136         COMPARE_SCALAR_FIELD(varno);
137         COMPARE_SCALAR_FIELD(varattno);
138         COMPARE_SCALAR_FIELD(vartype);
139         COMPARE_SCALAR_FIELD(vartypmod);
140         COMPARE_SCALAR_FIELD(varcollid);
141         COMPARE_SCALAR_FIELD(varlevelsup);
142         COMPARE_SCALAR_FIELD(varnoold);
143         COMPARE_SCALAR_FIELD(varoattno);
144         COMPARE_LOCATION_FIELD(location);
145
146         return true;
147 }
148
149 static bool
150 _equalConst(Const *a, Const *b)
151 {
152         COMPARE_SCALAR_FIELD(consttype);
153         COMPARE_SCALAR_FIELD(consttypmod);
154         COMPARE_SCALAR_FIELD(constcollid);
155         COMPARE_SCALAR_FIELD(constlen);
156         COMPARE_SCALAR_FIELD(constisnull);
157         COMPARE_SCALAR_FIELD(constbyval);
158         COMPARE_LOCATION_FIELD(location);
159
160         /*
161          * We treat all NULL constants of the same type as equal. Someday this
162          * might need to change?  But datumIsEqual doesn't work on nulls, so...
163          */
164         if (a->constisnull)
165                 return true;
166         return datumIsEqual(a->constvalue, b->constvalue,
167                                                 a->constbyval, a->constlen);
168 }
169
170 static bool
171 _equalParam(Param *a, Param *b)
172 {
173         COMPARE_SCALAR_FIELD(paramkind);
174         COMPARE_SCALAR_FIELD(paramid);
175         COMPARE_SCALAR_FIELD(paramtype);
176         COMPARE_SCALAR_FIELD(paramtypmod);
177         COMPARE_SCALAR_FIELD(paramcollid);
178         COMPARE_LOCATION_FIELD(location);
179
180         return true;
181 }
182
183 static bool
184 _equalAggref(Aggref *a, Aggref *b)
185 {
186         COMPARE_SCALAR_FIELD(aggfnoid);
187         COMPARE_SCALAR_FIELD(aggtype);
188         COMPARE_SCALAR_FIELD(aggcollid);
189         COMPARE_SCALAR_FIELD(inputcollid);
190         COMPARE_NODE_FIELD(args);
191         COMPARE_NODE_FIELD(aggorder);
192         COMPARE_NODE_FIELD(aggdistinct);
193         COMPARE_SCALAR_FIELD(aggstar);
194         COMPARE_SCALAR_FIELD(agglevelsup);
195         COMPARE_LOCATION_FIELD(location);
196
197         return true;
198 }
199
200 static bool
201 _equalWindowFunc(WindowFunc *a, WindowFunc *b)
202 {
203         COMPARE_SCALAR_FIELD(winfnoid);
204         COMPARE_SCALAR_FIELD(wintype);
205         COMPARE_SCALAR_FIELD(wincollid);
206         COMPARE_SCALAR_FIELD(inputcollid);
207         COMPARE_NODE_FIELD(args);
208         COMPARE_SCALAR_FIELD(winref);
209         COMPARE_SCALAR_FIELD(winstar);
210         COMPARE_SCALAR_FIELD(winagg);
211         COMPARE_LOCATION_FIELD(location);
212
213         return true;
214 }
215
216 static bool
217 _equalArrayRef(ArrayRef *a, ArrayRef *b)
218 {
219         COMPARE_SCALAR_FIELD(refarraytype);
220         COMPARE_SCALAR_FIELD(refelemtype);
221         COMPARE_SCALAR_FIELD(reftypmod);
222         COMPARE_SCALAR_FIELD(refcollid);
223         COMPARE_NODE_FIELD(refupperindexpr);
224         COMPARE_NODE_FIELD(reflowerindexpr);
225         COMPARE_NODE_FIELD(refexpr);
226         COMPARE_NODE_FIELD(refassgnexpr);
227
228         return true;
229 }
230
231 static bool
232 _equalFuncExpr(FuncExpr *a, FuncExpr *b)
233 {
234         COMPARE_SCALAR_FIELD(funcid);
235         COMPARE_SCALAR_FIELD(funcresulttype);
236         COMPARE_SCALAR_FIELD(funcretset);
237
238         /*
239          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
240          * that are equal() to both explicit and implicit coercions.
241          */
242         if (a->funcformat != b->funcformat &&
243                 a->funcformat != COERCE_DONTCARE &&
244                 b->funcformat != COERCE_DONTCARE)
245                 return false;
246
247         COMPARE_SCALAR_FIELD(funccollid);
248         COMPARE_SCALAR_FIELD(inputcollid);
249         COMPARE_NODE_FIELD(args);
250         COMPARE_LOCATION_FIELD(location);
251
252         return true;
253 }
254
255 static bool
256 _equalNamedArgExpr(NamedArgExpr *a, NamedArgExpr *b)
257 {
258         COMPARE_NODE_FIELD(arg);
259         COMPARE_STRING_FIELD(name);
260         COMPARE_SCALAR_FIELD(argnumber);
261         COMPARE_LOCATION_FIELD(location);
262
263         return true;
264 }
265
266 static bool
267 _equalOpExpr(OpExpr *a, OpExpr *b)
268 {
269         COMPARE_SCALAR_FIELD(opno);
270
271         /*
272          * Special-case opfuncid: it is allowable for it to differ if one node
273          * contains zero and the other doesn't.  This just means that the one node
274          * isn't as far along in the parse/plan pipeline and hasn't had the
275          * opfuncid cache filled yet.
276          */
277         if (a->opfuncid != b->opfuncid &&
278                 a->opfuncid != 0 &&
279                 b->opfuncid != 0)
280                 return false;
281
282         COMPARE_SCALAR_FIELD(opresulttype);
283         COMPARE_SCALAR_FIELD(opretset);
284         COMPARE_SCALAR_FIELD(opcollid);
285         COMPARE_SCALAR_FIELD(inputcollid);
286         COMPARE_NODE_FIELD(args);
287         COMPARE_LOCATION_FIELD(location);
288
289         return true;
290 }
291
292 static bool
293 _equalDistinctExpr(DistinctExpr *a, DistinctExpr *b)
294 {
295         COMPARE_SCALAR_FIELD(opno);
296
297         /*
298          * Special-case opfuncid: it is allowable for it to differ if one node
299          * contains zero and the other doesn't.  This just means that the one node
300          * isn't as far along in the parse/plan pipeline and hasn't had the
301          * opfuncid cache filled yet.
302          */
303         if (a->opfuncid != b->opfuncid &&
304                 a->opfuncid != 0 &&
305                 b->opfuncid != 0)
306                 return false;
307
308         COMPARE_SCALAR_FIELD(opresulttype);
309         COMPARE_SCALAR_FIELD(opretset);
310         COMPARE_SCALAR_FIELD(opcollid);
311         COMPARE_SCALAR_FIELD(inputcollid);
312         COMPARE_NODE_FIELD(args);
313         COMPARE_LOCATION_FIELD(location);
314
315         return true;
316 }
317
318 static bool
319 _equalNullIfExpr(NullIfExpr *a, NullIfExpr *b)
320 {
321         COMPARE_SCALAR_FIELD(opno);
322
323         /*
324          * Special-case opfuncid: it is allowable for it to differ if one node
325          * contains zero and the other doesn't.  This just means that the one node
326          * isn't as far along in the parse/plan pipeline and hasn't had the
327          * opfuncid cache filled yet.
328          */
329         if (a->opfuncid != b->opfuncid &&
330                 a->opfuncid != 0 &&
331                 b->opfuncid != 0)
332                 return false;
333
334         COMPARE_SCALAR_FIELD(opresulttype);
335         COMPARE_SCALAR_FIELD(opretset);
336         COMPARE_SCALAR_FIELD(opcollid);
337         COMPARE_SCALAR_FIELD(inputcollid);
338         COMPARE_NODE_FIELD(args);
339         COMPARE_LOCATION_FIELD(location);
340
341         return true;
342 }
343
344 static bool
345 _equalScalarArrayOpExpr(ScalarArrayOpExpr *a, ScalarArrayOpExpr *b)
346 {
347         COMPARE_SCALAR_FIELD(opno);
348
349         /*
350          * Special-case opfuncid: it is allowable for it to differ if one node
351          * contains zero and the other doesn't.  This just means that the one node
352          * isn't as far along in the parse/plan pipeline and hasn't had the
353          * opfuncid cache filled yet.
354          */
355         if (a->opfuncid != b->opfuncid &&
356                 a->opfuncid != 0 &&
357                 b->opfuncid != 0)
358                 return false;
359
360         COMPARE_SCALAR_FIELD(useOr);
361         COMPARE_SCALAR_FIELD(inputcollid);
362         COMPARE_NODE_FIELD(args);
363         COMPARE_LOCATION_FIELD(location);
364
365         return true;
366 }
367
368 static bool
369 _equalBoolExpr(BoolExpr *a, BoolExpr *b)
370 {
371         COMPARE_SCALAR_FIELD(boolop);
372         COMPARE_NODE_FIELD(args);
373         COMPARE_LOCATION_FIELD(location);
374
375         return true;
376 }
377
378 static bool
379 _equalSubLink(SubLink *a, SubLink *b)
380 {
381         COMPARE_SCALAR_FIELD(subLinkType);
382         COMPARE_NODE_FIELD(testexpr);
383         COMPARE_NODE_FIELD(operName);
384         COMPARE_NODE_FIELD(subselect);
385         COMPARE_LOCATION_FIELD(location);
386
387         return true;
388 }
389
390 static bool
391 _equalSubPlan(SubPlan *a, SubPlan *b)
392 {
393         COMPARE_SCALAR_FIELD(subLinkType);
394         COMPARE_NODE_FIELD(testexpr);
395         COMPARE_NODE_FIELD(paramIds);
396         COMPARE_SCALAR_FIELD(plan_id);
397         COMPARE_STRING_FIELD(plan_name);
398         COMPARE_SCALAR_FIELD(firstColType);
399         COMPARE_SCALAR_FIELD(firstColTypmod);
400         COMPARE_SCALAR_FIELD(firstColCollation);
401         COMPARE_SCALAR_FIELD(useHashTable);
402         COMPARE_SCALAR_FIELD(unknownEqFalse);
403         COMPARE_NODE_FIELD(setParam);
404         COMPARE_NODE_FIELD(parParam);
405         COMPARE_NODE_FIELD(args);
406         COMPARE_SCALAR_FIELD(startup_cost);
407         COMPARE_SCALAR_FIELD(per_call_cost);
408
409         return true;
410 }
411
412 static bool
413 _equalAlternativeSubPlan(AlternativeSubPlan *a, AlternativeSubPlan *b)
414 {
415         COMPARE_NODE_FIELD(subplans);
416
417         return true;
418 }
419
420 static bool
421 _equalFieldSelect(FieldSelect *a, FieldSelect *b)
422 {
423         COMPARE_NODE_FIELD(arg);
424         COMPARE_SCALAR_FIELD(fieldnum);
425         COMPARE_SCALAR_FIELD(resulttype);
426         COMPARE_SCALAR_FIELD(resulttypmod);
427         COMPARE_SCALAR_FIELD(resultcollid);
428
429         return true;
430 }
431
432 static bool
433 _equalFieldStore(FieldStore *a, FieldStore *b)
434 {
435         COMPARE_NODE_FIELD(arg);
436         COMPARE_NODE_FIELD(newvals);
437         COMPARE_NODE_FIELD(fieldnums);
438         COMPARE_SCALAR_FIELD(resulttype);
439
440         return true;
441 }
442
443 static bool
444 _equalRelabelType(RelabelType *a, RelabelType *b)
445 {
446         COMPARE_NODE_FIELD(arg);
447         COMPARE_SCALAR_FIELD(resulttype);
448         COMPARE_SCALAR_FIELD(resulttypmod);
449         COMPARE_SCALAR_FIELD(resultcollid);
450
451         /*
452          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
453          * that are equal() to both explicit and implicit coercions.
454          */
455         if (a->relabelformat != b->relabelformat &&
456                 a->relabelformat != COERCE_DONTCARE &&
457                 b->relabelformat != COERCE_DONTCARE)
458                 return false;
459
460         COMPARE_LOCATION_FIELD(location);
461
462         return true;
463 }
464
465 static bool
466 _equalCoerceViaIO(CoerceViaIO *a, CoerceViaIO *b)
467 {
468         COMPARE_NODE_FIELD(arg);
469         COMPARE_SCALAR_FIELD(resulttype);
470         COMPARE_SCALAR_FIELD(resultcollid);
471
472         /*
473          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
474          * that are equal() to both explicit and implicit coercions.
475          */
476         if (a->coerceformat != b->coerceformat &&
477                 a->coerceformat != COERCE_DONTCARE &&
478                 b->coerceformat != COERCE_DONTCARE)
479                 return false;
480
481         COMPARE_LOCATION_FIELD(location);
482
483         return true;
484 }
485
486 static bool
487 _equalArrayCoerceExpr(ArrayCoerceExpr *a, ArrayCoerceExpr *b)
488 {
489         COMPARE_NODE_FIELD(arg);
490         COMPARE_SCALAR_FIELD(elemfuncid);
491         COMPARE_SCALAR_FIELD(resulttype);
492         COMPARE_SCALAR_FIELD(resulttypmod);
493         COMPARE_SCALAR_FIELD(resultcollid);
494         COMPARE_SCALAR_FIELD(isExplicit);
495
496         /*
497          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
498          * that are equal() to both explicit and implicit coercions.
499          */
500         if (a->coerceformat != b->coerceformat &&
501                 a->coerceformat != COERCE_DONTCARE &&
502                 b->coerceformat != COERCE_DONTCARE)
503                 return false;
504
505         COMPARE_LOCATION_FIELD(location);
506
507         return true;
508 }
509
510 static bool
511 _equalConvertRowtypeExpr(ConvertRowtypeExpr *a, ConvertRowtypeExpr *b)
512 {
513         COMPARE_NODE_FIELD(arg);
514         COMPARE_SCALAR_FIELD(resulttype);
515
516         /*
517          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
518          * that are equal() to both explicit and implicit coercions.
519          */
520         if (a->convertformat != b->convertformat &&
521                 a->convertformat != COERCE_DONTCARE &&
522                 b->convertformat != COERCE_DONTCARE)
523                 return false;
524
525         COMPARE_LOCATION_FIELD(location);
526
527         return true;
528 }
529
530 static bool
531 _equalCollateExpr(CollateExpr *a, CollateExpr *b)
532 {
533         COMPARE_NODE_FIELD(arg);
534         COMPARE_SCALAR_FIELD(collOid);
535         COMPARE_LOCATION_FIELD(location);
536
537         return true;
538 }
539
540 static bool
541 _equalCaseExpr(CaseExpr *a, CaseExpr *b)
542 {
543         COMPARE_SCALAR_FIELD(casetype);
544         COMPARE_SCALAR_FIELD(casecollid);
545         COMPARE_NODE_FIELD(arg);
546         COMPARE_NODE_FIELD(args);
547         COMPARE_NODE_FIELD(defresult);
548         COMPARE_LOCATION_FIELD(location);
549
550         return true;
551 }
552
553 static bool
554 _equalCaseWhen(CaseWhen *a, CaseWhen *b)
555 {
556         COMPARE_NODE_FIELD(expr);
557         COMPARE_NODE_FIELD(result);
558         COMPARE_LOCATION_FIELD(location);
559
560         return true;
561 }
562
563 static bool
564 _equalCaseTestExpr(CaseTestExpr *a, CaseTestExpr *b)
565 {
566         COMPARE_SCALAR_FIELD(typeId);
567         COMPARE_SCALAR_FIELD(typeMod);
568         COMPARE_SCALAR_FIELD(collation);
569
570         return true;
571 }
572
573 static bool
574 _equalArrayExpr(ArrayExpr *a, ArrayExpr *b)
575 {
576         COMPARE_SCALAR_FIELD(array_typeid);
577         COMPARE_SCALAR_FIELD(array_collid);
578         COMPARE_SCALAR_FIELD(element_typeid);
579         COMPARE_NODE_FIELD(elements);
580         COMPARE_SCALAR_FIELD(multidims);
581         COMPARE_LOCATION_FIELD(location);
582
583         return true;
584 }
585
586 static bool
587 _equalRowExpr(RowExpr *a, RowExpr *b)
588 {
589         COMPARE_NODE_FIELD(args);
590         COMPARE_SCALAR_FIELD(row_typeid);
591
592         /*
593          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
594          * that are equal() to both explicit and implicit coercions.
595          */
596         if (a->row_format != b->row_format &&
597                 a->row_format != COERCE_DONTCARE &&
598                 b->row_format != COERCE_DONTCARE)
599                 return false;
600
601         COMPARE_NODE_FIELD(colnames);
602         COMPARE_LOCATION_FIELD(location);
603
604         return true;
605 }
606
607 static bool
608 _equalRowCompareExpr(RowCompareExpr *a, 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
621 _equalCoalesceExpr(CoalesceExpr *a, 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
632 _equalMinMaxExpr(MinMaxExpr *a, 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
645 _equalXmlExpr(XmlExpr *a, XmlExpr *b)
646 {
647         COMPARE_SCALAR_FIELD(op);
648         COMPARE_STRING_FIELD(name);
649         COMPARE_NODE_FIELD(named_args);
650         COMPARE_NODE_FIELD(arg_names);
651         COMPARE_NODE_FIELD(args);
652         COMPARE_SCALAR_FIELD(xmloption);
653         COMPARE_SCALAR_FIELD(type);
654         COMPARE_SCALAR_FIELD(typmod);
655         COMPARE_LOCATION_FIELD(location);
656
657         return true;
658 }
659
660 static bool
661 _equalNullTest(NullTest *a, NullTest *b)
662 {
663         COMPARE_NODE_FIELD(arg);
664         COMPARE_SCALAR_FIELD(nulltesttype);
665         COMPARE_SCALAR_FIELD(argisrow);
666
667         return true;
668 }
669
670 static bool
671 _equalBooleanTest(BooleanTest *a, BooleanTest *b)
672 {
673         COMPARE_NODE_FIELD(arg);
674         COMPARE_SCALAR_FIELD(booltesttype);
675
676         return true;
677 }
678
679 static bool
680 _equalCoerceToDomain(CoerceToDomain *a, CoerceToDomain *b)
681 {
682         COMPARE_NODE_FIELD(arg);
683         COMPARE_SCALAR_FIELD(resulttype);
684         COMPARE_SCALAR_FIELD(resulttypmod);
685         COMPARE_SCALAR_FIELD(resultcollid);
686
687         /*
688          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
689          * that are equal() to both explicit and implicit coercions.
690          */
691         if (a->coercionformat != b->coercionformat &&
692                 a->coercionformat != COERCE_DONTCARE &&
693                 b->coercionformat != COERCE_DONTCARE)
694                 return false;
695
696         COMPARE_LOCATION_FIELD(location);
697
698         return true;
699 }
700
701 static bool
702 _equalCoerceToDomainValue(CoerceToDomainValue *a, CoerceToDomainValue *b)
703 {
704         COMPARE_SCALAR_FIELD(typeId);
705         COMPARE_SCALAR_FIELD(typeMod);
706         COMPARE_SCALAR_FIELD(collation);
707         COMPARE_LOCATION_FIELD(location);
708
709         return true;
710 }
711
712 static bool
713 _equalSetToDefault(SetToDefault *a, SetToDefault *b)
714 {
715         COMPARE_SCALAR_FIELD(typeId);
716         COMPARE_SCALAR_FIELD(typeMod);
717         COMPARE_SCALAR_FIELD(collation);
718         COMPARE_LOCATION_FIELD(location);
719
720         return true;
721 }
722
723 static bool
724 _equalCurrentOfExpr(CurrentOfExpr *a, CurrentOfExpr *b)
725 {
726         COMPARE_SCALAR_FIELD(cvarno);
727         COMPARE_STRING_FIELD(cursor_name);
728         COMPARE_SCALAR_FIELD(cursor_param);
729
730         return true;
731 }
732
733 static bool
734 _equalTargetEntry(TargetEntry *a, TargetEntry *b)
735 {
736         COMPARE_NODE_FIELD(expr);
737         COMPARE_SCALAR_FIELD(resno);
738         COMPARE_STRING_FIELD(resname);
739         COMPARE_SCALAR_FIELD(ressortgroupref);
740         COMPARE_SCALAR_FIELD(resorigtbl);
741         COMPARE_SCALAR_FIELD(resorigcol);
742         COMPARE_SCALAR_FIELD(resjunk);
743
744         return true;
745 }
746
747 static bool
748 _equalRangeTblRef(RangeTblRef *a, RangeTblRef *b)
749 {
750         COMPARE_SCALAR_FIELD(rtindex);
751
752         return true;
753 }
754
755 static bool
756 _equalJoinExpr(JoinExpr *a, JoinExpr *b)
757 {
758         COMPARE_SCALAR_FIELD(jointype);
759         COMPARE_SCALAR_FIELD(isNatural);
760         COMPARE_NODE_FIELD(larg);
761         COMPARE_NODE_FIELD(rarg);
762         COMPARE_NODE_FIELD(usingClause);
763         COMPARE_NODE_FIELD(quals);
764         COMPARE_NODE_FIELD(alias);
765         COMPARE_SCALAR_FIELD(rtindex);
766
767         return true;
768 }
769
770 static bool
771 _equalFromExpr(FromExpr *a, FromExpr *b)
772 {
773         COMPARE_NODE_FIELD(fromlist);
774         COMPARE_NODE_FIELD(quals);
775
776         return true;
777 }
778
779
780 /*
781  * Stuff from relation.h
782  */
783
784 static bool
785 _equalPathKey(PathKey *a, PathKey *b)
786 {
787         /*
788          * This is normally used on non-canonicalized PathKeys, so must chase up
789          * to the topmost merged EquivalenceClass and see if those are the same
790          * (by pointer equality).
791          */
792         EquivalenceClass *a_eclass;
793         EquivalenceClass *b_eclass;
794
795         a_eclass = a->pk_eclass;
796         while (a_eclass->ec_merged)
797                 a_eclass = a_eclass->ec_merged;
798         b_eclass = b->pk_eclass;
799         while (b_eclass->ec_merged)
800                 b_eclass = b_eclass->ec_merged;
801         if (a_eclass != b_eclass)
802                 return false;
803         COMPARE_SCALAR_FIELD(pk_opfamily);
804         COMPARE_SCALAR_FIELD(pk_strategy);
805         COMPARE_SCALAR_FIELD(pk_nulls_first);
806
807         return true;
808 }
809
810 static bool
811 _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
812 {
813         COMPARE_NODE_FIELD(clause);
814         COMPARE_SCALAR_FIELD(is_pushed_down);
815         COMPARE_SCALAR_FIELD(outerjoin_delayed);
816         COMPARE_BITMAPSET_FIELD(required_relids);
817         COMPARE_BITMAPSET_FIELD(nullable_relids);
818
819         /*
820          * We ignore all the remaining fields, since they may not be set yet, and
821          * should be derivable from the clause anyway.
822          */
823
824         return true;
825 }
826
827 static bool
828 _equalPlaceHolderVar(PlaceHolderVar *a, PlaceHolderVar *b)
829 {
830         /*
831          * We intentionally do not compare phexpr.      Two PlaceHolderVars with the
832          * same ID and levelsup should be considered equal even if the contained
833          * expressions have managed to mutate to different states.      One way in
834          * which that can happen is that initplan sublinks would get replaced by
835          * differently-numbered Params when sublink folding is done.  (The end
836          * result of such a situation would be some unreferenced initplans, which
837          * is annoying but not really a problem.)
838          *
839          * COMPARE_NODE_FIELD(phexpr);
840          */
841         COMPARE_BITMAPSET_FIELD(phrels);
842         COMPARE_SCALAR_FIELD(phid);
843         COMPARE_SCALAR_FIELD(phlevelsup);
844
845         return true;
846 }
847
848 static bool
849 _equalSpecialJoinInfo(SpecialJoinInfo *a, SpecialJoinInfo *b)
850 {
851         COMPARE_BITMAPSET_FIELD(min_lefthand);
852         COMPARE_BITMAPSET_FIELD(min_righthand);
853         COMPARE_BITMAPSET_FIELD(syn_lefthand);
854         COMPARE_BITMAPSET_FIELD(syn_righthand);
855         COMPARE_SCALAR_FIELD(jointype);
856         COMPARE_SCALAR_FIELD(lhs_strict);
857         COMPARE_SCALAR_FIELD(delay_upper_joins);
858         COMPARE_NODE_FIELD(join_quals);
859
860         return true;
861 }
862
863 static bool
864 _equalAppendRelInfo(AppendRelInfo *a, AppendRelInfo *b)
865 {
866         COMPARE_SCALAR_FIELD(parent_relid);
867         COMPARE_SCALAR_FIELD(child_relid);
868         COMPARE_SCALAR_FIELD(parent_reltype);
869         COMPARE_SCALAR_FIELD(child_reltype);
870         COMPARE_NODE_FIELD(translated_vars);
871         COMPARE_SCALAR_FIELD(parent_reloid);
872
873         return true;
874 }
875
876 static bool
877 _equalPlaceHolderInfo(PlaceHolderInfo *a, PlaceHolderInfo *b)
878 {
879         COMPARE_SCALAR_FIELD(phid);
880         COMPARE_NODE_FIELD(ph_var);
881         COMPARE_BITMAPSET_FIELD(ph_eval_at);
882         COMPARE_BITMAPSET_FIELD(ph_needed);
883         COMPARE_BITMAPSET_FIELD(ph_may_need);
884         COMPARE_SCALAR_FIELD(ph_width);
885
886         return true;
887 }
888
889
890 /*
891  * Stuff from parsenodes.h
892  */
893
894 static bool
895 _equalQuery(Query *a, Query *b)
896 {
897         COMPARE_SCALAR_FIELD(commandType);
898         COMPARE_SCALAR_FIELD(querySource);
899         COMPARE_SCALAR_FIELD(canSetTag);
900         COMPARE_NODE_FIELD(utilityStmt);
901         COMPARE_SCALAR_FIELD(resultRelation);
902         COMPARE_NODE_FIELD(intoClause);
903         COMPARE_SCALAR_FIELD(hasAggs);
904         COMPARE_SCALAR_FIELD(hasWindowFuncs);
905         COMPARE_SCALAR_FIELD(hasSubLinks);
906         COMPARE_SCALAR_FIELD(hasDistinctOn);
907         COMPARE_SCALAR_FIELD(hasRecursive);
908         COMPARE_SCALAR_FIELD(hasModifyingCTE);
909         COMPARE_SCALAR_FIELD(hasForUpdate);
910         COMPARE_NODE_FIELD(cteList);
911         COMPARE_NODE_FIELD(rtable);
912         COMPARE_NODE_FIELD(jointree);
913         COMPARE_NODE_FIELD(targetList);
914         COMPARE_NODE_FIELD(returningList);
915         COMPARE_NODE_FIELD(groupClause);
916         COMPARE_NODE_FIELD(havingQual);
917         COMPARE_NODE_FIELD(windowClause);
918         COMPARE_NODE_FIELD(distinctClause);
919         COMPARE_NODE_FIELD(sortClause);
920         COMPARE_NODE_FIELD(limitOffset);
921         COMPARE_NODE_FIELD(limitCount);
922         COMPARE_NODE_FIELD(rowMarks);
923         COMPARE_NODE_FIELD(setOperations);
924         COMPARE_NODE_FIELD(constraintDeps);
925
926         return true;
927 }
928
929 static bool
930 _equalInsertStmt(InsertStmt *a, InsertStmt *b)
931 {
932         COMPARE_NODE_FIELD(relation);
933         COMPARE_NODE_FIELD(cols);
934         COMPARE_NODE_FIELD(selectStmt);
935         COMPARE_NODE_FIELD(returningList);
936         COMPARE_NODE_FIELD(withClause);
937
938         return true;
939 }
940
941 static bool
942 _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
943 {
944         COMPARE_NODE_FIELD(relation);
945         COMPARE_NODE_FIELD(usingClause);
946         COMPARE_NODE_FIELD(whereClause);
947         COMPARE_NODE_FIELD(returningList);
948         COMPARE_NODE_FIELD(withClause);
949
950         return true;
951 }
952
953 static bool
954 _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
955 {
956         COMPARE_NODE_FIELD(relation);
957         COMPARE_NODE_FIELD(targetList);
958         COMPARE_NODE_FIELD(whereClause);
959         COMPARE_NODE_FIELD(fromClause);
960         COMPARE_NODE_FIELD(returningList);
961         COMPARE_NODE_FIELD(withClause);
962
963         return true;
964 }
965
966 static bool
967 _equalSelectStmt(SelectStmt *a, SelectStmt *b)
968 {
969         COMPARE_NODE_FIELD(distinctClause);
970         COMPARE_NODE_FIELD(intoClause);
971         COMPARE_NODE_FIELD(targetList);
972         COMPARE_NODE_FIELD(fromClause);
973         COMPARE_NODE_FIELD(whereClause);
974         COMPARE_NODE_FIELD(groupClause);
975         COMPARE_NODE_FIELD(havingClause);
976         COMPARE_NODE_FIELD(windowClause);
977         COMPARE_NODE_FIELD(withClause);
978         COMPARE_NODE_FIELD(valuesLists);
979         COMPARE_NODE_FIELD(sortClause);
980         COMPARE_NODE_FIELD(limitOffset);
981         COMPARE_NODE_FIELD(limitCount);
982         COMPARE_NODE_FIELD(lockingClause);
983         COMPARE_SCALAR_FIELD(op);
984         COMPARE_SCALAR_FIELD(all);
985         COMPARE_NODE_FIELD(larg);
986         COMPARE_NODE_FIELD(rarg);
987
988         return true;
989 }
990
991 static bool
992 _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b)
993 {
994         COMPARE_SCALAR_FIELD(op);
995         COMPARE_SCALAR_FIELD(all);
996         COMPARE_NODE_FIELD(larg);
997         COMPARE_NODE_FIELD(rarg);
998         COMPARE_NODE_FIELD(colTypes);
999         COMPARE_NODE_FIELD(colTypmods);
1000         COMPARE_NODE_FIELD(colCollations);
1001         COMPARE_NODE_FIELD(groupClauses);
1002
1003         return true;
1004 }
1005
1006 static bool
1007 _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
1008 {
1009         COMPARE_NODE_FIELD(relation);
1010         COMPARE_NODE_FIELD(cmds);
1011         COMPARE_SCALAR_FIELD(relkind);
1012
1013         return true;
1014 }
1015
1016 static bool
1017 _equalAlterTableCmd(AlterTableCmd *a, AlterTableCmd *b)
1018 {
1019         COMPARE_SCALAR_FIELD(subtype);
1020         COMPARE_STRING_FIELD(name);
1021         COMPARE_NODE_FIELD(def);
1022         COMPARE_SCALAR_FIELD(behavior);
1023         COMPARE_SCALAR_FIELD(missing_ok);
1024
1025         return true;
1026 }
1027
1028 static bool
1029 _equalAlterDomainStmt(AlterDomainStmt *a, AlterDomainStmt *b)
1030 {
1031         COMPARE_SCALAR_FIELD(subtype);
1032         COMPARE_NODE_FIELD(typeName);
1033         COMPARE_STRING_FIELD(name);
1034         COMPARE_NODE_FIELD(def);
1035         COMPARE_SCALAR_FIELD(behavior);
1036
1037         return true;
1038 }
1039
1040 static bool
1041 _equalGrantStmt(GrantStmt *a, GrantStmt *b)
1042 {
1043         COMPARE_SCALAR_FIELD(is_grant);
1044         COMPARE_SCALAR_FIELD(targtype);
1045         COMPARE_SCALAR_FIELD(objtype);
1046         COMPARE_NODE_FIELD(objects);
1047         COMPARE_NODE_FIELD(privileges);
1048         COMPARE_NODE_FIELD(grantees);
1049         COMPARE_SCALAR_FIELD(grant_option);
1050         COMPARE_SCALAR_FIELD(behavior);
1051
1052         return true;
1053 }
1054
1055 static bool
1056 _equalPrivGrantee(PrivGrantee *a, PrivGrantee *b)
1057 {
1058         COMPARE_STRING_FIELD(rolname);
1059
1060         return true;
1061 }
1062
1063 static bool
1064 _equalFuncWithArgs(FuncWithArgs *a, FuncWithArgs *b)
1065 {
1066         COMPARE_NODE_FIELD(funcname);
1067         COMPARE_NODE_FIELD(funcargs);
1068
1069         return true;
1070 }
1071
1072 static bool
1073 _equalAccessPriv(AccessPriv *a, AccessPriv *b)
1074 {
1075         COMPARE_STRING_FIELD(priv_name);
1076         COMPARE_NODE_FIELD(cols);
1077
1078         return true;
1079 }
1080
1081 static bool
1082 _equalGrantRoleStmt(GrantRoleStmt *a, GrantRoleStmt *b)
1083 {
1084         COMPARE_NODE_FIELD(granted_roles);
1085         COMPARE_NODE_FIELD(grantee_roles);
1086         COMPARE_SCALAR_FIELD(is_grant);
1087         COMPARE_SCALAR_FIELD(admin_opt);
1088         COMPARE_STRING_FIELD(grantor);
1089         COMPARE_SCALAR_FIELD(behavior);
1090
1091         return true;
1092 }
1093
1094 static bool
1095 _equalAlterDefaultPrivilegesStmt(AlterDefaultPrivilegesStmt *a, AlterDefaultPrivilegesStmt *b)
1096 {
1097         COMPARE_NODE_FIELD(options);
1098         COMPARE_NODE_FIELD(action);
1099
1100         return true;
1101 }
1102
1103 static bool
1104 _equalDeclareCursorStmt(DeclareCursorStmt *a, DeclareCursorStmt *b)
1105 {
1106         COMPARE_STRING_FIELD(portalname);
1107         COMPARE_SCALAR_FIELD(options);
1108         COMPARE_NODE_FIELD(query);
1109
1110         return true;
1111 }
1112
1113 static bool
1114 _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
1115 {
1116         COMPARE_STRING_FIELD(portalname);
1117
1118         return true;
1119 }
1120
1121 static bool
1122 _equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
1123 {
1124         COMPARE_NODE_FIELD(relation);
1125         COMPARE_STRING_FIELD(indexname);
1126         COMPARE_SCALAR_FIELD(verbose);
1127
1128         return true;
1129 }
1130
1131 static bool
1132 _equalCopyStmt(CopyStmt *a, CopyStmt *b)
1133 {
1134         COMPARE_NODE_FIELD(relation);
1135         COMPARE_NODE_FIELD(query);
1136         COMPARE_NODE_FIELD(attlist);
1137         COMPARE_SCALAR_FIELD(is_from);
1138         COMPARE_STRING_FIELD(filename);
1139         COMPARE_NODE_FIELD(options);
1140
1141         return true;
1142 }
1143
1144 static bool
1145 _equalCreateStmt(CreateStmt *a, CreateStmt *b)
1146 {
1147         COMPARE_NODE_FIELD(relation);
1148         COMPARE_NODE_FIELD(tableElts);
1149         COMPARE_NODE_FIELD(inhRelations);
1150         COMPARE_NODE_FIELD(ofTypename);
1151         COMPARE_NODE_FIELD(constraints);
1152         COMPARE_NODE_FIELD(options);
1153         COMPARE_SCALAR_FIELD(oncommit);
1154         COMPARE_STRING_FIELD(tablespacename);
1155         COMPARE_SCALAR_FIELD(if_not_exists);
1156
1157         return true;
1158 }
1159
1160 static bool
1161 _equalInhRelation(InhRelation *a, InhRelation *b)
1162 {
1163         COMPARE_NODE_FIELD(relation);
1164         COMPARE_SCALAR_FIELD(options);
1165
1166         return true;
1167 }
1168
1169 static bool
1170 _equalDefineStmt(DefineStmt *a, DefineStmt *b)
1171 {
1172         COMPARE_SCALAR_FIELD(kind);
1173         COMPARE_SCALAR_FIELD(oldstyle);
1174         COMPARE_NODE_FIELD(defnames);
1175         COMPARE_NODE_FIELD(args);
1176         COMPARE_NODE_FIELD(definition);
1177
1178         return true;
1179 }
1180
1181 static bool
1182 _equalDropStmt(DropStmt *a, DropStmt *b)
1183 {
1184         COMPARE_NODE_FIELD(objects);
1185         COMPARE_SCALAR_FIELD(removeType);
1186         COMPARE_SCALAR_FIELD(behavior);
1187         COMPARE_SCALAR_FIELD(missing_ok);
1188
1189         return true;
1190 }
1191
1192 static bool
1193 _equalTruncateStmt(TruncateStmt *a, TruncateStmt *b)
1194 {
1195         COMPARE_NODE_FIELD(relations);
1196         COMPARE_SCALAR_FIELD(restart_seqs);
1197         COMPARE_SCALAR_FIELD(behavior);
1198
1199         return true;
1200 }
1201
1202 static bool
1203 _equalCommentStmt(CommentStmt *a, CommentStmt *b)
1204 {
1205         COMPARE_SCALAR_FIELD(objtype);
1206         COMPARE_NODE_FIELD(objname);
1207         COMPARE_NODE_FIELD(objargs);
1208         COMPARE_STRING_FIELD(comment);
1209
1210         return true;
1211 }
1212
1213 static bool
1214 _equalSecLabelStmt(SecLabelStmt *a, SecLabelStmt *b)
1215 {
1216         COMPARE_SCALAR_FIELD(objtype);
1217         COMPARE_NODE_FIELD(objname);
1218         COMPARE_NODE_FIELD(objargs);
1219         COMPARE_STRING_FIELD(provider);
1220         COMPARE_STRING_FIELD(label);
1221
1222         return true;
1223 }
1224
1225 static bool
1226 _equalFetchStmt(FetchStmt *a, FetchStmt *b)
1227 {
1228         COMPARE_SCALAR_FIELD(direction);
1229         COMPARE_SCALAR_FIELD(howMany);
1230         COMPARE_STRING_FIELD(portalname);
1231         COMPARE_SCALAR_FIELD(ismove);
1232
1233         return true;
1234 }
1235
1236 static bool
1237 _equalIndexStmt(IndexStmt *a, IndexStmt *b)
1238 {
1239         COMPARE_STRING_FIELD(idxname);
1240         COMPARE_NODE_FIELD(relation);
1241         COMPARE_STRING_FIELD(accessMethod);
1242         COMPARE_STRING_FIELD(tableSpace);
1243         COMPARE_NODE_FIELD(indexParams);
1244         COMPARE_NODE_FIELD(options);
1245         COMPARE_NODE_FIELD(whereClause);
1246         COMPARE_NODE_FIELD(excludeOpNames);
1247         COMPARE_SCALAR_FIELD(indexOid);
1248         COMPARE_SCALAR_FIELD(oldNode);
1249         COMPARE_SCALAR_FIELD(unique);
1250         COMPARE_SCALAR_FIELD(primary);
1251         COMPARE_SCALAR_FIELD(isconstraint);
1252         COMPARE_SCALAR_FIELD(deferrable);
1253         COMPARE_SCALAR_FIELD(initdeferred);
1254         COMPARE_SCALAR_FIELD(concurrent);
1255
1256         return true;
1257 }
1258
1259 static bool
1260 _equalCreateFunctionStmt(CreateFunctionStmt *a, CreateFunctionStmt *b)
1261 {
1262         COMPARE_SCALAR_FIELD(replace);
1263         COMPARE_NODE_FIELD(funcname);
1264         COMPARE_NODE_FIELD(parameters);
1265         COMPARE_NODE_FIELD(returnType);
1266         COMPARE_NODE_FIELD(options);
1267         COMPARE_NODE_FIELD(withClause);
1268
1269         return true;
1270 }
1271
1272 static bool
1273 _equalFunctionParameter(FunctionParameter *a, FunctionParameter *b)
1274 {
1275         COMPARE_STRING_FIELD(name);
1276         COMPARE_NODE_FIELD(argType);
1277         COMPARE_SCALAR_FIELD(mode);
1278         COMPARE_NODE_FIELD(defexpr);
1279
1280         return true;
1281 }
1282
1283 static bool
1284 _equalAlterFunctionStmt(AlterFunctionStmt *a, AlterFunctionStmt *b)
1285 {
1286         COMPARE_NODE_FIELD(func);
1287         COMPARE_NODE_FIELD(actions);
1288
1289         return true;
1290 }
1291
1292 static bool
1293 _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b)
1294 {
1295         COMPARE_SCALAR_FIELD(kind);
1296         COMPARE_NODE_FIELD(name);
1297         COMPARE_NODE_FIELD(args);
1298         COMPARE_SCALAR_FIELD(behavior);
1299         COMPARE_SCALAR_FIELD(missing_ok);
1300
1301         return true;
1302 }
1303
1304 static bool
1305 _equalDoStmt(DoStmt *a, DoStmt *b)
1306 {
1307         COMPARE_NODE_FIELD(args);
1308
1309         return true;
1310 }
1311
1312 static bool
1313 _equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b)
1314 {
1315         COMPARE_NODE_FIELD(opclassname);
1316         COMPARE_STRING_FIELD(amname);
1317         COMPARE_SCALAR_FIELD(behavior);
1318         COMPARE_SCALAR_FIELD(missing_ok);
1319
1320         return true;
1321 }
1322
1323 static bool
1324 _equalRemoveOpFamilyStmt(RemoveOpFamilyStmt *a, RemoveOpFamilyStmt *b)
1325 {
1326         COMPARE_NODE_FIELD(opfamilyname);
1327         COMPARE_STRING_FIELD(amname);
1328         COMPARE_SCALAR_FIELD(behavior);
1329         COMPARE_SCALAR_FIELD(missing_ok);
1330
1331         return true;
1332 }
1333
1334 static bool
1335 _equalRenameStmt(RenameStmt *a, RenameStmt *b)
1336 {
1337         COMPARE_SCALAR_FIELD(renameType);
1338         COMPARE_NODE_FIELD(relation);
1339         COMPARE_NODE_FIELD(object);
1340         COMPARE_NODE_FIELD(objarg);
1341         COMPARE_STRING_FIELD(subname);
1342         COMPARE_STRING_FIELD(newname);
1343         COMPARE_SCALAR_FIELD(behavior);
1344
1345         return true;
1346 }
1347
1348 static bool
1349 _equalAlterObjectSchemaStmt(AlterObjectSchemaStmt *a, AlterObjectSchemaStmt *b)
1350 {
1351         COMPARE_SCALAR_FIELD(objectType);
1352         COMPARE_NODE_FIELD(relation);
1353         COMPARE_NODE_FIELD(object);
1354         COMPARE_NODE_FIELD(objarg);
1355         COMPARE_STRING_FIELD(addname);
1356         COMPARE_STRING_FIELD(newschema);
1357
1358         return true;
1359 }
1360
1361 static bool
1362 _equalAlterOwnerStmt(AlterOwnerStmt *a, AlterOwnerStmt *b)
1363 {
1364         COMPARE_SCALAR_FIELD(objectType);
1365         COMPARE_NODE_FIELD(relation);
1366         COMPARE_NODE_FIELD(object);
1367         COMPARE_NODE_FIELD(objarg);
1368         COMPARE_STRING_FIELD(addname);
1369         COMPARE_STRING_FIELD(newowner);
1370
1371         return true;
1372 }
1373
1374 static bool
1375 _equalRuleStmt(RuleStmt *a, RuleStmt *b)
1376 {
1377         COMPARE_NODE_FIELD(relation);
1378         COMPARE_STRING_FIELD(rulename);
1379         COMPARE_NODE_FIELD(whereClause);
1380         COMPARE_SCALAR_FIELD(event);
1381         COMPARE_SCALAR_FIELD(instead);
1382         COMPARE_NODE_FIELD(actions);
1383         COMPARE_SCALAR_FIELD(replace);
1384
1385         return true;
1386 }
1387
1388 static bool
1389 _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
1390 {
1391         COMPARE_STRING_FIELD(conditionname);
1392         COMPARE_STRING_FIELD(payload);
1393
1394         return true;
1395 }
1396
1397 static bool
1398 _equalListenStmt(ListenStmt *a, ListenStmt *b)
1399 {
1400         COMPARE_STRING_FIELD(conditionname);
1401
1402         return true;
1403 }
1404
1405 static bool
1406 _equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
1407 {
1408         COMPARE_STRING_FIELD(conditionname);
1409
1410         return true;
1411 }
1412
1413 static bool
1414 _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
1415 {
1416         COMPARE_SCALAR_FIELD(kind);
1417         COMPARE_NODE_FIELD(options);
1418         COMPARE_STRING_FIELD(gid);
1419
1420         return true;
1421 }
1422
1423 static bool
1424 _equalCompositeTypeStmt(CompositeTypeStmt *a, CompositeTypeStmt *b)
1425 {
1426         COMPARE_NODE_FIELD(typevar);
1427         COMPARE_NODE_FIELD(coldeflist);
1428
1429         return true;
1430 }
1431
1432 static bool
1433 _equalCreateEnumStmt(CreateEnumStmt *a, CreateEnumStmt *b)
1434 {
1435         COMPARE_NODE_FIELD(typeName);
1436         COMPARE_NODE_FIELD(vals);
1437
1438         return true;
1439 }
1440
1441 static bool
1442 _equalAlterEnumStmt(AlterEnumStmt *a, AlterEnumStmt *b)
1443 {
1444         COMPARE_NODE_FIELD(typeName);
1445         COMPARE_STRING_FIELD(newVal);
1446         COMPARE_STRING_FIELD(newValNeighbor);
1447         COMPARE_SCALAR_FIELD(newValIsAfter);
1448
1449         return true;
1450 }
1451
1452 static bool
1453 _equalViewStmt(ViewStmt *a, ViewStmt *b)
1454 {
1455         COMPARE_NODE_FIELD(view);
1456         COMPARE_NODE_FIELD(aliases);
1457         COMPARE_NODE_FIELD(query);
1458         COMPARE_SCALAR_FIELD(replace);
1459
1460         return true;
1461 }
1462
1463 static bool
1464 _equalLoadStmt(LoadStmt *a, LoadStmt *b)
1465 {
1466         COMPARE_STRING_FIELD(filename);
1467
1468         return true;
1469 }
1470
1471 static bool
1472 _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b)
1473 {
1474         COMPARE_NODE_FIELD(domainname);
1475         COMPARE_NODE_FIELD(typeName);
1476         COMPARE_NODE_FIELD(collClause);
1477         COMPARE_NODE_FIELD(constraints);
1478
1479         return true;
1480 }
1481
1482 static bool
1483 _equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b)
1484 {
1485         COMPARE_NODE_FIELD(opclassname);
1486         COMPARE_NODE_FIELD(opfamilyname);
1487         COMPARE_STRING_FIELD(amname);
1488         COMPARE_NODE_FIELD(datatype);
1489         COMPARE_NODE_FIELD(items);
1490         COMPARE_SCALAR_FIELD(isDefault);
1491
1492         return true;
1493 }
1494
1495 static bool
1496 _equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b)
1497 {
1498         COMPARE_SCALAR_FIELD(itemtype);
1499         COMPARE_NODE_FIELD(name);
1500         COMPARE_NODE_FIELD(args);
1501         COMPARE_SCALAR_FIELD(number);
1502         COMPARE_NODE_FIELD(order_family);
1503         COMPARE_NODE_FIELD(class_args);
1504         COMPARE_NODE_FIELD(storedtype);
1505
1506         return true;
1507 }
1508
1509 static bool
1510 _equalCreateOpFamilyStmt(CreateOpFamilyStmt *a, CreateOpFamilyStmt *b)
1511 {
1512         COMPARE_NODE_FIELD(opfamilyname);
1513         COMPARE_STRING_FIELD(amname);
1514
1515         return true;
1516 }
1517
1518 static bool
1519 _equalAlterOpFamilyStmt(AlterOpFamilyStmt *a, AlterOpFamilyStmt *b)
1520 {
1521         COMPARE_NODE_FIELD(opfamilyname);
1522         COMPARE_STRING_FIELD(amname);
1523         COMPARE_SCALAR_FIELD(isDrop);
1524         COMPARE_NODE_FIELD(items);
1525
1526         return true;
1527 }
1528
1529 static bool
1530 _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
1531 {
1532         COMPARE_STRING_FIELD(dbname);
1533         COMPARE_NODE_FIELD(options);
1534
1535         return true;
1536 }
1537
1538 static bool
1539 _equalAlterDatabaseStmt(AlterDatabaseStmt *a, AlterDatabaseStmt *b)
1540 {
1541         COMPARE_STRING_FIELD(dbname);
1542         COMPARE_NODE_FIELD(options);
1543
1544         return true;
1545 }
1546
1547 static bool
1548 _equalAlterDatabaseSetStmt(AlterDatabaseSetStmt *a, AlterDatabaseSetStmt *b)
1549 {
1550         COMPARE_STRING_FIELD(dbname);
1551         COMPARE_NODE_FIELD(setstmt);
1552
1553         return true;
1554 }
1555
1556 static bool
1557 _equalDropdbStmt(DropdbStmt *a, DropdbStmt *b)
1558 {
1559         COMPARE_STRING_FIELD(dbname);
1560         COMPARE_SCALAR_FIELD(missing_ok);
1561
1562         return true;
1563 }
1564
1565 static bool
1566 _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
1567 {
1568         COMPARE_SCALAR_FIELD(options);
1569         COMPARE_SCALAR_FIELD(freeze_min_age);
1570         COMPARE_SCALAR_FIELD(freeze_table_age);
1571         COMPARE_NODE_FIELD(relation);
1572         COMPARE_NODE_FIELD(va_cols);
1573
1574         return true;
1575 }
1576
1577 static bool
1578 _equalExplainStmt(ExplainStmt *a, ExplainStmt *b)
1579 {
1580         COMPARE_NODE_FIELD(query);
1581         COMPARE_NODE_FIELD(options);
1582
1583         return true;
1584 }
1585
1586 static bool
1587 _equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b)
1588 {
1589         COMPARE_NODE_FIELD(sequence);
1590         COMPARE_NODE_FIELD(options);
1591         COMPARE_SCALAR_FIELD(ownerId);
1592
1593         return true;
1594 }
1595
1596 static bool
1597 _equalAlterSeqStmt(AlterSeqStmt *a, AlterSeqStmt *b)
1598 {
1599         COMPARE_NODE_FIELD(sequence);
1600         COMPARE_NODE_FIELD(options);
1601
1602         return true;
1603 }
1604
1605 static bool
1606 _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
1607 {
1608         COMPARE_SCALAR_FIELD(kind);
1609         COMPARE_STRING_FIELD(name);
1610         COMPARE_NODE_FIELD(args);
1611         COMPARE_SCALAR_FIELD(is_local);
1612
1613         return true;
1614 }
1615
1616 static bool
1617 _equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b)
1618 {
1619         COMPARE_STRING_FIELD(name);
1620
1621         return true;
1622 }
1623
1624 static bool
1625 _equalDiscardStmt(DiscardStmt *a, DiscardStmt *b)
1626 {
1627         COMPARE_SCALAR_FIELD(target);
1628
1629         return true;
1630 }
1631
1632 static bool
1633 _equalCreateTableSpaceStmt(CreateTableSpaceStmt *a, CreateTableSpaceStmt *b)
1634 {
1635         COMPARE_STRING_FIELD(tablespacename);
1636         COMPARE_STRING_FIELD(owner);
1637         COMPARE_STRING_FIELD(location);
1638
1639         return true;
1640 }
1641
1642 static bool
1643 _equalDropTableSpaceStmt(DropTableSpaceStmt *a, DropTableSpaceStmt *b)
1644 {
1645         COMPARE_STRING_FIELD(tablespacename);
1646         COMPARE_SCALAR_FIELD(missing_ok);
1647
1648         return true;
1649 }
1650
1651 static bool
1652 _equalAlterTableSpaceOptionsStmt(AlterTableSpaceOptionsStmt *a,
1653                                                                  AlterTableSpaceOptionsStmt *b)
1654 {
1655         COMPARE_STRING_FIELD(tablespacename);
1656         COMPARE_NODE_FIELD(options);
1657         COMPARE_SCALAR_FIELD(isReset);
1658
1659         return true;
1660 }
1661
1662 static bool
1663 _equalCreateExtensionStmt(CreateExtensionStmt *a, CreateExtensionStmt *b)
1664 {
1665         COMPARE_STRING_FIELD(extname);
1666         COMPARE_SCALAR_FIELD(if_not_exists);
1667         COMPARE_NODE_FIELD(options);
1668
1669         return true;
1670 }
1671
1672 static bool
1673 _equalAlterExtensionStmt(AlterExtensionStmt *a, AlterExtensionStmt *b)
1674 {
1675         COMPARE_STRING_FIELD(extname);
1676         COMPARE_NODE_FIELD(options);
1677
1678         return true;
1679 }
1680
1681 static bool
1682 _equalAlterExtensionContentsStmt(AlterExtensionContentsStmt *a, AlterExtensionContentsStmt *b)
1683 {
1684         COMPARE_STRING_FIELD(extname);
1685         COMPARE_SCALAR_FIELD(action);
1686         COMPARE_SCALAR_FIELD(objtype);
1687         COMPARE_NODE_FIELD(objname);
1688         COMPARE_NODE_FIELD(objargs);
1689
1690         return true;
1691 }
1692
1693 static bool
1694 _equalCreateFdwStmt(CreateFdwStmt *a, CreateFdwStmt *b)
1695 {
1696         COMPARE_STRING_FIELD(fdwname);
1697         COMPARE_NODE_FIELD(func_options);
1698         COMPARE_NODE_FIELD(options);
1699
1700         return true;
1701 }
1702
1703 static bool
1704 _equalAlterFdwStmt(AlterFdwStmt *a, AlterFdwStmt *b)
1705 {
1706         COMPARE_STRING_FIELD(fdwname);
1707         COMPARE_NODE_FIELD(func_options);
1708         COMPARE_NODE_FIELD(options);
1709
1710         return true;
1711 }
1712
1713 static bool
1714 _equalDropFdwStmt(DropFdwStmt *a, DropFdwStmt *b)
1715 {
1716         COMPARE_STRING_FIELD(fdwname);
1717         COMPARE_SCALAR_FIELD(missing_ok);
1718         COMPARE_SCALAR_FIELD(behavior);
1719
1720         return true;
1721 }
1722
1723 static bool
1724 _equalCreateForeignServerStmt(CreateForeignServerStmt *a, CreateForeignServerStmt *b)
1725 {
1726         COMPARE_STRING_FIELD(servername);
1727         COMPARE_STRING_FIELD(servertype);
1728         COMPARE_STRING_FIELD(version);
1729         COMPARE_STRING_FIELD(fdwname);
1730         COMPARE_NODE_FIELD(options);
1731
1732         return true;
1733 }
1734
1735 static bool
1736 _equalAlterForeignServerStmt(AlterForeignServerStmt *a, AlterForeignServerStmt *b)
1737 {
1738         COMPARE_STRING_FIELD(servername);
1739         COMPARE_STRING_FIELD(version);
1740         COMPARE_NODE_FIELD(options);
1741         COMPARE_SCALAR_FIELD(has_version);
1742
1743         return true;
1744 }
1745
1746 static bool
1747 _equalDropForeignServerStmt(DropForeignServerStmt *a, DropForeignServerStmt *b)
1748 {
1749         COMPARE_STRING_FIELD(servername);
1750         COMPARE_SCALAR_FIELD(missing_ok);
1751         COMPARE_SCALAR_FIELD(behavior);
1752
1753         return true;
1754 }
1755
1756 static bool
1757 _equalCreateUserMappingStmt(CreateUserMappingStmt *a, CreateUserMappingStmt *b)
1758 {
1759         COMPARE_STRING_FIELD(username);
1760         COMPARE_STRING_FIELD(servername);
1761         COMPARE_NODE_FIELD(options);
1762
1763         return true;
1764 }
1765
1766 static bool
1767 _equalAlterUserMappingStmt(AlterUserMappingStmt *a, AlterUserMappingStmt *b)
1768 {
1769         COMPARE_STRING_FIELD(username);
1770         COMPARE_STRING_FIELD(servername);
1771         COMPARE_NODE_FIELD(options);
1772
1773         return true;
1774 }
1775
1776 static bool
1777 _equalDropUserMappingStmt(DropUserMappingStmt *a, DropUserMappingStmt *b)
1778 {
1779         COMPARE_STRING_FIELD(username);
1780         COMPARE_STRING_FIELD(servername);
1781         COMPARE_SCALAR_FIELD(missing_ok);
1782
1783         return true;
1784 }
1785
1786 static bool
1787 _equalCreateForeignTableStmt(CreateForeignTableStmt *a, CreateForeignTableStmt *b)
1788 {
1789         if (!_equalCreateStmt(&a->base, &b->base))
1790                 return false;
1791
1792         COMPARE_STRING_FIELD(servername);
1793         COMPARE_NODE_FIELD(options);
1794
1795         return true;
1796 }
1797
1798 static bool
1799 _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b)
1800 {
1801         COMPARE_STRING_FIELD(trigname);
1802         COMPARE_NODE_FIELD(relation);
1803         COMPARE_NODE_FIELD(funcname);
1804         COMPARE_NODE_FIELD(args);
1805         COMPARE_SCALAR_FIELD(row);
1806         COMPARE_SCALAR_FIELD(timing);
1807         COMPARE_SCALAR_FIELD(events);
1808         COMPARE_NODE_FIELD(columns);
1809         COMPARE_NODE_FIELD(whenClause);
1810         COMPARE_SCALAR_FIELD(isconstraint);
1811         COMPARE_SCALAR_FIELD(deferrable);
1812         COMPARE_SCALAR_FIELD(initdeferred);
1813         COMPARE_NODE_FIELD(constrrel);
1814
1815         return true;
1816 }
1817
1818 static bool
1819 _equalDropPropertyStmt(DropPropertyStmt *a, DropPropertyStmt *b)
1820 {
1821         COMPARE_NODE_FIELD(relation);
1822         COMPARE_STRING_FIELD(property);
1823         COMPARE_SCALAR_FIELD(removeType);
1824         COMPARE_SCALAR_FIELD(behavior);
1825         COMPARE_SCALAR_FIELD(missing_ok);
1826
1827         return true;
1828 }
1829
1830 static bool
1831 _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b)
1832 {
1833         COMPARE_SCALAR_FIELD(replace);
1834         COMPARE_STRING_FIELD(plname);
1835         COMPARE_NODE_FIELD(plhandler);
1836         COMPARE_NODE_FIELD(plinline);
1837         COMPARE_NODE_FIELD(plvalidator);
1838         COMPARE_SCALAR_FIELD(pltrusted);
1839
1840         return true;
1841 }
1842
1843 static bool
1844 _equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b)
1845 {
1846         COMPARE_STRING_FIELD(plname);
1847         COMPARE_SCALAR_FIELD(behavior);
1848         COMPARE_SCALAR_FIELD(missing_ok);
1849
1850         return true;
1851 }
1852
1853 static bool
1854 _equalCreateRoleStmt(CreateRoleStmt *a, CreateRoleStmt *b)
1855 {
1856         COMPARE_SCALAR_FIELD(stmt_type);
1857         COMPARE_STRING_FIELD(role);
1858         COMPARE_NODE_FIELD(options);
1859
1860         return true;
1861 }
1862
1863 static bool
1864 _equalAlterRoleStmt(AlterRoleStmt *a, AlterRoleStmt *b)
1865 {
1866         COMPARE_STRING_FIELD(role);
1867         COMPARE_NODE_FIELD(options);
1868         COMPARE_SCALAR_FIELD(action);
1869
1870         return true;
1871 }
1872
1873 static bool
1874 _equalAlterRoleSetStmt(AlterRoleSetStmt *a, AlterRoleSetStmt *b)
1875 {
1876         COMPARE_STRING_FIELD(role);
1877         COMPARE_STRING_FIELD(database);
1878         COMPARE_NODE_FIELD(setstmt);
1879
1880         return true;
1881 }
1882
1883 static bool
1884 _equalDropRoleStmt(DropRoleStmt *a, DropRoleStmt *b)
1885 {
1886         COMPARE_NODE_FIELD(roles);
1887         COMPARE_SCALAR_FIELD(missing_ok);
1888
1889         return true;
1890 }
1891
1892 static bool
1893 _equalLockStmt(LockStmt *a, LockStmt *b)
1894 {
1895         COMPARE_NODE_FIELD(relations);
1896         COMPARE_SCALAR_FIELD(mode);
1897         COMPARE_SCALAR_FIELD(nowait);
1898
1899         return true;
1900 }
1901
1902 static bool
1903 _equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b)
1904 {
1905         COMPARE_NODE_FIELD(constraints);
1906         COMPARE_SCALAR_FIELD(deferred);
1907
1908         return true;
1909 }
1910
1911 static bool
1912 _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
1913 {
1914         COMPARE_SCALAR_FIELD(kind);
1915         COMPARE_NODE_FIELD(relation);
1916         COMPARE_STRING_FIELD(name);
1917         COMPARE_SCALAR_FIELD(do_system);
1918         COMPARE_SCALAR_FIELD(do_user);
1919
1920         return true;
1921 }
1922
1923 static bool
1924 _equalCreateSchemaStmt(CreateSchemaStmt *a, CreateSchemaStmt *b)
1925 {
1926         COMPARE_STRING_FIELD(schemaname);
1927         COMPARE_STRING_FIELD(authid);
1928         COMPARE_NODE_FIELD(schemaElts);
1929
1930         return true;
1931 }
1932
1933 static bool
1934 _equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b)
1935 {
1936         COMPARE_NODE_FIELD(conversion_name);
1937         COMPARE_STRING_FIELD(for_encoding_name);
1938         COMPARE_STRING_FIELD(to_encoding_name);
1939         COMPARE_NODE_FIELD(func_name);
1940         COMPARE_SCALAR_FIELD(def);
1941
1942         return true;
1943 }
1944
1945 static bool
1946 _equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b)
1947 {
1948         COMPARE_NODE_FIELD(sourcetype);
1949         COMPARE_NODE_FIELD(targettype);
1950         COMPARE_NODE_FIELD(func);
1951         COMPARE_SCALAR_FIELD(context);
1952         COMPARE_SCALAR_FIELD(inout);
1953
1954         return true;
1955 }
1956
1957 static bool
1958 _equalDropCastStmt(DropCastStmt *a, DropCastStmt *b)
1959 {
1960         COMPARE_NODE_FIELD(sourcetype);
1961         COMPARE_NODE_FIELD(targettype);
1962         COMPARE_SCALAR_FIELD(behavior);
1963         COMPARE_SCALAR_FIELD(missing_ok);
1964
1965         return true;
1966 }
1967
1968 static bool
1969 _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b)
1970 {
1971         COMPARE_STRING_FIELD(name);
1972         COMPARE_NODE_FIELD(argtypes);
1973         COMPARE_NODE_FIELD(query);
1974
1975         return true;
1976 }
1977
1978 static bool
1979 _equalExecuteStmt(ExecuteStmt *a, ExecuteStmt *b)
1980 {
1981         COMPARE_STRING_FIELD(name);
1982         COMPARE_NODE_FIELD(into);
1983         COMPARE_NODE_FIELD(params);
1984
1985         return true;
1986 }
1987
1988 static bool
1989 _equalDeallocateStmt(DeallocateStmt *a, DeallocateStmt *b)
1990 {
1991         COMPARE_STRING_FIELD(name);
1992
1993         return true;
1994 }
1995
1996 static bool
1997 _equalDropOwnedStmt(DropOwnedStmt *a, DropOwnedStmt *b)
1998 {
1999         COMPARE_NODE_FIELD(roles);
2000         COMPARE_SCALAR_FIELD(behavior);
2001
2002         return true;
2003 }
2004
2005 static bool
2006 _equalReassignOwnedStmt(ReassignOwnedStmt *a, ReassignOwnedStmt *b)
2007 {
2008         COMPARE_NODE_FIELD(roles);
2009         COMPARE_NODE_FIELD(newrole);
2010
2011         return true;
2012 }
2013
2014 static bool
2015 _equalAlterTSDictionaryStmt(AlterTSDictionaryStmt *a, AlterTSDictionaryStmt *b)
2016 {
2017         COMPARE_NODE_FIELD(dictname);
2018         COMPARE_NODE_FIELD(options);
2019
2020         return true;
2021 }
2022
2023 static bool
2024 _equalAlterTSConfigurationStmt(AlterTSConfigurationStmt *a,
2025                                                            AlterTSConfigurationStmt *b)
2026 {
2027         COMPARE_NODE_FIELD(cfgname);
2028         COMPARE_NODE_FIELD(tokentype);
2029         COMPARE_NODE_FIELD(dicts);
2030         COMPARE_SCALAR_FIELD(override);
2031         COMPARE_SCALAR_FIELD(replace);
2032         COMPARE_SCALAR_FIELD(missing_ok);
2033
2034         return true;
2035 }
2036
2037 static bool
2038 _equalAExpr(A_Expr *a, A_Expr *b)
2039 {
2040         COMPARE_SCALAR_FIELD(kind);
2041         COMPARE_NODE_FIELD(name);
2042         COMPARE_NODE_FIELD(lexpr);
2043         COMPARE_NODE_FIELD(rexpr);
2044         COMPARE_LOCATION_FIELD(location);
2045
2046         return true;
2047 }
2048
2049 static bool
2050 _equalColumnRef(ColumnRef *a, ColumnRef *b)
2051 {
2052         COMPARE_NODE_FIELD(fields);
2053         COMPARE_LOCATION_FIELD(location);
2054
2055         return true;
2056 }
2057
2058 static bool
2059 _equalParamRef(ParamRef *a, ParamRef *b)
2060 {
2061         COMPARE_SCALAR_FIELD(number);
2062         COMPARE_LOCATION_FIELD(location);
2063
2064         return true;
2065 }
2066
2067 static bool
2068 _equalAConst(A_Const *a, A_Const *b)
2069 {
2070         if (!equal(&a->val, &b->val))           /* hack for in-line Value field */
2071                 return false;
2072         COMPARE_LOCATION_FIELD(location);
2073
2074         return true;
2075 }
2076
2077 static bool
2078 _equalFuncCall(FuncCall *a, FuncCall *b)
2079 {
2080         COMPARE_NODE_FIELD(funcname);
2081         COMPARE_NODE_FIELD(args);
2082         COMPARE_NODE_FIELD(agg_order);
2083         COMPARE_SCALAR_FIELD(agg_star);
2084         COMPARE_SCALAR_FIELD(agg_distinct);
2085         COMPARE_SCALAR_FIELD(func_variadic);
2086         COMPARE_NODE_FIELD(over);
2087         COMPARE_LOCATION_FIELD(location);
2088
2089         return true;
2090 }
2091
2092 static bool
2093 _equalAStar(A_Star *a, A_Star *b)
2094 {
2095         return true;
2096 }
2097
2098 static bool
2099 _equalAIndices(A_Indices *a, A_Indices *b)
2100 {
2101         COMPARE_NODE_FIELD(lidx);
2102         COMPARE_NODE_FIELD(uidx);
2103
2104         return true;
2105 }
2106
2107 static bool
2108 _equalA_Indirection(A_Indirection *a, A_Indirection *b)
2109 {
2110         COMPARE_NODE_FIELD(arg);
2111         COMPARE_NODE_FIELD(indirection);
2112
2113         return true;
2114 }
2115
2116 static bool
2117 _equalA_ArrayExpr(A_ArrayExpr *a, A_ArrayExpr *b)
2118 {
2119         COMPARE_NODE_FIELD(elements);
2120         COMPARE_LOCATION_FIELD(location);
2121
2122         return true;
2123 }
2124
2125 static bool
2126 _equalResTarget(ResTarget *a, ResTarget *b)
2127 {
2128         COMPARE_STRING_FIELD(name);
2129         COMPARE_NODE_FIELD(indirection);
2130         COMPARE_NODE_FIELD(val);
2131         COMPARE_LOCATION_FIELD(location);
2132
2133         return true;
2134 }
2135
2136 static bool
2137 _equalTypeName(TypeName *a, TypeName *b)
2138 {
2139         COMPARE_NODE_FIELD(names);
2140         COMPARE_SCALAR_FIELD(typeOid);
2141         COMPARE_SCALAR_FIELD(setof);
2142         COMPARE_SCALAR_FIELD(pct_type);
2143         COMPARE_NODE_FIELD(typmods);
2144         COMPARE_SCALAR_FIELD(typemod);
2145         COMPARE_NODE_FIELD(arrayBounds);
2146         COMPARE_LOCATION_FIELD(location);
2147
2148         return true;
2149 }
2150
2151 static bool
2152 _equalTypeCast(TypeCast *a, TypeCast *b)
2153 {
2154         COMPARE_NODE_FIELD(arg);
2155         COMPARE_NODE_FIELD(typeName);
2156         COMPARE_LOCATION_FIELD(location);
2157
2158         return true;
2159 }
2160
2161 static bool
2162 _equalCollateClause(CollateClause *a, CollateClause *b)
2163 {
2164         COMPARE_NODE_FIELD(arg);
2165         COMPARE_NODE_FIELD(collname);
2166         COMPARE_LOCATION_FIELD(location);
2167
2168         return true;
2169 }
2170
2171 static bool
2172 _equalSortBy(SortBy *a, SortBy *b)
2173 {
2174         COMPARE_NODE_FIELD(node);
2175         COMPARE_SCALAR_FIELD(sortby_dir);
2176         COMPARE_SCALAR_FIELD(sortby_nulls);
2177         COMPARE_NODE_FIELD(useOp);
2178         COMPARE_LOCATION_FIELD(location);
2179
2180         return true;
2181 }
2182
2183 static bool
2184 _equalWindowDef(WindowDef *a, WindowDef *b)
2185 {
2186         COMPARE_STRING_FIELD(name);
2187         COMPARE_STRING_FIELD(refname);
2188         COMPARE_NODE_FIELD(partitionClause);
2189         COMPARE_NODE_FIELD(orderClause);
2190         COMPARE_SCALAR_FIELD(frameOptions);
2191         COMPARE_NODE_FIELD(startOffset);
2192         COMPARE_NODE_FIELD(endOffset);
2193         COMPARE_LOCATION_FIELD(location);
2194
2195         return true;
2196 }
2197
2198 static bool
2199 _equalRangeSubselect(RangeSubselect *a, RangeSubselect *b)
2200 {
2201         COMPARE_NODE_FIELD(subquery);
2202         COMPARE_NODE_FIELD(alias);
2203
2204         return true;
2205 }
2206
2207 static bool
2208 _equalRangeFunction(RangeFunction *a, RangeFunction *b)
2209 {
2210         COMPARE_NODE_FIELD(funccallnode);
2211         COMPARE_NODE_FIELD(alias);
2212         COMPARE_NODE_FIELD(coldeflist);
2213
2214         return true;
2215 }
2216
2217 static bool
2218 _equalIndexElem(IndexElem *a, IndexElem *b)
2219 {
2220         COMPARE_STRING_FIELD(name);
2221         COMPARE_NODE_FIELD(expr);
2222         COMPARE_STRING_FIELD(indexcolname);
2223         COMPARE_NODE_FIELD(collation);
2224         COMPARE_NODE_FIELD(opclass);
2225         COMPARE_SCALAR_FIELD(ordering);
2226         COMPARE_SCALAR_FIELD(nulls_ordering);
2227
2228         return true;
2229 }
2230
2231 static bool
2232 _equalColumnDef(ColumnDef *a, ColumnDef *b)
2233 {
2234         COMPARE_STRING_FIELD(colname);
2235         COMPARE_NODE_FIELD(typeName);
2236         COMPARE_SCALAR_FIELD(inhcount);
2237         COMPARE_SCALAR_FIELD(is_local);
2238         COMPARE_SCALAR_FIELD(is_not_null);
2239         COMPARE_SCALAR_FIELD(is_from_type);
2240         COMPARE_SCALAR_FIELD(storage);
2241         COMPARE_NODE_FIELD(raw_default);
2242         COMPARE_NODE_FIELD(cooked_default);
2243         COMPARE_NODE_FIELD(collClause);
2244         COMPARE_SCALAR_FIELD(collOid);
2245         COMPARE_NODE_FIELD(constraints);
2246
2247         return true;
2248 }
2249
2250 static bool
2251 _equalConstraint(Constraint *a, Constraint *b)
2252 {
2253         COMPARE_SCALAR_FIELD(contype);
2254         COMPARE_STRING_FIELD(conname);
2255         COMPARE_SCALAR_FIELD(deferrable);
2256         COMPARE_SCALAR_FIELD(initdeferred);
2257         COMPARE_LOCATION_FIELD(location);
2258         COMPARE_NODE_FIELD(raw_expr);
2259         COMPARE_STRING_FIELD(cooked_expr);
2260         COMPARE_NODE_FIELD(keys);
2261         COMPARE_NODE_FIELD(exclusions);
2262         COMPARE_NODE_FIELD(options);
2263         COMPARE_STRING_FIELD(indexname);
2264         COMPARE_STRING_FIELD(indexspace);
2265         COMPARE_STRING_FIELD(access_method);
2266         COMPARE_NODE_FIELD(where_clause);
2267         COMPARE_NODE_FIELD(pktable);
2268         COMPARE_NODE_FIELD(fk_attrs);
2269         COMPARE_NODE_FIELD(pk_attrs);
2270         COMPARE_SCALAR_FIELD(fk_matchtype);
2271         COMPARE_SCALAR_FIELD(fk_upd_action);
2272         COMPARE_SCALAR_FIELD(fk_del_action);
2273         COMPARE_SCALAR_FIELD(skip_validation);
2274         COMPARE_SCALAR_FIELD(initially_valid);
2275
2276         return true;
2277 }
2278
2279 static bool
2280 _equalDefElem(DefElem *a, DefElem *b)
2281 {
2282         COMPARE_STRING_FIELD(defnamespace);
2283         COMPARE_STRING_FIELD(defname);
2284         COMPARE_NODE_FIELD(arg);
2285         COMPARE_SCALAR_FIELD(defaction);
2286
2287         return true;
2288 }
2289
2290 static bool
2291 _equalLockingClause(LockingClause *a, LockingClause *b)
2292 {
2293         COMPARE_NODE_FIELD(lockedRels);
2294         COMPARE_SCALAR_FIELD(forUpdate);
2295         COMPARE_SCALAR_FIELD(noWait);
2296
2297         return true;
2298 }
2299
2300 static bool
2301 _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
2302 {
2303         COMPARE_SCALAR_FIELD(rtekind);
2304         COMPARE_SCALAR_FIELD(relid);
2305         COMPARE_SCALAR_FIELD(relkind);
2306         COMPARE_NODE_FIELD(subquery);
2307         COMPARE_SCALAR_FIELD(jointype);
2308         COMPARE_NODE_FIELD(joinaliasvars);
2309         COMPARE_NODE_FIELD(funcexpr);
2310         COMPARE_NODE_FIELD(funccoltypes);
2311         COMPARE_NODE_FIELD(funccoltypmods);
2312         COMPARE_NODE_FIELD(funccolcollations);
2313         COMPARE_NODE_FIELD(values_lists);
2314         COMPARE_NODE_FIELD(values_collations);
2315         COMPARE_STRING_FIELD(ctename);
2316         COMPARE_SCALAR_FIELD(ctelevelsup);
2317         COMPARE_SCALAR_FIELD(self_reference);
2318         COMPARE_NODE_FIELD(ctecoltypes);
2319         COMPARE_NODE_FIELD(ctecoltypmods);
2320         COMPARE_NODE_FIELD(ctecolcollations);
2321         COMPARE_NODE_FIELD(alias);
2322         COMPARE_NODE_FIELD(eref);
2323         COMPARE_SCALAR_FIELD(inh);
2324         COMPARE_SCALAR_FIELD(inFromCl);
2325         COMPARE_SCALAR_FIELD(requiredPerms);
2326         COMPARE_SCALAR_FIELD(checkAsUser);
2327         COMPARE_BITMAPSET_FIELD(selectedCols);
2328         COMPARE_BITMAPSET_FIELD(modifiedCols);
2329
2330         return true;
2331 }
2332
2333 static bool
2334 _equalSortGroupClause(SortGroupClause *a, SortGroupClause *b)
2335 {
2336         COMPARE_SCALAR_FIELD(tleSortGroupRef);
2337         COMPARE_SCALAR_FIELD(eqop);
2338         COMPARE_SCALAR_FIELD(sortop);
2339         COMPARE_SCALAR_FIELD(nulls_first);
2340         COMPARE_SCALAR_FIELD(hashable);
2341
2342         return true;
2343 }
2344
2345 static bool
2346 _equalWindowClause(WindowClause *a, WindowClause *b)
2347 {
2348         COMPARE_STRING_FIELD(name);
2349         COMPARE_STRING_FIELD(refname);
2350         COMPARE_NODE_FIELD(partitionClause);
2351         COMPARE_NODE_FIELD(orderClause);
2352         COMPARE_SCALAR_FIELD(frameOptions);
2353         COMPARE_NODE_FIELD(startOffset);
2354         COMPARE_NODE_FIELD(endOffset);
2355         COMPARE_SCALAR_FIELD(winref);
2356         COMPARE_SCALAR_FIELD(copiedOrder);
2357
2358         return true;
2359 }
2360
2361 static bool
2362 _equalRowMarkClause(RowMarkClause *a, RowMarkClause *b)
2363 {
2364         COMPARE_SCALAR_FIELD(rti);
2365         COMPARE_SCALAR_FIELD(forUpdate);
2366         COMPARE_SCALAR_FIELD(noWait);
2367         COMPARE_SCALAR_FIELD(pushedDown);
2368
2369         return true;
2370 }
2371
2372 static bool
2373 _equalWithClause(WithClause *a, WithClause *b)
2374 {
2375         COMPARE_NODE_FIELD(ctes);
2376         COMPARE_SCALAR_FIELD(recursive);
2377         COMPARE_LOCATION_FIELD(location);
2378
2379         return true;
2380 }
2381
2382 static bool
2383 _equalCommonTableExpr(CommonTableExpr *a, CommonTableExpr *b)
2384 {
2385         COMPARE_STRING_FIELD(ctename);
2386         COMPARE_NODE_FIELD(aliascolnames);
2387         COMPARE_NODE_FIELD(ctequery);
2388         COMPARE_LOCATION_FIELD(location);
2389         COMPARE_SCALAR_FIELD(cterecursive);
2390         COMPARE_SCALAR_FIELD(cterefcount);
2391         COMPARE_NODE_FIELD(ctecolnames);
2392         COMPARE_NODE_FIELD(ctecoltypes);
2393         COMPARE_NODE_FIELD(ctecoltypmods);
2394         COMPARE_NODE_FIELD(ctecolcollations);
2395
2396         return true;
2397 }
2398
2399 static bool
2400 _equalXmlSerialize(XmlSerialize *a, XmlSerialize *b)
2401 {
2402         COMPARE_SCALAR_FIELD(xmloption);
2403         COMPARE_NODE_FIELD(expr);
2404         COMPARE_NODE_FIELD(typeName);
2405         COMPARE_LOCATION_FIELD(location);
2406
2407         return true;
2408 }
2409
2410 /*
2411  * Stuff from pg_list.h
2412  */
2413
2414 static bool
2415 _equalList(List *a, List *b)
2416 {
2417         ListCell   *item_a;
2418         ListCell   *item_b;
2419
2420         /*
2421          * Try to reject by simple scalar checks before grovelling through all the
2422          * list elements...
2423          */
2424         COMPARE_SCALAR_FIELD(type);
2425         COMPARE_SCALAR_FIELD(length);
2426
2427         /*
2428          * We place the switch outside the loop for the sake of efficiency; this
2429          * may not be worth doing...
2430          */
2431         switch (a->type)
2432         {
2433                 case T_List:
2434                         forboth(item_a, a, item_b, b)
2435                         {
2436                                 if (!equal(lfirst(item_a), lfirst(item_b)))
2437                                         return false;
2438                         }
2439                         break;
2440                 case T_IntList:
2441                         forboth(item_a, a, item_b, b)
2442                         {
2443                                 if (lfirst_int(item_a) != lfirst_int(item_b))
2444                                         return false;
2445                         }
2446                         break;
2447                 case T_OidList:
2448                         forboth(item_a, a, item_b, b)
2449                         {
2450                                 if (lfirst_oid(item_a) != lfirst_oid(item_b))
2451                                         return false;
2452                         }
2453                         break;
2454                 default:
2455                         elog(ERROR, "unrecognized list node type: %d",
2456                                  (int) a->type);
2457                         return false;           /* keep compiler quiet */
2458         }
2459
2460         /*
2461          * If we got here, we should have run out of elements of both lists
2462          */
2463         Assert(item_a == NULL);
2464         Assert(item_b == NULL);
2465
2466         return true;
2467 }
2468
2469 /*
2470  * Stuff from value.h
2471  */
2472
2473 static bool
2474 _equalValue(Value *a, Value *b)
2475 {
2476         COMPARE_SCALAR_FIELD(type);
2477
2478         switch (a->type)
2479         {
2480                 case T_Integer:
2481                         COMPARE_SCALAR_FIELD(val.ival);
2482                         break;
2483                 case T_Float:
2484                 case T_String:
2485                 case T_BitString:
2486                         COMPARE_STRING_FIELD(val.str);
2487                         break;
2488                 case T_Null:
2489                         /* nothing to do */
2490                         break;
2491                 default:
2492                         elog(ERROR, "unrecognized node type: %d", (int) a->type);
2493                         break;
2494         }
2495
2496         return true;
2497 }
2498
2499 /*
2500  * equal
2501  *        returns whether two nodes are equal
2502  */
2503 bool
2504 equal(void *a, void *b)
2505 {
2506         bool            retval;
2507
2508         if (a == b)
2509                 return true;
2510
2511         /*
2512          * note that a!=b, so only one of them can be NULL
2513          */
2514         if (a == NULL || b == NULL)
2515                 return false;
2516
2517         /*
2518          * are they the same type of nodes?
2519          */
2520         if (nodeTag(a) != nodeTag(b))
2521                 return false;
2522
2523         switch (nodeTag(a))
2524         {
2525                         /*
2526                          * PRIMITIVE NODES
2527                          */
2528                 case T_Alias:
2529                         retval = _equalAlias(a, b);
2530                         break;
2531                 case T_RangeVar:
2532                         retval = _equalRangeVar(a, b);
2533                         break;
2534                 case T_IntoClause:
2535                         retval = _equalIntoClause(a, b);
2536                         break;
2537                 case T_Var:
2538                         retval = _equalVar(a, b);
2539                         break;
2540                 case T_Const:
2541                         retval = _equalConst(a, b);
2542                         break;
2543                 case T_Param:
2544                         retval = _equalParam(a, b);
2545                         break;
2546                 case T_Aggref:
2547                         retval = _equalAggref(a, b);
2548                         break;
2549                 case T_WindowFunc:
2550                         retval = _equalWindowFunc(a, b);
2551                         break;
2552                 case T_ArrayRef:
2553                         retval = _equalArrayRef(a, b);
2554                         break;
2555                 case T_FuncExpr:
2556                         retval = _equalFuncExpr(a, b);
2557                         break;
2558                 case T_NamedArgExpr:
2559                         retval = _equalNamedArgExpr(a, b);
2560                         break;
2561                 case T_OpExpr:
2562                         retval = _equalOpExpr(a, b);
2563                         break;
2564                 case T_DistinctExpr:
2565                         retval = _equalDistinctExpr(a, b);
2566                         break;
2567                 case T_NullIfExpr:
2568                         retval = _equalNullIfExpr(a, b);
2569                         break;
2570                 case T_ScalarArrayOpExpr:
2571                         retval = _equalScalarArrayOpExpr(a, b);
2572                         break;
2573                 case T_BoolExpr:
2574                         retval = _equalBoolExpr(a, b);
2575                         break;
2576                 case T_SubLink:
2577                         retval = _equalSubLink(a, b);
2578                         break;
2579                 case T_SubPlan:
2580                         retval = _equalSubPlan(a, b);
2581                         break;
2582                 case T_AlternativeSubPlan:
2583                         retval = _equalAlternativeSubPlan(a, b);
2584                         break;
2585                 case T_FieldSelect:
2586                         retval = _equalFieldSelect(a, b);
2587                         break;
2588                 case T_FieldStore:
2589                         retval = _equalFieldStore(a, b);
2590                         break;
2591                 case T_RelabelType:
2592                         retval = _equalRelabelType(a, b);
2593                         break;
2594                 case T_CoerceViaIO:
2595                         retval = _equalCoerceViaIO(a, b);
2596                         break;
2597                 case T_ArrayCoerceExpr:
2598                         retval = _equalArrayCoerceExpr(a, b);
2599                         break;
2600                 case T_ConvertRowtypeExpr:
2601                         retval = _equalConvertRowtypeExpr(a, b);
2602                         break;
2603                 case T_CollateExpr:
2604                         retval = _equalCollateExpr(a, b);
2605                         break;
2606                 case T_CaseExpr:
2607                         retval = _equalCaseExpr(a, b);
2608                         break;
2609                 case T_CaseWhen:
2610                         retval = _equalCaseWhen(a, b);
2611                         break;
2612                 case T_CaseTestExpr:
2613                         retval = _equalCaseTestExpr(a, b);
2614                         break;
2615                 case T_ArrayExpr:
2616                         retval = _equalArrayExpr(a, b);
2617                         break;
2618                 case T_RowExpr:
2619                         retval = _equalRowExpr(a, b);
2620                         break;
2621                 case T_RowCompareExpr:
2622                         retval = _equalRowCompareExpr(a, b);
2623                         break;
2624                 case T_CoalesceExpr:
2625                         retval = _equalCoalesceExpr(a, b);
2626                         break;
2627                 case T_MinMaxExpr:
2628                         retval = _equalMinMaxExpr(a, b);
2629                         break;
2630                 case T_XmlExpr:
2631                         retval = _equalXmlExpr(a, b);
2632                         break;
2633                 case T_NullTest:
2634                         retval = _equalNullTest(a, b);
2635                         break;
2636                 case T_BooleanTest:
2637                         retval = _equalBooleanTest(a, b);
2638                         break;
2639                 case T_CoerceToDomain:
2640                         retval = _equalCoerceToDomain(a, b);
2641                         break;
2642                 case T_CoerceToDomainValue:
2643                         retval = _equalCoerceToDomainValue(a, b);
2644                         break;
2645                 case T_SetToDefault:
2646                         retval = _equalSetToDefault(a, b);
2647                         break;
2648                 case T_CurrentOfExpr:
2649                         retval = _equalCurrentOfExpr(a, b);
2650                         break;
2651                 case T_TargetEntry:
2652                         retval = _equalTargetEntry(a, b);
2653                         break;
2654                 case T_RangeTblRef:
2655                         retval = _equalRangeTblRef(a, b);
2656                         break;
2657                 case T_FromExpr:
2658                         retval = _equalFromExpr(a, b);
2659                         break;
2660                 case T_JoinExpr:
2661                         retval = _equalJoinExpr(a, b);
2662                         break;
2663
2664                         /*
2665                          * RELATION NODES
2666                          */
2667                 case T_PathKey:
2668                         retval = _equalPathKey(a, b);
2669                         break;
2670                 case T_RestrictInfo:
2671                         retval = _equalRestrictInfo(a, b);
2672                         break;
2673                 case T_PlaceHolderVar:
2674                         retval = _equalPlaceHolderVar(a, b);
2675                         break;
2676                 case T_SpecialJoinInfo:
2677                         retval = _equalSpecialJoinInfo(a, b);
2678                         break;
2679                 case T_AppendRelInfo:
2680                         retval = _equalAppendRelInfo(a, b);
2681                         break;
2682                 case T_PlaceHolderInfo:
2683                         retval = _equalPlaceHolderInfo(a, b);
2684                         break;
2685
2686                 case T_List:
2687                 case T_IntList:
2688                 case T_OidList:
2689                         retval = _equalList(a, b);
2690                         break;
2691
2692                 case T_Integer:
2693                 case T_Float:
2694                 case T_String:
2695                 case T_BitString:
2696                 case T_Null:
2697                         retval = _equalValue(a, b);
2698                         break;
2699
2700                         /*
2701                          * PARSE NODES
2702                          */
2703                 case T_Query:
2704                         retval = _equalQuery(a, b);
2705                         break;
2706                 case T_InsertStmt:
2707                         retval = _equalInsertStmt(a, b);
2708                         break;
2709                 case T_DeleteStmt:
2710                         retval = _equalDeleteStmt(a, b);
2711                         break;
2712                 case T_UpdateStmt:
2713                         retval = _equalUpdateStmt(a, b);
2714                         break;
2715                 case T_SelectStmt:
2716                         retval = _equalSelectStmt(a, b);
2717                         break;
2718                 case T_SetOperationStmt:
2719                         retval = _equalSetOperationStmt(a, b);
2720                         break;
2721                 case T_AlterTableStmt:
2722                         retval = _equalAlterTableStmt(a, b);
2723                         break;
2724                 case T_AlterTableCmd:
2725                         retval = _equalAlterTableCmd(a, b);
2726                         break;
2727                 case T_AlterDomainStmt:
2728                         retval = _equalAlterDomainStmt(a, b);
2729                         break;
2730                 case T_GrantStmt:
2731                         retval = _equalGrantStmt(a, b);
2732                         break;
2733                 case T_GrantRoleStmt:
2734                         retval = _equalGrantRoleStmt(a, b);
2735                         break;
2736                 case T_AlterDefaultPrivilegesStmt:
2737                         retval = _equalAlterDefaultPrivilegesStmt(a, b);
2738                         break;
2739                 case T_DeclareCursorStmt:
2740                         retval = _equalDeclareCursorStmt(a, b);
2741                         break;
2742                 case T_ClosePortalStmt:
2743                         retval = _equalClosePortalStmt(a, b);
2744                         break;
2745                 case T_ClusterStmt:
2746                         retval = _equalClusterStmt(a, b);
2747                         break;
2748                 case T_CopyStmt:
2749                         retval = _equalCopyStmt(a, b);
2750                         break;
2751                 case T_CreateStmt:
2752                         retval = _equalCreateStmt(a, b);
2753                         break;
2754                 case T_InhRelation:
2755                         retval = _equalInhRelation(a, b);
2756                         break;
2757                 case T_DefineStmt:
2758                         retval = _equalDefineStmt(a, b);
2759                         break;
2760                 case T_DropStmt:
2761                         retval = _equalDropStmt(a, b);
2762                         break;
2763                 case T_TruncateStmt:
2764                         retval = _equalTruncateStmt(a, b);
2765                         break;
2766                 case T_CommentStmt:
2767                         retval = _equalCommentStmt(a, b);
2768                         break;
2769                 case T_SecLabelStmt:
2770                         retval = _equalSecLabelStmt(a, b);
2771                         break;
2772                 case T_FetchStmt:
2773                         retval = _equalFetchStmt(a, b);
2774                         break;
2775                 case T_IndexStmt:
2776                         retval = _equalIndexStmt(a, b);
2777                         break;
2778                 case T_CreateFunctionStmt:
2779                         retval = _equalCreateFunctionStmt(a, b);
2780                         break;
2781                 case T_FunctionParameter:
2782                         retval = _equalFunctionParameter(a, b);
2783                         break;
2784                 case T_AlterFunctionStmt:
2785                         retval = _equalAlterFunctionStmt(a, b);
2786                         break;
2787                 case T_RemoveFuncStmt:
2788                         retval = _equalRemoveFuncStmt(a, b);
2789                         break;
2790                 case T_DoStmt:
2791                         retval = _equalDoStmt(a, b);
2792                         break;
2793                 case T_RemoveOpClassStmt:
2794                         retval = _equalRemoveOpClassStmt(a, b);
2795                         break;
2796                 case T_RemoveOpFamilyStmt:
2797                         retval = _equalRemoveOpFamilyStmt(a, b);
2798                         break;
2799                 case T_RenameStmt:
2800                         retval = _equalRenameStmt(a, b);
2801                         break;
2802                 case T_AlterObjectSchemaStmt:
2803                         retval = _equalAlterObjectSchemaStmt(a, b);
2804                         break;
2805                 case T_AlterOwnerStmt:
2806                         retval = _equalAlterOwnerStmt(a, b);
2807                         break;
2808                 case T_RuleStmt:
2809                         retval = _equalRuleStmt(a, b);
2810                         break;
2811                 case T_NotifyStmt:
2812                         retval = _equalNotifyStmt(a, b);
2813                         break;
2814                 case T_ListenStmt:
2815                         retval = _equalListenStmt(a, b);
2816                         break;
2817                 case T_UnlistenStmt:
2818                         retval = _equalUnlistenStmt(a, b);
2819                         break;
2820                 case T_TransactionStmt:
2821                         retval = _equalTransactionStmt(a, b);
2822                         break;
2823                 case T_CompositeTypeStmt:
2824                         retval = _equalCompositeTypeStmt(a, b);
2825                         break;
2826                 case T_CreateEnumStmt:
2827                         retval = _equalCreateEnumStmt(a, b);
2828                         break;
2829                 case T_AlterEnumStmt:
2830                         retval = _equalAlterEnumStmt(a, b);
2831                         break;
2832                 case T_ViewStmt:
2833                         retval = _equalViewStmt(a, b);
2834                         break;
2835                 case T_LoadStmt:
2836                         retval = _equalLoadStmt(a, b);
2837                         break;
2838                 case T_CreateDomainStmt:
2839                         retval = _equalCreateDomainStmt(a, b);
2840                         break;
2841                 case T_CreateOpClassStmt:
2842                         retval = _equalCreateOpClassStmt(a, b);
2843                         break;
2844                 case T_CreateOpClassItem:
2845                         retval = _equalCreateOpClassItem(a, b);
2846                         break;
2847                 case T_CreateOpFamilyStmt:
2848                         retval = _equalCreateOpFamilyStmt(a, b);
2849                         break;
2850                 case T_AlterOpFamilyStmt:
2851                         retval = _equalAlterOpFamilyStmt(a, b);
2852                         break;
2853                 case T_CreatedbStmt:
2854                         retval = _equalCreatedbStmt(a, b);
2855                         break;
2856                 case T_AlterDatabaseStmt:
2857                         retval = _equalAlterDatabaseStmt(a, b);
2858                         break;
2859                 case T_AlterDatabaseSetStmt:
2860                         retval = _equalAlterDatabaseSetStmt(a, b);
2861                         break;
2862                 case T_DropdbStmt:
2863                         retval = _equalDropdbStmt(a, b);
2864                         break;
2865                 case T_VacuumStmt:
2866                         retval = _equalVacuumStmt(a, b);
2867                         break;
2868                 case T_ExplainStmt:
2869                         retval = _equalExplainStmt(a, b);
2870                         break;
2871                 case T_CreateSeqStmt:
2872                         retval = _equalCreateSeqStmt(a, b);
2873                         break;
2874                 case T_AlterSeqStmt:
2875                         retval = _equalAlterSeqStmt(a, b);
2876                         break;
2877                 case T_VariableSetStmt:
2878                         retval = _equalVariableSetStmt(a, b);
2879                         break;
2880                 case T_VariableShowStmt:
2881                         retval = _equalVariableShowStmt(a, b);
2882                         break;
2883                 case T_DiscardStmt:
2884                         retval = _equalDiscardStmt(a, b);
2885                         break;
2886                 case T_CreateTableSpaceStmt:
2887                         retval = _equalCreateTableSpaceStmt(a, b);
2888                         break;
2889                 case T_DropTableSpaceStmt:
2890                         retval = _equalDropTableSpaceStmt(a, b);
2891                         break;
2892                 case T_AlterTableSpaceOptionsStmt:
2893                         retval = _equalAlterTableSpaceOptionsStmt(a, b);
2894                         break;
2895                 case T_CreateExtensionStmt:
2896                         retval = _equalCreateExtensionStmt(a, b);
2897                         break;
2898                 case T_AlterExtensionStmt:
2899                         retval = _equalAlterExtensionStmt(a, b);
2900                         break;
2901                 case T_AlterExtensionContentsStmt:
2902                         retval = _equalAlterExtensionContentsStmt(a, b);
2903                         break;
2904                 case T_CreateFdwStmt:
2905                         retval = _equalCreateFdwStmt(a, b);
2906                         break;
2907                 case T_AlterFdwStmt:
2908                         retval = _equalAlterFdwStmt(a, b);
2909                         break;
2910                 case T_DropFdwStmt:
2911                         retval = _equalDropFdwStmt(a, b);
2912                         break;
2913                 case T_CreateForeignServerStmt:
2914                         retval = _equalCreateForeignServerStmt(a, b);
2915                         break;
2916                 case T_AlterForeignServerStmt:
2917                         retval = _equalAlterForeignServerStmt(a, b);
2918                         break;
2919                 case T_DropForeignServerStmt:
2920                         retval = _equalDropForeignServerStmt(a, b);
2921                         break;
2922                 case T_CreateUserMappingStmt:
2923                         retval = _equalCreateUserMappingStmt(a, b);
2924                         break;
2925                 case T_AlterUserMappingStmt:
2926                         retval = _equalAlterUserMappingStmt(a, b);
2927                         break;
2928                 case T_DropUserMappingStmt:
2929                         retval = _equalDropUserMappingStmt(a, b);
2930                         break;
2931                 case T_CreateForeignTableStmt:
2932                         retval = _equalCreateForeignTableStmt(a, b);
2933                         break;
2934                 case T_CreateTrigStmt:
2935                         retval = _equalCreateTrigStmt(a, b);
2936                         break;
2937                 case T_DropPropertyStmt:
2938                         retval = _equalDropPropertyStmt(a, b);
2939                         break;
2940                 case T_CreatePLangStmt:
2941                         retval = _equalCreatePLangStmt(a, b);
2942                         break;
2943                 case T_DropPLangStmt:
2944                         retval = _equalDropPLangStmt(a, b);
2945                         break;
2946                 case T_CreateRoleStmt:
2947                         retval = _equalCreateRoleStmt(a, b);
2948                         break;
2949                 case T_AlterRoleStmt:
2950                         retval = _equalAlterRoleStmt(a, b);
2951                         break;
2952                 case T_AlterRoleSetStmt:
2953                         retval = _equalAlterRoleSetStmt(a, b);
2954                         break;
2955                 case T_DropRoleStmt:
2956                         retval = _equalDropRoleStmt(a, b);
2957                         break;
2958                 case T_LockStmt:
2959                         retval = _equalLockStmt(a, b);
2960                         break;
2961                 case T_ConstraintsSetStmt:
2962                         retval = _equalConstraintsSetStmt(a, b);
2963                         break;
2964                 case T_ReindexStmt:
2965                         retval = _equalReindexStmt(a, b);
2966                         break;
2967                 case T_CheckPointStmt:
2968                         retval = true;
2969                         break;
2970                 case T_CreateSchemaStmt:
2971                         retval = _equalCreateSchemaStmt(a, b);
2972                         break;
2973                 case T_CreateConversionStmt:
2974                         retval = _equalCreateConversionStmt(a, b);
2975                         break;
2976                 case T_CreateCastStmt:
2977                         retval = _equalCreateCastStmt(a, b);
2978                         break;
2979                 case T_DropCastStmt:
2980                         retval = _equalDropCastStmt(a, b);
2981                         break;
2982                 case T_PrepareStmt:
2983                         retval = _equalPrepareStmt(a, b);
2984                         break;
2985                 case T_ExecuteStmt:
2986                         retval = _equalExecuteStmt(a, b);
2987                         break;
2988                 case T_DeallocateStmt:
2989                         retval = _equalDeallocateStmt(a, b);
2990                         break;
2991                 case T_DropOwnedStmt:
2992                         retval = _equalDropOwnedStmt(a, b);
2993                         break;
2994                 case T_ReassignOwnedStmt:
2995                         retval = _equalReassignOwnedStmt(a, b);
2996                         break;
2997                 case T_AlterTSDictionaryStmt:
2998                         retval = _equalAlterTSDictionaryStmt(a, b);
2999                         break;
3000                 case T_AlterTSConfigurationStmt:
3001                         retval = _equalAlterTSConfigurationStmt(a, b);
3002                         break;
3003
3004                 case T_A_Expr:
3005                         retval = _equalAExpr(a, b);
3006                         break;
3007                 case T_ColumnRef:
3008                         retval = _equalColumnRef(a, b);
3009                         break;
3010                 case T_ParamRef:
3011                         retval = _equalParamRef(a, b);
3012                         break;
3013                 case T_A_Const:
3014                         retval = _equalAConst(a, b);
3015                         break;
3016                 case T_FuncCall:
3017                         retval = _equalFuncCall(a, b);
3018                         break;
3019                 case T_A_Star:
3020                         retval = _equalAStar(a, b);
3021                         break;
3022                 case T_A_Indices:
3023                         retval = _equalAIndices(a, b);
3024                         break;
3025                 case T_A_Indirection:
3026                         retval = _equalA_Indirection(a, b);
3027                         break;
3028                 case T_A_ArrayExpr:
3029                         retval = _equalA_ArrayExpr(a, b);
3030                         break;
3031                 case T_ResTarget:
3032                         retval = _equalResTarget(a, b);
3033                         break;
3034                 case T_TypeCast:
3035                         retval = _equalTypeCast(a, b);
3036                         break;
3037                 case T_CollateClause:
3038                         retval = _equalCollateClause(a, b);
3039                         break;
3040                 case T_SortBy:
3041                         retval = _equalSortBy(a, b);
3042                         break;
3043                 case T_WindowDef:
3044                         retval = _equalWindowDef(a, b);
3045                         break;
3046                 case T_RangeSubselect:
3047                         retval = _equalRangeSubselect(a, b);
3048                         break;
3049                 case T_RangeFunction:
3050                         retval = _equalRangeFunction(a, b);
3051                         break;
3052                 case T_TypeName:
3053                         retval = _equalTypeName(a, b);
3054                         break;
3055                 case T_IndexElem:
3056                         retval = _equalIndexElem(a, b);
3057                         break;
3058                 case T_ColumnDef:
3059                         retval = _equalColumnDef(a, b);
3060                         break;
3061                 case T_Constraint:
3062                         retval = _equalConstraint(a, b);
3063                         break;
3064                 case T_DefElem:
3065                         retval = _equalDefElem(a, b);
3066                         break;
3067                 case T_LockingClause:
3068                         retval = _equalLockingClause(a, b);
3069                         break;
3070                 case T_RangeTblEntry:
3071                         retval = _equalRangeTblEntry(a, b);
3072                         break;
3073                 case T_SortGroupClause:
3074                         retval = _equalSortGroupClause(a, b);
3075                         break;
3076                 case T_WindowClause:
3077                         retval = _equalWindowClause(a, b);
3078                         break;
3079                 case T_RowMarkClause:
3080                         retval = _equalRowMarkClause(a, b);
3081                         break;
3082                 case T_WithClause:
3083                         retval = _equalWithClause(a, b);
3084                         break;
3085                 case T_CommonTableExpr:
3086                         retval = _equalCommonTableExpr(a, b);
3087                         break;
3088                 case T_PrivGrantee:
3089                         retval = _equalPrivGrantee(a, b);
3090                         break;
3091                 case T_FuncWithArgs:
3092                         retval = _equalFuncWithArgs(a, b);
3093                         break;
3094                 case T_AccessPriv:
3095                         retval = _equalAccessPriv(a, b);
3096                         break;
3097                 case T_XmlSerialize:
3098                         retval = _equalXmlSerialize(a, b);
3099                         break;
3100
3101                 default:
3102                         elog(ERROR, "unrecognized node type: %d",
3103                                  (int) nodeTag(a));
3104                         retval = false;         /* keep compiler quiet */
3105                         break;
3106         }
3107
3108         return retval;
3109 }