OSDN Git Service

665d4833be3619a80c88b9cf3abbf91075014e3f
[pg-rex/syncrep.git] / 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  *
17  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
18  * Portions Copyright (c) 1994, Regents of the University of California
19  *
20  * IDENTIFICATION
21  *        $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.281 2006/08/12 02:52:04 tgl Exp $
22  *
23  *-------------------------------------------------------------------------
24  */
25
26 #include "postgres.h"
27
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
30
31
32 /*
33  * Macros to simplify comparison of different kinds of fields.  Use these
34  * wherever possible to reduce the chance for silly typos.      Note that these
35  * hard-wire the convention that the local variables in an Equal routine are
36  * named 'a' and 'b'.
37  */
38
39 /* Compare a simple scalar field (int, float, bool, enum, etc) */
40 #define COMPARE_SCALAR_FIELD(fldname) \
41         do { \
42                 if (a->fldname != b->fldname) \
43                         return false; \
44         } while (0)
45
46 /* Compare a field that is a pointer to some kind of Node or Node tree */
47 #define COMPARE_NODE_FIELD(fldname) \
48         do { \
49                 if (!equal(a->fldname, b->fldname)) \
50                         return false; \
51         } while (0)
52
53 /* Compare a field that is a pointer to a Bitmapset */
54 #define COMPARE_BITMAPSET_FIELD(fldname) \
55         do { \
56                 if (!bms_equal(a->fldname, b->fldname)) \
57                         return false; \
58         } while (0)
59
60 /* Compare a field that is a pointer to a C string, or perhaps NULL */
61 #define COMPARE_STRING_FIELD(fldname) \
62         do { \
63                 if (!equalstr(a->fldname, b->fldname)) \
64                         return false; \
65         } while (0)
66
67 /* Macro for comparing string fields that might be NULL */
68 #define equalstr(a, b)  \
69         (((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
70
71 /* Compare a field that is a pointer to a simple palloc'd object of size sz */
72 #define COMPARE_POINTER_FIELD(fldname, sz) \
73         do { \
74                 if (memcmp(a->fldname, b->fldname, (sz)) != 0) \
75                         return false; \
76         } while (0)
77
78
79 /*
80  *      Stuff from primnodes.h
81  */
82
83 static bool
84 _equalAlias(Alias *a, Alias *b)
85 {
86         COMPARE_STRING_FIELD(aliasname);
87         COMPARE_NODE_FIELD(colnames);
88
89         return true;
90 }
91
92 static bool
93 _equalRangeVar(RangeVar *a, RangeVar *b)
94 {
95         COMPARE_STRING_FIELD(catalogname);
96         COMPARE_STRING_FIELD(schemaname);
97         COMPARE_STRING_FIELD(relname);
98         COMPARE_SCALAR_FIELD(inhOpt);
99         COMPARE_SCALAR_FIELD(istemp);
100         COMPARE_NODE_FIELD(alias);
101
102         return true;
103 }
104
105 /*
106  * We don't need an _equalExpr because Expr is an abstract supertype which
107  * should never actually get instantiated.      Also, since it has no common
108  * fields except NodeTag, there's no need for a helper routine to factor
109  * out comparing the common fields...
110  */
111
112 static bool
113 _equalVar(Var *a, Var *b)
114 {
115         COMPARE_SCALAR_FIELD(varno);
116         COMPARE_SCALAR_FIELD(varattno);
117         COMPARE_SCALAR_FIELD(vartype);
118         COMPARE_SCALAR_FIELD(vartypmod);
119         COMPARE_SCALAR_FIELD(varlevelsup);
120         COMPARE_SCALAR_FIELD(varnoold);
121         COMPARE_SCALAR_FIELD(varoattno);
122
123         return true;
124 }
125
126 static bool
127 _equalConst(Const *a, Const *b)
128 {
129         COMPARE_SCALAR_FIELD(consttype);
130         COMPARE_SCALAR_FIELD(constlen);
131         COMPARE_SCALAR_FIELD(constisnull);
132         COMPARE_SCALAR_FIELD(constbyval);
133
134         /*
135          * We treat all NULL constants of the same type as equal. Someday this
136          * might need to change?  But datumIsEqual doesn't work on nulls, so...
137          */
138         if (a->constisnull)
139                 return true;
140         return datumIsEqual(a->constvalue, b->constvalue,
141                                                 a->constbyval, a->constlen);
142 }
143
144 static bool
145 _equalParam(Param *a, Param *b)
146 {
147         COMPARE_SCALAR_FIELD(paramkind);
148         COMPARE_SCALAR_FIELD(paramid);
149         COMPARE_SCALAR_FIELD(paramtype);
150
151         return true;
152 }
153
154 static bool
155 _equalAggref(Aggref *a, Aggref *b)
156 {
157         COMPARE_SCALAR_FIELD(aggfnoid);
158         COMPARE_SCALAR_FIELD(aggtype);
159         COMPARE_NODE_FIELD(args);
160         COMPARE_SCALAR_FIELD(agglevelsup);
161         COMPARE_SCALAR_FIELD(aggstar);
162         COMPARE_SCALAR_FIELD(aggdistinct);
163
164         return true;
165 }
166
167 static bool
168 _equalArrayRef(ArrayRef *a, ArrayRef *b)
169 {
170         COMPARE_SCALAR_FIELD(refrestype);
171         COMPARE_SCALAR_FIELD(refarraytype);
172         COMPARE_SCALAR_FIELD(refelemtype);
173         COMPARE_NODE_FIELD(refupperindexpr);
174         COMPARE_NODE_FIELD(reflowerindexpr);
175         COMPARE_NODE_FIELD(refexpr);
176         COMPARE_NODE_FIELD(refassgnexpr);
177
178         return true;
179 }
180
181 static bool
182 _equalFuncExpr(FuncExpr *a, FuncExpr *b)
183 {
184         COMPARE_SCALAR_FIELD(funcid);
185         COMPARE_SCALAR_FIELD(funcresulttype);
186         COMPARE_SCALAR_FIELD(funcretset);
187
188         /*
189          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
190          * that are equal() to both explicit and implicit coercions.
191          */
192         if (a->funcformat != b->funcformat &&
193                 a->funcformat != COERCE_DONTCARE &&
194                 b->funcformat != COERCE_DONTCARE)
195                 return false;
196
197         COMPARE_NODE_FIELD(args);
198
199         return true;
200 }
201
202 static bool
203 _equalOpExpr(OpExpr *a, OpExpr *b)
204 {
205         COMPARE_SCALAR_FIELD(opno);
206
207         /*
208          * Special-case opfuncid: it is allowable for it to differ if one node
209          * contains zero and the other doesn't.  This just means that the one node
210          * isn't as far along in the parse/plan pipeline and hasn't had the
211          * opfuncid cache filled yet.
212          */
213         if (a->opfuncid != b->opfuncid &&
214                 a->opfuncid != 0 &&
215                 b->opfuncid != 0)
216                 return false;
217
218         COMPARE_SCALAR_FIELD(opresulttype);
219         COMPARE_SCALAR_FIELD(opretset);
220         COMPARE_NODE_FIELD(args);
221
222         return true;
223 }
224
225 static bool
226 _equalDistinctExpr(DistinctExpr *a, DistinctExpr *b)
227 {
228         COMPARE_SCALAR_FIELD(opno);
229
230         /*
231          * Special-case opfuncid: it is allowable for it to differ if one node
232          * contains zero and the other doesn't.  This just means that the one node
233          * isn't as far along in the parse/plan pipeline and hasn't had the
234          * opfuncid cache filled yet.
235          */
236         if (a->opfuncid != b->opfuncid &&
237                 a->opfuncid != 0 &&
238                 b->opfuncid != 0)
239                 return false;
240
241         COMPARE_SCALAR_FIELD(opresulttype);
242         COMPARE_SCALAR_FIELD(opretset);
243         COMPARE_NODE_FIELD(args);
244
245         return true;
246 }
247
248 static bool
249 _equalScalarArrayOpExpr(ScalarArrayOpExpr *a, ScalarArrayOpExpr *b)
250 {
251         COMPARE_SCALAR_FIELD(opno);
252
253         /*
254          * Special-case opfuncid: it is allowable for it to differ if one node
255          * contains zero and the other doesn't.  This just means that the one node
256          * isn't as far along in the parse/plan pipeline and hasn't had the
257          * opfuncid cache filled yet.
258          */
259         if (a->opfuncid != b->opfuncid &&
260                 a->opfuncid != 0 &&
261                 b->opfuncid != 0)
262                 return false;
263
264         COMPARE_SCALAR_FIELD(useOr);
265         COMPARE_NODE_FIELD(args);
266
267         return true;
268 }
269
270 static bool
271 _equalBoolExpr(BoolExpr *a, BoolExpr *b)
272 {
273         COMPARE_SCALAR_FIELD(boolop);
274         COMPARE_NODE_FIELD(args);
275
276         return true;
277 }
278
279 static bool
280 _equalSubLink(SubLink *a, SubLink *b)
281 {
282         COMPARE_SCALAR_FIELD(subLinkType);
283         COMPARE_NODE_FIELD(testexpr);
284         COMPARE_NODE_FIELD(operName);
285         COMPARE_NODE_FIELD(subselect);
286
287         return true;
288 }
289
290 static bool
291 _equalSubPlan(SubPlan *a, SubPlan *b)
292 {
293         COMPARE_SCALAR_FIELD(subLinkType);
294         COMPARE_NODE_FIELD(testexpr);
295         COMPARE_NODE_FIELD(paramIds);
296         /* should compare plans, but have to settle for comparing plan IDs */
297         COMPARE_SCALAR_FIELD(plan_id);
298         COMPARE_NODE_FIELD(rtable);
299         COMPARE_SCALAR_FIELD(useHashTable);
300         COMPARE_SCALAR_FIELD(unknownEqFalse);
301         COMPARE_NODE_FIELD(setParam);
302         COMPARE_NODE_FIELD(parParam);
303         COMPARE_NODE_FIELD(args);
304
305         return true;
306 }
307
308 static bool
309 _equalFieldSelect(FieldSelect *a, FieldSelect *b)
310 {
311         COMPARE_NODE_FIELD(arg);
312         COMPARE_SCALAR_FIELD(fieldnum);
313         COMPARE_SCALAR_FIELD(resulttype);
314         COMPARE_SCALAR_FIELD(resulttypmod);
315
316         return true;
317 }
318
319 static bool
320 _equalFieldStore(FieldStore *a, FieldStore *b)
321 {
322         COMPARE_NODE_FIELD(arg);
323         COMPARE_NODE_FIELD(newvals);
324         COMPARE_NODE_FIELD(fieldnums);
325         COMPARE_SCALAR_FIELD(resulttype);
326
327         return true;
328 }
329
330 static bool
331 _equalRelabelType(RelabelType *a, RelabelType *b)
332 {
333         COMPARE_NODE_FIELD(arg);
334         COMPARE_SCALAR_FIELD(resulttype);
335         COMPARE_SCALAR_FIELD(resulttypmod);
336
337         /*
338          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
339          * that are equal() to both explicit and implicit coercions.
340          */
341         if (a->relabelformat != b->relabelformat &&
342                 a->relabelformat != COERCE_DONTCARE &&
343                 b->relabelformat != COERCE_DONTCARE)
344                 return false;
345
346         return true;
347 }
348
349 static bool
350 _equalConvertRowtypeExpr(ConvertRowtypeExpr *a, ConvertRowtypeExpr *b)
351 {
352         COMPARE_NODE_FIELD(arg);
353         COMPARE_SCALAR_FIELD(resulttype);
354
355         /*
356          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
357          * that are equal() to both explicit and implicit coercions.
358          */
359         if (a->convertformat != b->convertformat &&
360                 a->convertformat != COERCE_DONTCARE &&
361                 b->convertformat != COERCE_DONTCARE)
362                 return false;
363
364         return true;
365 }
366
367 static bool
368 _equalCaseExpr(CaseExpr *a, CaseExpr *b)
369 {
370         COMPARE_SCALAR_FIELD(casetype);
371         COMPARE_NODE_FIELD(arg);
372         COMPARE_NODE_FIELD(args);
373         COMPARE_NODE_FIELD(defresult);
374
375         return true;
376 }
377
378 static bool
379 _equalCaseWhen(CaseWhen *a, CaseWhen *b)
380 {
381         COMPARE_NODE_FIELD(expr);
382         COMPARE_NODE_FIELD(result);
383
384         return true;
385 }
386
387 static bool
388 _equalCaseTestExpr(CaseTestExpr *a, CaseTestExpr *b)
389 {
390         COMPARE_SCALAR_FIELD(typeId);
391         COMPARE_SCALAR_FIELD(typeMod);
392
393         return true;
394 }
395
396 static bool
397 _equalArrayExpr(ArrayExpr *a, ArrayExpr *b)
398 {
399         COMPARE_SCALAR_FIELD(array_typeid);
400         COMPARE_SCALAR_FIELD(element_typeid);
401         COMPARE_NODE_FIELD(elements);
402         COMPARE_SCALAR_FIELD(multidims);
403
404         return true;
405 }
406
407 static bool
408 _equalRowExpr(RowExpr *a, RowExpr *b)
409 {
410         COMPARE_NODE_FIELD(args);
411         COMPARE_SCALAR_FIELD(row_typeid);
412
413         /*
414          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
415          * that are equal() to both explicit and implicit coercions.
416          */
417         if (a->row_format != b->row_format &&
418                 a->row_format != COERCE_DONTCARE &&
419                 b->row_format != COERCE_DONTCARE)
420                 return false;
421
422         return true;
423 }
424
425 static bool
426 _equalRowCompareExpr(RowCompareExpr *a, RowCompareExpr *b)
427 {
428         COMPARE_SCALAR_FIELD(rctype);
429         COMPARE_NODE_FIELD(opnos);
430         COMPARE_NODE_FIELD(opclasses);
431         COMPARE_NODE_FIELD(largs);
432         COMPARE_NODE_FIELD(rargs);
433
434         return true;
435 }
436
437 static bool
438 _equalCoalesceExpr(CoalesceExpr *a, CoalesceExpr *b)
439 {
440         COMPARE_SCALAR_FIELD(coalescetype);
441         COMPARE_NODE_FIELD(args);
442
443         return true;
444 }
445
446 static bool
447 _equalMinMaxExpr(MinMaxExpr *a, MinMaxExpr *b)
448 {
449         COMPARE_SCALAR_FIELD(minmaxtype);
450         COMPARE_SCALAR_FIELD(op);
451         COMPARE_NODE_FIELD(args);
452
453         return true;
454 }
455
456 static bool
457 _equalNullIfExpr(NullIfExpr *a, NullIfExpr *b)
458 {
459         COMPARE_SCALAR_FIELD(opno);
460
461         /*
462          * Special-case opfuncid: it is allowable for it to differ if one node
463          * contains zero and the other doesn't.  This just means that the one node
464          * isn't as far along in the parse/plan pipeline and hasn't had the
465          * opfuncid cache filled yet.
466          */
467         if (a->opfuncid != b->opfuncid &&
468                 a->opfuncid != 0 &&
469                 b->opfuncid != 0)
470                 return false;
471
472         COMPARE_SCALAR_FIELD(opresulttype);
473         COMPARE_SCALAR_FIELD(opretset);
474         COMPARE_NODE_FIELD(args);
475
476         return true;
477 }
478
479 static bool
480 _equalNullTest(NullTest *a, NullTest *b)
481 {
482         COMPARE_NODE_FIELD(arg);
483         COMPARE_SCALAR_FIELD(nulltesttype);
484
485         return true;
486 }
487
488 static bool
489 _equalBooleanTest(BooleanTest *a, BooleanTest *b)
490 {
491         COMPARE_NODE_FIELD(arg);
492         COMPARE_SCALAR_FIELD(booltesttype);
493
494         return true;
495 }
496
497 static bool
498 _equalCoerceToDomain(CoerceToDomain *a, CoerceToDomain *b)
499 {
500         COMPARE_NODE_FIELD(arg);
501         COMPARE_SCALAR_FIELD(resulttype);
502         COMPARE_SCALAR_FIELD(resulttypmod);
503
504         /*
505          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
506          * that are equal() to both explicit and implicit coercions.
507          */
508         if (a->coercionformat != b->coercionformat &&
509                 a->coercionformat != COERCE_DONTCARE &&
510                 b->coercionformat != COERCE_DONTCARE)
511                 return false;
512
513         return true;
514 }
515
516 static bool
517 _equalCoerceToDomainValue(CoerceToDomainValue *a, CoerceToDomainValue *b)
518 {
519         COMPARE_SCALAR_FIELD(typeId);
520         COMPARE_SCALAR_FIELD(typeMod);
521
522         return true;
523 }
524
525 static bool
526 _equalSetToDefault(SetToDefault *a, SetToDefault *b)
527 {
528         COMPARE_SCALAR_FIELD(typeId);
529         COMPARE_SCALAR_FIELD(typeMod);
530
531         return true;
532 }
533
534 static bool
535 _equalTargetEntry(TargetEntry *a, TargetEntry *b)
536 {
537         COMPARE_NODE_FIELD(expr);
538         COMPARE_SCALAR_FIELD(resno);
539         COMPARE_STRING_FIELD(resname);
540         COMPARE_SCALAR_FIELD(ressortgroupref);
541         COMPARE_SCALAR_FIELD(resorigtbl);
542         COMPARE_SCALAR_FIELD(resorigcol);
543         COMPARE_SCALAR_FIELD(resjunk);
544
545         return true;
546 }
547
548 static bool
549 _equalRangeTblRef(RangeTblRef *a, RangeTblRef *b)
550 {
551         COMPARE_SCALAR_FIELD(rtindex);
552
553         return true;
554 }
555
556 static bool
557 _equalJoinExpr(JoinExpr *a, JoinExpr *b)
558 {
559         COMPARE_SCALAR_FIELD(jointype);
560         COMPARE_SCALAR_FIELD(isNatural);
561         COMPARE_NODE_FIELD(larg);
562         COMPARE_NODE_FIELD(rarg);
563         COMPARE_NODE_FIELD(using);
564         COMPARE_NODE_FIELD(quals);
565         COMPARE_NODE_FIELD(alias);
566         COMPARE_SCALAR_FIELD(rtindex);
567
568         return true;
569 }
570
571 static bool
572 _equalFromExpr(FromExpr *a, FromExpr *b)
573 {
574         COMPARE_NODE_FIELD(fromlist);
575         COMPARE_NODE_FIELD(quals);
576
577         return true;
578 }
579
580
581 /*
582  * Stuff from relation.h
583  */
584
585 static bool
586 _equalPathKeyItem(PathKeyItem *a, PathKeyItem *b)
587 {
588         COMPARE_NODE_FIELD(key);
589         COMPARE_SCALAR_FIELD(sortop);
590
591         return true;
592 }
593
594 static bool
595 _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
596 {
597         COMPARE_NODE_FIELD(clause);
598         COMPARE_SCALAR_FIELD(is_pushed_down);
599         COMPARE_SCALAR_FIELD(outerjoin_delayed);
600         COMPARE_BITMAPSET_FIELD(required_relids);
601
602         /*
603          * We ignore all the remaining fields, since they may not be set yet, and
604          * should be derivable from the clause anyway.
605          */
606
607         return true;
608 }
609
610 static bool
611 _equalOuterJoinInfo(OuterJoinInfo *a, OuterJoinInfo *b)
612 {
613         COMPARE_BITMAPSET_FIELD(min_lefthand);
614         COMPARE_BITMAPSET_FIELD(min_righthand);
615         COMPARE_SCALAR_FIELD(is_full_join);
616         COMPARE_SCALAR_FIELD(lhs_strict);
617
618         return true;
619 }
620
621 static bool
622 _equalInClauseInfo(InClauseInfo *a, InClauseInfo *b)
623 {
624         COMPARE_BITMAPSET_FIELD(lefthand);
625         COMPARE_BITMAPSET_FIELD(righthand);
626         COMPARE_NODE_FIELD(sub_targetlist);
627
628         return true;
629 }
630
631 static bool
632 _equalAppendRelInfo(AppendRelInfo *a, AppendRelInfo *b)
633 {
634         COMPARE_SCALAR_FIELD(parent_relid);
635         COMPARE_SCALAR_FIELD(child_relid);
636         COMPARE_SCALAR_FIELD(parent_reltype);
637         COMPARE_SCALAR_FIELD(child_reltype);
638         COMPARE_NODE_FIELD(col_mappings);
639         COMPARE_NODE_FIELD(translated_vars);
640         COMPARE_SCALAR_FIELD(parent_reloid);
641
642         return true;
643 }
644
645
646 /*
647  * Stuff from parsenodes.h
648  */
649
650 static bool
651 _equalQuery(Query *a, Query *b)
652 {
653         COMPARE_SCALAR_FIELD(commandType);
654         COMPARE_SCALAR_FIELD(querySource);
655         COMPARE_SCALAR_FIELD(canSetTag);
656         COMPARE_NODE_FIELD(utilityStmt);
657         COMPARE_SCALAR_FIELD(resultRelation);
658         COMPARE_NODE_FIELD(into);
659         COMPARE_NODE_FIELD(intoOptions);
660         COMPARE_SCALAR_FIELD(intoOnCommit);
661         COMPARE_STRING_FIELD(intoTableSpaceName);
662         COMPARE_SCALAR_FIELD(hasAggs);
663         COMPARE_SCALAR_FIELD(hasSubLinks);
664         COMPARE_NODE_FIELD(rtable);
665         COMPARE_NODE_FIELD(jointree);
666         COMPARE_NODE_FIELD(targetList);
667         COMPARE_NODE_FIELD(returningList);
668         COMPARE_NODE_FIELD(groupClause);
669         COMPARE_NODE_FIELD(havingQual);
670         COMPARE_NODE_FIELD(distinctClause);
671         COMPARE_NODE_FIELD(sortClause);
672         COMPARE_NODE_FIELD(limitOffset);
673         COMPARE_NODE_FIELD(limitCount);
674         COMPARE_NODE_FIELD(rowMarks);
675         COMPARE_NODE_FIELD(setOperations);
676         COMPARE_NODE_FIELD(resultRelations);
677         COMPARE_NODE_FIELD(returningLists);
678
679         return true;
680 }
681
682 static bool
683 _equalInsertStmt(InsertStmt *a, InsertStmt *b)
684 {
685         COMPARE_NODE_FIELD(relation);
686         COMPARE_NODE_FIELD(cols);
687         COMPARE_NODE_FIELD(selectStmt);
688         COMPARE_NODE_FIELD(returningList);
689
690         return true;
691 }
692
693 static bool
694 _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
695 {
696         COMPARE_NODE_FIELD(relation);
697         COMPARE_NODE_FIELD(usingClause);
698         COMPARE_NODE_FIELD(whereClause);
699         COMPARE_NODE_FIELD(returningList);
700
701         return true;
702 }
703
704 static bool
705 _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
706 {
707         COMPARE_NODE_FIELD(relation);
708         COMPARE_NODE_FIELD(targetList);
709         COMPARE_NODE_FIELD(whereClause);
710         COMPARE_NODE_FIELD(fromClause);
711         COMPARE_NODE_FIELD(returningList);
712
713         return true;
714 }
715
716 static bool
717 _equalSelectStmt(SelectStmt *a, SelectStmt *b)
718 {
719         COMPARE_NODE_FIELD(distinctClause);
720         COMPARE_NODE_FIELD(into);
721         COMPARE_NODE_FIELD(intoColNames);
722         COMPARE_NODE_FIELD(intoOptions);
723         COMPARE_SCALAR_FIELD(intoOnCommit);
724         COMPARE_STRING_FIELD(intoTableSpaceName);
725         COMPARE_NODE_FIELD(targetList);
726         COMPARE_NODE_FIELD(fromClause);
727         COMPARE_NODE_FIELD(whereClause);
728         COMPARE_NODE_FIELD(groupClause);
729         COMPARE_NODE_FIELD(havingClause);
730         COMPARE_NODE_FIELD(valuesLists);
731         COMPARE_NODE_FIELD(sortClause);
732         COMPARE_NODE_FIELD(limitOffset);
733         COMPARE_NODE_FIELD(limitCount);
734         COMPARE_NODE_FIELD(lockingClause);
735         COMPARE_SCALAR_FIELD(op);
736         COMPARE_SCALAR_FIELD(all);
737         COMPARE_NODE_FIELD(larg);
738         COMPARE_NODE_FIELD(rarg);
739
740         return true;
741 }
742
743 static bool
744 _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b)
745 {
746         COMPARE_SCALAR_FIELD(op);
747         COMPARE_SCALAR_FIELD(all);
748         COMPARE_NODE_FIELD(larg);
749         COMPARE_NODE_FIELD(rarg);
750         COMPARE_NODE_FIELD(colTypes);
751         COMPARE_NODE_FIELD(colTypmods);
752
753         return true;
754 }
755
756 static bool
757 _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
758 {
759         COMPARE_NODE_FIELD(relation);
760         COMPARE_NODE_FIELD(cmds);
761         COMPARE_SCALAR_FIELD(relkind);
762
763         return true;
764 }
765
766 static bool
767 _equalAlterTableCmd(AlterTableCmd *a, AlterTableCmd *b)
768 {
769         COMPARE_SCALAR_FIELD(subtype);
770         COMPARE_STRING_FIELD(name);
771         COMPARE_NODE_FIELD(parent);
772         COMPARE_NODE_FIELD(def);
773         COMPARE_NODE_FIELD(transform);
774         COMPARE_SCALAR_FIELD(behavior);
775
776         return true;
777 }
778
779 static bool
780 _equalAlterDomainStmt(AlterDomainStmt *a, AlterDomainStmt *b)
781 {
782         COMPARE_SCALAR_FIELD(subtype);
783         COMPARE_NODE_FIELD(typename);
784         COMPARE_STRING_FIELD(name);
785         COMPARE_NODE_FIELD(def);
786         COMPARE_SCALAR_FIELD(behavior);
787
788         return true;
789 }
790
791 static bool
792 _equalGrantStmt(GrantStmt *a, GrantStmt *b)
793 {
794         COMPARE_SCALAR_FIELD(is_grant);
795         COMPARE_SCALAR_FIELD(objtype);
796         COMPARE_NODE_FIELD(objects);
797         COMPARE_NODE_FIELD(privileges);
798         COMPARE_NODE_FIELD(grantees);
799         COMPARE_SCALAR_FIELD(grant_option);
800         COMPARE_SCALAR_FIELD(behavior);
801
802         return true;
803 }
804
805 static bool
806 _equalPrivGrantee(PrivGrantee *a, PrivGrantee *b)
807 {
808         COMPARE_STRING_FIELD(rolname);
809
810         return true;
811 }
812
813 static bool
814 _equalFuncWithArgs(FuncWithArgs *a, FuncWithArgs *b)
815 {
816         COMPARE_NODE_FIELD(funcname);
817         COMPARE_NODE_FIELD(funcargs);
818
819         return true;
820 }
821
822 static bool
823 _equalGrantRoleStmt(GrantRoleStmt *a, GrantRoleStmt *b)
824 {
825         COMPARE_NODE_FIELD(granted_roles);
826         COMPARE_NODE_FIELD(grantee_roles);
827         COMPARE_SCALAR_FIELD(is_grant);
828         COMPARE_SCALAR_FIELD(admin_opt);
829         COMPARE_STRING_FIELD(grantor);
830         COMPARE_SCALAR_FIELD(behavior);
831
832         return true;
833 }
834
835 static bool
836 _equalDeclareCursorStmt(DeclareCursorStmt *a, DeclareCursorStmt *b)
837 {
838         COMPARE_STRING_FIELD(portalname);
839         COMPARE_SCALAR_FIELD(options);
840         COMPARE_NODE_FIELD(query);
841
842         return true;
843 }
844
845 static bool
846 _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
847 {
848         COMPARE_STRING_FIELD(portalname);
849
850         return true;
851 }
852
853 static bool
854 _equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
855 {
856         COMPARE_NODE_FIELD(relation);
857         COMPARE_STRING_FIELD(indexname);
858
859         return true;
860 }
861
862 static bool
863 _equalCopyStmt(CopyStmt *a, CopyStmt *b)
864 {
865         COMPARE_NODE_FIELD(relation);
866         COMPARE_NODE_FIELD(attlist);
867         COMPARE_SCALAR_FIELD(is_from);
868         COMPARE_STRING_FIELD(filename);
869         COMPARE_NODE_FIELD(options);
870
871         return true;
872 }
873
874 static bool
875 _equalCreateStmt(CreateStmt *a, CreateStmt *b)
876 {
877         COMPARE_NODE_FIELD(relation);
878         COMPARE_NODE_FIELD(tableElts);
879         COMPARE_NODE_FIELD(inhRelations);
880         COMPARE_NODE_FIELD(constraints);
881         COMPARE_NODE_FIELD(options);
882         COMPARE_SCALAR_FIELD(oncommit);
883         COMPARE_STRING_FIELD(tablespacename);
884
885         return true;
886 }
887
888 static bool
889 _equalInhRelation(InhRelation *a, InhRelation *b)
890 {
891         COMPARE_NODE_FIELD(relation);
892         COMPARE_NODE_FIELD(options);
893
894         return true;
895 }
896
897 static bool
898 _equalDefineStmt(DefineStmt *a, DefineStmt *b)
899 {
900         COMPARE_SCALAR_FIELD(kind);
901         COMPARE_SCALAR_FIELD(oldstyle);
902         COMPARE_NODE_FIELD(defnames);
903         COMPARE_NODE_FIELD(args);
904         COMPARE_NODE_FIELD(definition);
905
906         return true;
907 }
908
909 static bool
910 _equalDropStmt(DropStmt *a, DropStmt *b)
911 {
912         COMPARE_NODE_FIELD(objects);
913         COMPARE_SCALAR_FIELD(removeType);
914         COMPARE_SCALAR_FIELD(behavior);
915         COMPARE_SCALAR_FIELD(missing_ok);
916
917         return true;
918 }
919
920 static bool
921 _equalTruncateStmt(TruncateStmt *a, TruncateStmt *b)
922 {
923         COMPARE_NODE_FIELD(relations);
924         COMPARE_SCALAR_FIELD(behavior);
925
926         return true;
927 }
928
929 static bool
930 _equalCommentStmt(CommentStmt *a, CommentStmt *b)
931 {
932         COMPARE_SCALAR_FIELD(objtype);
933         COMPARE_NODE_FIELD(objname);
934         COMPARE_NODE_FIELD(objargs);
935         COMPARE_STRING_FIELD(comment);
936
937         return true;
938 }
939
940 static bool
941 _equalFetchStmt(FetchStmt *a, FetchStmt *b)
942 {
943         COMPARE_SCALAR_FIELD(direction);
944         COMPARE_SCALAR_FIELD(howMany);
945         COMPARE_STRING_FIELD(portalname);
946         COMPARE_SCALAR_FIELD(ismove);
947
948         return true;
949 }
950
951 static bool
952 _equalIndexStmt(IndexStmt *a, IndexStmt *b)
953 {
954         COMPARE_STRING_FIELD(idxname);
955         COMPARE_NODE_FIELD(relation);
956         COMPARE_STRING_FIELD(accessMethod);
957         COMPARE_STRING_FIELD(tableSpace);
958         COMPARE_NODE_FIELD(indexParams);
959         COMPARE_NODE_FIELD(options);
960         COMPARE_NODE_FIELD(whereClause);
961         COMPARE_NODE_FIELD(rangetable);
962         COMPARE_SCALAR_FIELD(unique);
963         COMPARE_SCALAR_FIELD(primary);
964         COMPARE_SCALAR_FIELD(isconstraint);
965
966         return true;
967 }
968
969 static bool
970 _equalCreateFunctionStmt(CreateFunctionStmt *a, CreateFunctionStmt *b)
971 {
972         COMPARE_SCALAR_FIELD(replace);
973         COMPARE_NODE_FIELD(funcname);
974         COMPARE_NODE_FIELD(parameters);
975         COMPARE_NODE_FIELD(returnType);
976         COMPARE_NODE_FIELD(options);
977         COMPARE_NODE_FIELD(withClause);
978
979         return true;
980 }
981
982 static bool
983 _equalFunctionParameter(FunctionParameter *a, FunctionParameter *b)
984 {
985         COMPARE_STRING_FIELD(name);
986         COMPARE_NODE_FIELD(argType);
987         COMPARE_SCALAR_FIELD(mode);
988
989         return true;
990 }
991
992 static bool
993 _equalAlterFunctionStmt(AlterFunctionStmt *a, AlterFunctionStmt *b)
994 {
995         COMPARE_NODE_FIELD(func);
996         COMPARE_NODE_FIELD(actions);
997
998         return true;
999 }
1000
1001 static bool
1002 _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b)
1003 {
1004         COMPARE_SCALAR_FIELD(kind);
1005         COMPARE_NODE_FIELD(name);
1006         COMPARE_NODE_FIELD(args);
1007         COMPARE_SCALAR_FIELD(behavior);
1008         COMPARE_SCALAR_FIELD(missing_ok);
1009
1010         return true;
1011 }
1012
1013 static bool
1014 _equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b)
1015 {
1016         COMPARE_NODE_FIELD(opclassname);
1017         COMPARE_STRING_FIELD(amname);
1018         COMPARE_SCALAR_FIELD(behavior);
1019         COMPARE_SCALAR_FIELD(missing_ok);
1020
1021         return true;
1022 }
1023
1024 static bool
1025 _equalRenameStmt(RenameStmt *a, RenameStmt *b)
1026 {
1027         COMPARE_SCALAR_FIELD(renameType);
1028         COMPARE_NODE_FIELD(relation);
1029         COMPARE_NODE_FIELD(object);
1030         COMPARE_NODE_FIELD(objarg);
1031         COMPARE_STRING_FIELD(subname);
1032         COMPARE_STRING_FIELD(newname);
1033
1034         return true;
1035 }
1036
1037 static bool
1038 _equalAlterObjectSchemaStmt(AlterObjectSchemaStmt *a, AlterObjectSchemaStmt *b)
1039 {
1040         COMPARE_SCALAR_FIELD(objectType);
1041         COMPARE_NODE_FIELD(relation);
1042         COMPARE_NODE_FIELD(object);
1043         COMPARE_NODE_FIELD(objarg);
1044         COMPARE_STRING_FIELD(addname);
1045         COMPARE_STRING_FIELD(newschema);
1046
1047         return true;
1048 }
1049
1050 static bool
1051 _equalAlterOwnerStmt(AlterOwnerStmt *a, AlterOwnerStmt *b)
1052 {
1053         COMPARE_SCALAR_FIELD(objectType);
1054         COMPARE_NODE_FIELD(relation);
1055         COMPARE_NODE_FIELD(object);
1056         COMPARE_NODE_FIELD(objarg);
1057         COMPARE_STRING_FIELD(addname);
1058         COMPARE_STRING_FIELD(newowner);
1059
1060         return true;
1061 }
1062
1063 static bool
1064 _equalRuleStmt(RuleStmt *a, RuleStmt *b)
1065 {
1066         COMPARE_NODE_FIELD(relation);
1067         COMPARE_STRING_FIELD(rulename);
1068         COMPARE_NODE_FIELD(whereClause);
1069         COMPARE_SCALAR_FIELD(event);
1070         COMPARE_SCALAR_FIELD(instead);
1071         COMPARE_NODE_FIELD(actions);
1072         COMPARE_SCALAR_FIELD(replace);
1073
1074         return true;
1075 }
1076
1077 static bool
1078 _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
1079 {
1080         COMPARE_NODE_FIELD(relation);
1081
1082         return true;
1083 }
1084
1085 static bool
1086 _equalListenStmt(ListenStmt *a, ListenStmt *b)
1087 {
1088         COMPARE_NODE_FIELD(relation);
1089
1090         return true;
1091 }
1092
1093 static bool
1094 _equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
1095 {
1096         COMPARE_NODE_FIELD(relation);
1097
1098         return true;
1099 }
1100
1101 static bool
1102 _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
1103 {
1104         COMPARE_SCALAR_FIELD(kind);
1105         COMPARE_NODE_FIELD(options);
1106         COMPARE_STRING_FIELD(gid);
1107
1108         return true;
1109 }
1110
1111 static bool
1112 _equalCompositeTypeStmt(CompositeTypeStmt *a, CompositeTypeStmt *b)
1113 {
1114         COMPARE_NODE_FIELD(typevar);
1115         COMPARE_NODE_FIELD(coldeflist);
1116
1117         return true;
1118 }
1119
1120 static bool
1121 _equalViewStmt(ViewStmt *a, ViewStmt *b)
1122 {
1123         COMPARE_NODE_FIELD(view);
1124         COMPARE_NODE_FIELD(aliases);
1125         COMPARE_NODE_FIELD(query);
1126         COMPARE_SCALAR_FIELD(replace);
1127
1128         return true;
1129 }
1130
1131 static bool
1132 _equalLoadStmt(LoadStmt *a, LoadStmt *b)
1133 {
1134         COMPARE_STRING_FIELD(filename);
1135
1136         return true;
1137 }
1138
1139 static bool
1140 _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b)
1141 {
1142         COMPARE_NODE_FIELD(domainname);
1143         COMPARE_NODE_FIELD(typename);
1144         COMPARE_NODE_FIELD(constraints);
1145
1146         return true;
1147 }
1148
1149 static bool
1150 _equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b)
1151 {
1152         COMPARE_NODE_FIELD(opclassname);
1153         COMPARE_STRING_FIELD(amname);
1154         COMPARE_NODE_FIELD(datatype);
1155         COMPARE_NODE_FIELD(items);
1156         COMPARE_SCALAR_FIELD(isDefault);
1157
1158         return true;
1159 }
1160
1161 static bool
1162 _equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b)
1163 {
1164         COMPARE_SCALAR_FIELD(itemtype);
1165         COMPARE_NODE_FIELD(name);
1166         COMPARE_NODE_FIELD(args);
1167         COMPARE_SCALAR_FIELD(number);
1168         COMPARE_SCALAR_FIELD(recheck);
1169         COMPARE_NODE_FIELD(storedtype);
1170
1171         return true;
1172 }
1173
1174 static bool
1175 _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
1176 {
1177         COMPARE_STRING_FIELD(dbname);
1178         COMPARE_NODE_FIELD(options);
1179
1180         return true;
1181 }
1182
1183 static bool
1184 _equalAlterDatabaseStmt(AlterDatabaseStmt *a, AlterDatabaseStmt *b)
1185 {
1186         COMPARE_STRING_FIELD(dbname);
1187         COMPARE_NODE_FIELD(options);
1188
1189         return true;
1190 }
1191
1192 static bool
1193 _equalAlterDatabaseSetStmt(AlterDatabaseSetStmt *a, AlterDatabaseSetStmt *b)
1194 {
1195         COMPARE_STRING_FIELD(dbname);
1196         COMPARE_STRING_FIELD(variable);
1197         COMPARE_NODE_FIELD(value);
1198
1199         return true;
1200 }
1201
1202 static bool
1203 _equalDropdbStmt(DropdbStmt *a, DropdbStmt *b)
1204 {
1205         COMPARE_STRING_FIELD(dbname);
1206         COMPARE_SCALAR_FIELD(missing_ok);
1207
1208         return true;
1209 }
1210
1211 static bool
1212 _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
1213 {
1214         COMPARE_SCALAR_FIELD(vacuum);
1215         COMPARE_SCALAR_FIELD(full);
1216         COMPARE_SCALAR_FIELD(analyze);
1217         COMPARE_SCALAR_FIELD(freeze);
1218         COMPARE_SCALAR_FIELD(verbose);
1219         COMPARE_NODE_FIELD(relation);
1220         COMPARE_NODE_FIELD(va_cols);
1221
1222         return true;
1223 }
1224
1225 static bool
1226 _equalExplainStmt(ExplainStmt *a, ExplainStmt *b)
1227 {
1228         COMPARE_NODE_FIELD(query);
1229         COMPARE_SCALAR_FIELD(verbose);
1230         COMPARE_SCALAR_FIELD(analyze);
1231
1232         return true;
1233 }
1234
1235 static bool
1236 _equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b)
1237 {
1238         COMPARE_NODE_FIELD(sequence);
1239         COMPARE_NODE_FIELD(options);
1240
1241         return true;
1242 }
1243
1244 static bool
1245 _equalAlterSeqStmt(AlterSeqStmt *a, AlterSeqStmt *b)
1246 {
1247         COMPARE_NODE_FIELD(sequence);
1248         COMPARE_NODE_FIELD(options);
1249
1250         return true;
1251 }
1252
1253 static bool
1254 _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
1255 {
1256         COMPARE_STRING_FIELD(name);
1257         COMPARE_NODE_FIELD(args);
1258         COMPARE_SCALAR_FIELD(is_local);
1259
1260         return true;
1261 }
1262
1263 static bool
1264 _equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b)
1265 {
1266         COMPARE_STRING_FIELD(name);
1267
1268         return true;
1269 }
1270
1271 static bool
1272 _equalVariableResetStmt(VariableResetStmt *a, VariableResetStmt *b)
1273 {
1274         COMPARE_STRING_FIELD(name);
1275
1276         return true;
1277 }
1278
1279 static bool
1280 _equalCreateTableSpaceStmt(CreateTableSpaceStmt *a, CreateTableSpaceStmt *b)
1281 {
1282         COMPARE_STRING_FIELD(tablespacename);
1283         COMPARE_STRING_FIELD(owner);
1284         COMPARE_STRING_FIELD(location);
1285
1286         return true;
1287 }
1288
1289 static bool
1290 _equalDropTableSpaceStmt(DropTableSpaceStmt *a, DropTableSpaceStmt *b)
1291 {
1292         COMPARE_STRING_FIELD(tablespacename);
1293         COMPARE_SCALAR_FIELD(missing_ok);
1294
1295         return true;
1296 }
1297
1298 static bool
1299 _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b)
1300 {
1301         COMPARE_STRING_FIELD(trigname);
1302         COMPARE_NODE_FIELD(relation);
1303         COMPARE_NODE_FIELD(funcname);
1304         COMPARE_NODE_FIELD(args);
1305         COMPARE_SCALAR_FIELD(before);
1306         COMPARE_SCALAR_FIELD(row);
1307         if (strcmp(a->actions, b->actions) != 0)        /* in-line string field */
1308                 return false;
1309         COMPARE_SCALAR_FIELD(isconstraint);
1310         COMPARE_SCALAR_FIELD(deferrable);
1311         COMPARE_SCALAR_FIELD(initdeferred);
1312         COMPARE_NODE_FIELD(constrrel);
1313
1314         return true;
1315 }
1316
1317 static bool
1318 _equalDropPropertyStmt(DropPropertyStmt *a, DropPropertyStmt *b)
1319 {
1320         COMPARE_NODE_FIELD(relation);
1321         COMPARE_STRING_FIELD(property);
1322         COMPARE_SCALAR_FIELD(removeType);
1323         COMPARE_SCALAR_FIELD(behavior);
1324         COMPARE_SCALAR_FIELD(missing_ok);
1325
1326         return true;
1327 }
1328
1329 static bool
1330 _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b)
1331 {
1332         COMPARE_STRING_FIELD(plname);
1333         COMPARE_NODE_FIELD(plhandler);
1334         COMPARE_NODE_FIELD(plvalidator);
1335         COMPARE_SCALAR_FIELD(pltrusted);
1336
1337         return true;
1338 }
1339
1340 static bool
1341 _equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b)
1342 {
1343         COMPARE_STRING_FIELD(plname);
1344         COMPARE_SCALAR_FIELD(behavior);
1345         COMPARE_SCALAR_FIELD(missing_ok);
1346
1347         return true;
1348 }
1349
1350 static bool
1351 _equalCreateRoleStmt(CreateRoleStmt *a, CreateRoleStmt *b)
1352 {
1353         COMPARE_SCALAR_FIELD(stmt_type);
1354         COMPARE_STRING_FIELD(role);
1355         COMPARE_NODE_FIELD(options);
1356
1357         return true;
1358 }
1359
1360 static bool
1361 _equalAlterRoleStmt(AlterRoleStmt *a, AlterRoleStmt *b)
1362 {
1363         COMPARE_STRING_FIELD(role);
1364         COMPARE_NODE_FIELD(options);
1365         COMPARE_SCALAR_FIELD(action);
1366
1367         return true;
1368 }
1369
1370 static bool
1371 _equalAlterRoleSetStmt(AlterRoleSetStmt *a, AlterRoleSetStmt *b)
1372 {
1373         COMPARE_STRING_FIELD(role);
1374         COMPARE_STRING_FIELD(variable);
1375         COMPARE_NODE_FIELD(value);
1376
1377         return true;
1378 }
1379
1380 static bool
1381 _equalDropRoleStmt(DropRoleStmt *a, DropRoleStmt *b)
1382 {
1383         COMPARE_NODE_FIELD(roles);
1384         COMPARE_SCALAR_FIELD(missing_ok);
1385
1386         return true;
1387 }
1388
1389 static bool
1390 _equalLockStmt(LockStmt *a, LockStmt *b)
1391 {
1392         COMPARE_NODE_FIELD(relations);
1393         COMPARE_SCALAR_FIELD(mode);
1394         COMPARE_SCALAR_FIELD(nowait);
1395
1396         return true;
1397 }
1398
1399 static bool
1400 _equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b)
1401 {
1402         COMPARE_NODE_FIELD(constraints);
1403         COMPARE_SCALAR_FIELD(deferred);
1404
1405         return true;
1406 }
1407
1408 static bool
1409 _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
1410 {
1411         COMPARE_SCALAR_FIELD(kind);
1412         COMPARE_NODE_FIELD(relation);
1413         COMPARE_STRING_FIELD(name);
1414         COMPARE_SCALAR_FIELD(do_system);
1415         COMPARE_SCALAR_FIELD(do_user);
1416
1417         return true;
1418 }
1419
1420 static bool
1421 _equalCreateSchemaStmt(CreateSchemaStmt *a, CreateSchemaStmt *b)
1422 {
1423         COMPARE_STRING_FIELD(schemaname);
1424         COMPARE_STRING_FIELD(authid);
1425         COMPARE_NODE_FIELD(schemaElts);
1426
1427         return true;
1428 }
1429
1430 static bool
1431 _equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b)
1432 {
1433         COMPARE_NODE_FIELD(conversion_name);
1434         COMPARE_STRING_FIELD(for_encoding_name);
1435         COMPARE_STRING_FIELD(to_encoding_name);
1436         COMPARE_NODE_FIELD(func_name);
1437         COMPARE_SCALAR_FIELD(def);
1438
1439         return true;
1440 }
1441
1442 static bool
1443 _equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b)
1444 {
1445         COMPARE_NODE_FIELD(sourcetype);
1446         COMPARE_NODE_FIELD(targettype);
1447         COMPARE_NODE_FIELD(func);
1448         COMPARE_SCALAR_FIELD(context);
1449
1450         return true;
1451 }
1452
1453 static bool
1454 _equalDropCastStmt(DropCastStmt *a, DropCastStmt *b)
1455 {
1456         COMPARE_NODE_FIELD(sourcetype);
1457         COMPARE_NODE_FIELD(targettype);
1458         COMPARE_SCALAR_FIELD(behavior);
1459         COMPARE_SCALAR_FIELD(missing_ok);
1460
1461         return true;
1462 }
1463
1464 static bool
1465 _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b)
1466 {
1467         COMPARE_STRING_FIELD(name);
1468         COMPARE_NODE_FIELD(argtypes);
1469         COMPARE_NODE_FIELD(argtype_oids);
1470         COMPARE_NODE_FIELD(query);
1471
1472         return true;
1473 }
1474
1475 static bool
1476 _equalExecuteStmt(ExecuteStmt *a, ExecuteStmt *b)
1477 {
1478         COMPARE_STRING_FIELD(name);
1479         COMPARE_NODE_FIELD(into);
1480         COMPARE_NODE_FIELD(intoOptions);
1481         COMPARE_SCALAR_FIELD(into_on_commit);
1482         COMPARE_STRING_FIELD(into_tbl_space);
1483         COMPARE_NODE_FIELD(params);
1484
1485         return true;
1486 }
1487
1488 static bool
1489 _equalDeallocateStmt(DeallocateStmt *a, DeallocateStmt *b)
1490 {
1491         COMPARE_STRING_FIELD(name);
1492
1493         return true;
1494 }
1495
1496 static bool
1497 _equalDropOwnedStmt(DropOwnedStmt * a, DropOwnedStmt * b)
1498 {
1499         COMPARE_NODE_FIELD(roles);
1500         COMPARE_SCALAR_FIELD(behavior);
1501
1502         return true;
1503 }
1504
1505 static bool
1506 _equalReassignOwnedStmt(ReassignOwnedStmt * a, ReassignOwnedStmt * b)
1507 {
1508         COMPARE_NODE_FIELD(roles);
1509         COMPARE_NODE_FIELD(newrole);
1510
1511         return true;
1512 }
1513
1514 static bool
1515 _equalAExpr(A_Expr *a, A_Expr *b)
1516 {
1517         COMPARE_SCALAR_FIELD(kind);
1518         COMPARE_NODE_FIELD(name);
1519         COMPARE_NODE_FIELD(lexpr);
1520         COMPARE_NODE_FIELD(rexpr);
1521         COMPARE_SCALAR_FIELD(location);
1522
1523         return true;
1524 }
1525
1526 static bool
1527 _equalColumnRef(ColumnRef *a, ColumnRef *b)
1528 {
1529         COMPARE_NODE_FIELD(fields);
1530         COMPARE_SCALAR_FIELD(location);
1531
1532         return true;
1533 }
1534
1535 static bool
1536 _equalParamRef(ParamRef *a, ParamRef *b)
1537 {
1538         COMPARE_SCALAR_FIELD(number);
1539
1540         return true;
1541 }
1542
1543 static bool
1544 _equalAConst(A_Const *a, A_Const *b)
1545 {
1546         if (!equal(&a->val, &b->val))           /* hack for in-line Value field */
1547                 return false;
1548         COMPARE_NODE_FIELD(typename);
1549
1550         return true;
1551 }
1552
1553 static bool
1554 _equalFuncCall(FuncCall *a, FuncCall *b)
1555 {
1556         COMPARE_NODE_FIELD(funcname);
1557         COMPARE_NODE_FIELD(args);
1558         COMPARE_SCALAR_FIELD(agg_star);
1559         COMPARE_SCALAR_FIELD(agg_distinct);
1560         COMPARE_SCALAR_FIELD(location);
1561
1562         return true;
1563 }
1564
1565 static bool
1566 _equalAIndices(A_Indices *a, A_Indices *b)
1567 {
1568         COMPARE_NODE_FIELD(lidx);
1569         COMPARE_NODE_FIELD(uidx);
1570
1571         return true;
1572 }
1573
1574 static bool
1575 _equalA_Indirection(A_Indirection *a, A_Indirection *b)
1576 {
1577         COMPARE_NODE_FIELD(arg);
1578         COMPARE_NODE_FIELD(indirection);
1579
1580         return true;
1581 }
1582
1583 static bool
1584 _equalResTarget(ResTarget *a, ResTarget *b)
1585 {
1586         COMPARE_STRING_FIELD(name);
1587         COMPARE_NODE_FIELD(indirection);
1588         COMPARE_NODE_FIELD(val);
1589         COMPARE_SCALAR_FIELD(location);
1590
1591         return true;
1592 }
1593
1594 static bool
1595 _equalTypeName(TypeName *a, TypeName *b)
1596 {
1597         COMPARE_NODE_FIELD(names);
1598         COMPARE_SCALAR_FIELD(typeid);
1599         COMPARE_SCALAR_FIELD(timezone);
1600         COMPARE_SCALAR_FIELD(setof);
1601         COMPARE_SCALAR_FIELD(pct_type);
1602         COMPARE_SCALAR_FIELD(typmod);
1603         COMPARE_NODE_FIELD(arrayBounds);
1604         COMPARE_SCALAR_FIELD(location);
1605
1606         return true;
1607 }
1608
1609 static bool
1610 _equalTypeCast(TypeCast *a, TypeCast *b)
1611 {
1612         COMPARE_NODE_FIELD(arg);
1613         COMPARE_NODE_FIELD(typename);
1614
1615         return true;
1616 }
1617
1618 static bool
1619 _equalSortBy(SortBy *a, SortBy *b)
1620 {
1621         COMPARE_SCALAR_FIELD(sortby_kind);
1622         COMPARE_NODE_FIELD(useOp);
1623         COMPARE_NODE_FIELD(node);
1624
1625         return true;
1626 }
1627
1628 static bool
1629 _equalRangeSubselect(RangeSubselect *a, RangeSubselect *b)
1630 {
1631         COMPARE_NODE_FIELD(subquery);
1632         COMPARE_NODE_FIELD(alias);
1633
1634         return true;
1635 }
1636
1637 static bool
1638 _equalRangeFunction(RangeFunction *a, RangeFunction *b)
1639 {
1640         COMPARE_NODE_FIELD(funccallnode);
1641         COMPARE_NODE_FIELD(alias);
1642         COMPARE_NODE_FIELD(coldeflist);
1643
1644         return true;
1645 }
1646
1647 static bool
1648 _equalIndexElem(IndexElem *a, IndexElem *b)
1649 {
1650         COMPARE_STRING_FIELD(name);
1651         COMPARE_NODE_FIELD(expr);
1652         COMPARE_NODE_FIELD(opclass);
1653
1654         return true;
1655 }
1656
1657 static bool
1658 _equalColumnDef(ColumnDef *a, ColumnDef *b)
1659 {
1660         COMPARE_STRING_FIELD(colname);
1661         COMPARE_NODE_FIELD(typename);
1662         COMPARE_SCALAR_FIELD(inhcount);
1663         COMPARE_SCALAR_FIELD(is_local);
1664         COMPARE_SCALAR_FIELD(is_not_null);
1665         COMPARE_NODE_FIELD(raw_default);
1666         COMPARE_STRING_FIELD(cooked_default);
1667         COMPARE_NODE_FIELD(constraints);
1668         COMPARE_NODE_FIELD(support);
1669
1670         return true;
1671 }
1672
1673 static bool
1674 _equalConstraint(Constraint *a, Constraint *b)
1675 {
1676         COMPARE_SCALAR_FIELD(contype);
1677         COMPARE_STRING_FIELD(name);
1678         COMPARE_NODE_FIELD(raw_expr);
1679         COMPARE_STRING_FIELD(cooked_expr);
1680         COMPARE_NODE_FIELD(keys);
1681         COMPARE_NODE_FIELD(options);
1682         COMPARE_STRING_FIELD(indexspace);
1683
1684         return true;
1685 }
1686
1687 static bool
1688 _equalDefElem(DefElem *a, DefElem *b)
1689 {
1690         COMPARE_STRING_FIELD(defname);
1691         COMPARE_NODE_FIELD(arg);
1692
1693         return true;
1694 }
1695
1696 static bool
1697 _equalLockingClause(LockingClause *a, LockingClause *b)
1698 {
1699         COMPARE_NODE_FIELD(lockedRels);
1700         COMPARE_SCALAR_FIELD(forUpdate);
1701         COMPARE_SCALAR_FIELD(noWait);
1702
1703         return true;
1704 }
1705
1706 static bool
1707 _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
1708 {
1709         COMPARE_SCALAR_FIELD(rtekind);
1710         COMPARE_SCALAR_FIELD(relid);
1711         COMPARE_NODE_FIELD(subquery);
1712         COMPARE_NODE_FIELD(funcexpr);
1713         COMPARE_NODE_FIELD(funccoltypes);
1714         COMPARE_NODE_FIELD(funccoltypmods);
1715         COMPARE_NODE_FIELD(values_lists);
1716         COMPARE_SCALAR_FIELD(jointype);
1717         COMPARE_NODE_FIELD(joinaliasvars);
1718         COMPARE_NODE_FIELD(alias);
1719         COMPARE_NODE_FIELD(eref);
1720         COMPARE_SCALAR_FIELD(inh);
1721         COMPARE_SCALAR_FIELD(inFromCl);
1722         COMPARE_SCALAR_FIELD(requiredPerms);
1723         COMPARE_SCALAR_FIELD(checkAsUser);
1724
1725         return true;
1726 }
1727
1728 static bool
1729 _equalSortClause(SortClause *a, SortClause *b)
1730 {
1731         COMPARE_SCALAR_FIELD(tleSortGroupRef);
1732         COMPARE_SCALAR_FIELD(sortop);
1733
1734         return true;
1735 }
1736
1737 static bool
1738 _equalRowMarkClause(RowMarkClause *a, RowMarkClause *b)
1739 {
1740         COMPARE_SCALAR_FIELD(rti);
1741         COMPARE_SCALAR_FIELD(forUpdate);
1742         COMPARE_SCALAR_FIELD(noWait);
1743
1744         return true;
1745 }
1746
1747 static bool
1748 _equalFkConstraint(FkConstraint *a, FkConstraint *b)
1749 {
1750         COMPARE_STRING_FIELD(constr_name);
1751         COMPARE_NODE_FIELD(pktable);
1752         COMPARE_NODE_FIELD(fk_attrs);
1753         COMPARE_NODE_FIELD(pk_attrs);
1754         COMPARE_SCALAR_FIELD(fk_matchtype);
1755         COMPARE_SCALAR_FIELD(fk_upd_action);
1756         COMPARE_SCALAR_FIELD(fk_del_action);
1757         COMPARE_SCALAR_FIELD(deferrable);
1758         COMPARE_SCALAR_FIELD(initdeferred);
1759         COMPARE_SCALAR_FIELD(skip_validation);
1760
1761         return true;
1762 }
1763
1764
1765 /*
1766  * Stuff from pg_list.h
1767  */
1768
1769 static bool
1770 _equalList(List *a, List *b)
1771 {
1772         ListCell   *item_a;
1773         ListCell   *item_b;
1774
1775         /*
1776          * Try to reject by simple scalar checks before grovelling through all the
1777          * list elements...
1778          */
1779         COMPARE_SCALAR_FIELD(type);
1780         COMPARE_SCALAR_FIELD(length);
1781
1782         /*
1783          * We place the switch outside the loop for the sake of efficiency; this
1784          * may not be worth doing...
1785          */
1786         switch (a->type)
1787         {
1788                 case T_List:
1789                         forboth(item_a, a, item_b, b)
1790                         {
1791                                 if (!equal(lfirst(item_a), lfirst(item_b)))
1792                                         return false;
1793                         }
1794                         break;
1795                 case T_IntList:
1796                         forboth(item_a, a, item_b, b)
1797                         {
1798                                 if (lfirst_int(item_a) != lfirst_int(item_b))
1799                                         return false;
1800                         }
1801                         break;
1802                 case T_OidList:
1803                         forboth(item_a, a, item_b, b)
1804                         {
1805                                 if (lfirst_oid(item_a) != lfirst_oid(item_b))
1806                                         return false;
1807                         }
1808                         break;
1809                 default:
1810                         elog(ERROR, "unrecognized list node type: %d",
1811                                  (int) a->type);
1812                         return false;           /* keep compiler quiet */
1813         }
1814
1815         /*
1816          * If we got here, we should have run out of elements of both lists
1817          */
1818         Assert(item_a == NULL);
1819         Assert(item_b == NULL);
1820
1821         return true;
1822 }
1823
1824 /*
1825  * Stuff from value.h
1826  */
1827
1828 static bool
1829 _equalValue(Value *a, Value *b)
1830 {
1831         COMPARE_SCALAR_FIELD(type);
1832
1833         switch (a->type)
1834         {
1835                 case T_Integer:
1836                         COMPARE_SCALAR_FIELD(val.ival);
1837                         break;
1838                 case T_Float:
1839                 case T_String:
1840                 case T_BitString:
1841                         COMPARE_STRING_FIELD(val.str);
1842                         break;
1843                 case T_Null:
1844                         /* nothing to do */
1845                         break;
1846                 default:
1847                         elog(ERROR, "unrecognized node type: %d", (int) a->type);
1848                         break;
1849         }
1850
1851         return true;
1852 }
1853
1854 /*
1855  * equal
1856  *        returns whether two nodes are equal
1857  */
1858 bool
1859 equal(void *a, void *b)
1860 {
1861         bool            retval;
1862
1863         if (a == b)
1864                 return true;
1865
1866         /*
1867          * note that a!=b, so only one of them can be NULL
1868          */
1869         if (a == NULL || b == NULL)
1870                 return false;
1871
1872         /*
1873          * are they the same type of nodes?
1874          */
1875         if (nodeTag(a) != nodeTag(b))
1876                 return false;
1877
1878         switch (nodeTag(a))
1879         {
1880                         /*
1881                          * PRIMITIVE NODES
1882                          */
1883                 case T_Alias:
1884                         retval = _equalAlias(a, b);
1885                         break;
1886                 case T_RangeVar:
1887                         retval = _equalRangeVar(a, b);
1888                         break;
1889                 case T_Var:
1890                         retval = _equalVar(a, b);
1891                         break;
1892                 case T_Const:
1893                         retval = _equalConst(a, b);
1894                         break;
1895                 case T_Param:
1896                         retval = _equalParam(a, b);
1897                         break;
1898                 case T_Aggref:
1899                         retval = _equalAggref(a, b);
1900                         break;
1901                 case T_ArrayRef:
1902                         retval = _equalArrayRef(a, b);
1903                         break;
1904                 case T_FuncExpr:
1905                         retval = _equalFuncExpr(a, b);
1906                         break;
1907                 case T_OpExpr:
1908                         retval = _equalOpExpr(a, b);
1909                         break;
1910                 case T_DistinctExpr:
1911                         retval = _equalDistinctExpr(a, b);
1912                         break;
1913                 case T_ScalarArrayOpExpr:
1914                         retval = _equalScalarArrayOpExpr(a, b);
1915                         break;
1916                 case T_BoolExpr:
1917                         retval = _equalBoolExpr(a, b);
1918                         break;
1919                 case T_SubLink:
1920                         retval = _equalSubLink(a, b);
1921                         break;
1922                 case T_SubPlan:
1923                         retval = _equalSubPlan(a, b);
1924                         break;
1925                 case T_FieldSelect:
1926                         retval = _equalFieldSelect(a, b);
1927                         break;
1928                 case T_FieldStore:
1929                         retval = _equalFieldStore(a, b);
1930                         break;
1931                 case T_RelabelType:
1932                         retval = _equalRelabelType(a, b);
1933                         break;
1934                 case T_ConvertRowtypeExpr:
1935                         retval = _equalConvertRowtypeExpr(a, b);
1936                         break;
1937                 case T_CaseExpr:
1938                         retval = _equalCaseExpr(a, b);
1939                         break;
1940                 case T_CaseWhen:
1941                         retval = _equalCaseWhen(a, b);
1942                         break;
1943                 case T_CaseTestExpr:
1944                         retval = _equalCaseTestExpr(a, b);
1945                         break;
1946                 case T_ArrayExpr:
1947                         retval = _equalArrayExpr(a, b);
1948                         break;
1949                 case T_RowExpr:
1950                         retval = _equalRowExpr(a, b);
1951                         break;
1952                 case T_RowCompareExpr:
1953                         retval = _equalRowCompareExpr(a, b);
1954                         break;
1955                 case T_CoalesceExpr:
1956                         retval = _equalCoalesceExpr(a, b);
1957                         break;
1958                 case T_MinMaxExpr:
1959                         retval = _equalMinMaxExpr(a, b);
1960                         break;
1961                 case T_NullIfExpr:
1962                         retval = _equalNullIfExpr(a, b);
1963                         break;
1964                 case T_NullTest:
1965                         retval = _equalNullTest(a, b);
1966                         break;
1967                 case T_BooleanTest:
1968                         retval = _equalBooleanTest(a, b);
1969                         break;
1970                 case T_CoerceToDomain:
1971                         retval = _equalCoerceToDomain(a, b);
1972                         break;
1973                 case T_CoerceToDomainValue:
1974                         retval = _equalCoerceToDomainValue(a, b);
1975                         break;
1976                 case T_SetToDefault:
1977                         retval = _equalSetToDefault(a, b);
1978                         break;
1979                 case T_TargetEntry:
1980                         retval = _equalTargetEntry(a, b);
1981                         break;
1982                 case T_RangeTblRef:
1983                         retval = _equalRangeTblRef(a, b);
1984                         break;
1985                 case T_FromExpr:
1986                         retval = _equalFromExpr(a, b);
1987                         break;
1988                 case T_JoinExpr:
1989                         retval = _equalJoinExpr(a, b);
1990                         break;
1991
1992                         /*
1993                          * RELATION NODES
1994                          */
1995                 case T_PathKeyItem:
1996                         retval = _equalPathKeyItem(a, b);
1997                         break;
1998                 case T_RestrictInfo:
1999                         retval = _equalRestrictInfo(a, b);
2000                         break;
2001                 case T_OuterJoinInfo:
2002                         retval = _equalOuterJoinInfo(a, b);
2003                         break;
2004                 case T_InClauseInfo:
2005                         retval = _equalInClauseInfo(a, b);
2006                         break;
2007                 case T_AppendRelInfo:
2008                         retval = _equalAppendRelInfo(a, b);
2009                         break;
2010                 case T_List:
2011                 case T_IntList:
2012                 case T_OidList:
2013                         retval = _equalList(a, b);
2014                         break;
2015
2016                 case T_Integer:
2017                 case T_Float:
2018                 case T_String:
2019                 case T_BitString:
2020                 case T_Null:
2021                         retval = _equalValue(a, b);
2022                         break;
2023
2024                         /*
2025                          * PARSE NODES
2026                          */
2027                 case T_Query:
2028                         retval = _equalQuery(a, b);
2029                         break;
2030                 case T_InsertStmt:
2031                         retval = _equalInsertStmt(a, b);
2032                         break;
2033                 case T_DeleteStmt:
2034                         retval = _equalDeleteStmt(a, b);
2035                         break;
2036                 case T_UpdateStmt:
2037                         retval = _equalUpdateStmt(a, b);
2038                         break;
2039                 case T_SelectStmt:
2040                         retval = _equalSelectStmt(a, b);
2041                         break;
2042                 case T_SetOperationStmt:
2043                         retval = _equalSetOperationStmt(a, b);
2044                         break;
2045                 case T_AlterTableStmt:
2046                         retval = _equalAlterTableStmt(a, b);
2047                         break;
2048                 case T_AlterTableCmd:
2049                         retval = _equalAlterTableCmd(a, b);
2050                         break;
2051                 case T_AlterDomainStmt:
2052                         retval = _equalAlterDomainStmt(a, b);
2053                         break;
2054                 case T_GrantStmt:
2055                         retval = _equalGrantStmt(a, b);
2056                         break;
2057                 case T_GrantRoleStmt:
2058                         retval = _equalGrantRoleStmt(a, b);
2059                         break;
2060                 case T_DeclareCursorStmt:
2061                         retval = _equalDeclareCursorStmt(a, b);
2062                         break;
2063                 case T_ClosePortalStmt:
2064                         retval = _equalClosePortalStmt(a, b);
2065                         break;
2066                 case T_ClusterStmt:
2067                         retval = _equalClusterStmt(a, b);
2068                         break;
2069                 case T_CopyStmt:
2070                         retval = _equalCopyStmt(a, b);
2071                         break;
2072                 case T_CreateStmt:
2073                         retval = _equalCreateStmt(a, b);
2074                         break;
2075                 case T_InhRelation:
2076                         retval = _equalInhRelation(a, b);
2077                         break;
2078                 case T_DefineStmt:
2079                         retval = _equalDefineStmt(a, b);
2080                         break;
2081                 case T_DropStmt:
2082                         retval = _equalDropStmt(a, b);
2083                         break;
2084                 case T_TruncateStmt:
2085                         retval = _equalTruncateStmt(a, b);
2086                         break;
2087                 case T_CommentStmt:
2088                         retval = _equalCommentStmt(a, b);
2089                         break;
2090                 case T_FetchStmt:
2091                         retval = _equalFetchStmt(a, b);
2092                         break;
2093                 case T_IndexStmt:
2094                         retval = _equalIndexStmt(a, b);
2095                         break;
2096                 case T_CreateFunctionStmt:
2097                         retval = _equalCreateFunctionStmt(a, b);
2098                         break;
2099                 case T_FunctionParameter:
2100                         retval = _equalFunctionParameter(a, b);
2101                         break;
2102                 case T_AlterFunctionStmt:
2103                         retval = _equalAlterFunctionStmt(a, b);
2104                         break;
2105                 case T_RemoveFuncStmt:
2106                         retval = _equalRemoveFuncStmt(a, b);
2107                         break;
2108                 case T_RemoveOpClassStmt:
2109                         retval = _equalRemoveOpClassStmt(a, b);
2110                         break;
2111                 case T_RenameStmt:
2112                         retval = _equalRenameStmt(a, b);
2113                         break;
2114                 case T_AlterObjectSchemaStmt:
2115                         retval = _equalAlterObjectSchemaStmt(a, b);
2116                         break;
2117                 case T_AlterOwnerStmt:
2118                         retval = _equalAlterOwnerStmt(a, b);
2119                         break;
2120                 case T_RuleStmt:
2121                         retval = _equalRuleStmt(a, b);
2122                         break;
2123                 case T_NotifyStmt:
2124                         retval = _equalNotifyStmt(a, b);
2125                         break;
2126                 case T_ListenStmt:
2127                         retval = _equalListenStmt(a, b);
2128                         break;
2129                 case T_UnlistenStmt:
2130                         retval = _equalUnlistenStmt(a, b);
2131                         break;
2132                 case T_TransactionStmt:
2133                         retval = _equalTransactionStmt(a, b);
2134                         break;
2135                 case T_CompositeTypeStmt:
2136                         retval = _equalCompositeTypeStmt(a, b);
2137                         break;
2138                 case T_ViewStmt:
2139                         retval = _equalViewStmt(a, b);
2140                         break;
2141                 case T_LoadStmt:
2142                         retval = _equalLoadStmt(a, b);
2143                         break;
2144                 case T_CreateDomainStmt:
2145                         retval = _equalCreateDomainStmt(a, b);
2146                         break;
2147                 case T_CreateOpClassStmt:
2148                         retval = _equalCreateOpClassStmt(a, b);
2149                         break;
2150                 case T_CreateOpClassItem:
2151                         retval = _equalCreateOpClassItem(a, b);
2152                         break;
2153                 case T_CreatedbStmt:
2154                         retval = _equalCreatedbStmt(a, b);
2155                         break;
2156                 case T_AlterDatabaseStmt:
2157                         retval = _equalAlterDatabaseStmt(a, b);
2158                         break;
2159                 case T_AlterDatabaseSetStmt:
2160                         retval = _equalAlterDatabaseSetStmt(a, b);
2161                         break;
2162                 case T_DropdbStmt:
2163                         retval = _equalDropdbStmt(a, b);
2164                         break;
2165                 case T_VacuumStmt:
2166                         retval = _equalVacuumStmt(a, b);
2167                         break;
2168                 case T_ExplainStmt:
2169                         retval = _equalExplainStmt(a, b);
2170                         break;
2171                 case T_CreateSeqStmt:
2172                         retval = _equalCreateSeqStmt(a, b);
2173                         break;
2174                 case T_AlterSeqStmt:
2175                         retval = _equalAlterSeqStmt(a, b);
2176                         break;
2177                 case T_VariableSetStmt:
2178                         retval = _equalVariableSetStmt(a, b);
2179                         break;
2180                 case T_VariableShowStmt:
2181                         retval = _equalVariableShowStmt(a, b);
2182                         break;
2183                 case T_VariableResetStmt:
2184                         retval = _equalVariableResetStmt(a, b);
2185                         break;
2186                 case T_CreateTableSpaceStmt:
2187                         retval = _equalCreateTableSpaceStmt(a, b);
2188                         break;
2189                 case T_DropTableSpaceStmt:
2190                         retval = _equalDropTableSpaceStmt(a, b);
2191                         break;
2192                 case T_CreateTrigStmt:
2193                         retval = _equalCreateTrigStmt(a, b);
2194                         break;
2195                 case T_DropPropertyStmt:
2196                         retval = _equalDropPropertyStmt(a, b);
2197                         break;
2198                 case T_CreatePLangStmt:
2199                         retval = _equalCreatePLangStmt(a, b);
2200                         break;
2201                 case T_DropPLangStmt:
2202                         retval = _equalDropPLangStmt(a, b);
2203                         break;
2204                 case T_CreateRoleStmt:
2205                         retval = _equalCreateRoleStmt(a, b);
2206                         break;
2207                 case T_AlterRoleStmt:
2208                         retval = _equalAlterRoleStmt(a, b);
2209                         break;
2210                 case T_AlterRoleSetStmt:
2211                         retval = _equalAlterRoleSetStmt(a, b);
2212                         break;
2213                 case T_DropRoleStmt:
2214                         retval = _equalDropRoleStmt(a, b);
2215                         break;
2216                 case T_LockStmt:
2217                         retval = _equalLockStmt(a, b);
2218                         break;
2219                 case T_ConstraintsSetStmt:
2220                         retval = _equalConstraintsSetStmt(a, b);
2221                         break;
2222                 case T_ReindexStmt:
2223                         retval = _equalReindexStmt(a, b);
2224                         break;
2225                 case T_CheckPointStmt:
2226                         retval = true;
2227                         break;
2228                 case T_CreateSchemaStmt:
2229                         retval = _equalCreateSchemaStmt(a, b);
2230                         break;
2231                 case T_CreateConversionStmt:
2232                         retval = _equalCreateConversionStmt(a, b);
2233                         break;
2234                 case T_CreateCastStmt:
2235                         retval = _equalCreateCastStmt(a, b);
2236                         break;
2237                 case T_DropCastStmt:
2238                         retval = _equalDropCastStmt(a, b);
2239                         break;
2240                 case T_PrepareStmt:
2241                         retval = _equalPrepareStmt(a, b);
2242                         break;
2243                 case T_ExecuteStmt:
2244                         retval = _equalExecuteStmt(a, b);
2245                         break;
2246                 case T_DeallocateStmt:
2247                         retval = _equalDeallocateStmt(a, b);
2248                         break;
2249                 case T_DropOwnedStmt:
2250                         retval = _equalDropOwnedStmt(a, b);
2251                         break;
2252
2253                 case T_ReassignOwnedStmt:
2254                         retval = _equalReassignOwnedStmt(a, b);
2255                         break;
2256
2257                 case T_A_Expr:
2258                         retval = _equalAExpr(a, b);
2259                         break;
2260                 case T_ColumnRef:
2261                         retval = _equalColumnRef(a, b);
2262                         break;
2263                 case T_ParamRef:
2264                         retval = _equalParamRef(a, b);
2265                         break;
2266                 case T_A_Const:
2267                         retval = _equalAConst(a, b);
2268                         break;
2269                 case T_FuncCall:
2270                         retval = _equalFuncCall(a, b);
2271                         break;
2272                 case T_A_Indices:
2273                         retval = _equalAIndices(a, b);
2274                         break;
2275                 case T_A_Indirection:
2276                         retval = _equalA_Indirection(a, b);
2277                         break;
2278                 case T_ResTarget:
2279                         retval = _equalResTarget(a, b);
2280                         break;
2281                 case T_TypeCast:
2282                         retval = _equalTypeCast(a, b);
2283                         break;
2284                 case T_SortBy:
2285                         retval = _equalSortBy(a, b);
2286                         break;
2287                 case T_RangeSubselect:
2288                         retval = _equalRangeSubselect(a, b);
2289                         break;
2290                 case T_RangeFunction:
2291                         retval = _equalRangeFunction(a, b);
2292                         break;
2293                 case T_TypeName:
2294                         retval = _equalTypeName(a, b);
2295                         break;
2296                 case T_IndexElem:
2297                         retval = _equalIndexElem(a, b);
2298                         break;
2299                 case T_ColumnDef:
2300                         retval = _equalColumnDef(a, b);
2301                         break;
2302                 case T_Constraint:
2303                         retval = _equalConstraint(a, b);
2304                         break;
2305                 case T_DefElem:
2306                         retval = _equalDefElem(a, b);
2307                         break;
2308                 case T_LockingClause:
2309                         retval = _equalLockingClause(a, b);
2310                         break;
2311                 case T_RangeTblEntry:
2312                         retval = _equalRangeTblEntry(a, b);
2313                         break;
2314                 case T_SortClause:
2315                         retval = _equalSortClause(a, b);
2316                         break;
2317                 case T_GroupClause:
2318                         /* GroupClause is equivalent to SortClause */
2319                         retval = _equalSortClause(a, b);
2320                         break;
2321                 case T_RowMarkClause:
2322                         retval = _equalRowMarkClause(a, b);
2323                         break;
2324                 case T_FkConstraint:
2325                         retval = _equalFkConstraint(a, b);
2326                         break;
2327                 case T_PrivGrantee:
2328                         retval = _equalPrivGrantee(a, b);
2329                         break;
2330                 case T_FuncWithArgs:
2331                         retval = _equalFuncWithArgs(a, b);
2332                         break;
2333
2334                 default:
2335                         elog(ERROR, "unrecognized node type: %d",
2336                                  (int) nodeTag(a));
2337                         retval = false;         /* keep compiler quiet */
2338                         break;
2339         }
2340
2341         return retval;
2342 }