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