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