]> granicus.if.org Git - postgresql/blob - src/backend/nodes/equalfuncs.c
pgindent run for 8.2.
[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  *
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.285 2006/10/04 00:29:53 momjian 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(query);
867         COMPARE_NODE_FIELD(attlist);
868         COMPARE_SCALAR_FIELD(is_from);
869         COMPARE_STRING_FIELD(filename);
870         COMPARE_NODE_FIELD(options);
871
872         return true;
873 }
874
875 static bool
876 _equalCreateStmt(CreateStmt *a, CreateStmt *b)
877 {
878         COMPARE_NODE_FIELD(relation);
879         COMPARE_NODE_FIELD(tableElts);
880         COMPARE_NODE_FIELD(inhRelations);
881         COMPARE_NODE_FIELD(constraints);
882         COMPARE_NODE_FIELD(options);
883         COMPARE_SCALAR_FIELD(oncommit);
884         COMPARE_STRING_FIELD(tablespacename);
885
886         return true;
887 }
888
889 static bool
890 _equalInhRelation(InhRelation *a, InhRelation *b)
891 {
892         COMPARE_NODE_FIELD(relation);
893         COMPARE_NODE_FIELD(options);
894
895         return true;
896 }
897
898 static bool
899 _equalDefineStmt(DefineStmt *a, DefineStmt *b)
900 {
901         COMPARE_SCALAR_FIELD(kind);
902         COMPARE_SCALAR_FIELD(oldstyle);
903         COMPARE_NODE_FIELD(defnames);
904         COMPARE_NODE_FIELD(args);
905         COMPARE_NODE_FIELD(definition);
906
907         return true;
908 }
909
910 static bool
911 _equalDropStmt(DropStmt *a, DropStmt *b)
912 {
913         COMPARE_NODE_FIELD(objects);
914         COMPARE_SCALAR_FIELD(removeType);
915         COMPARE_SCALAR_FIELD(behavior);
916         COMPARE_SCALAR_FIELD(missing_ok);
917
918         return true;
919 }
920
921 static bool
922 _equalTruncateStmt(TruncateStmt *a, TruncateStmt *b)
923 {
924         COMPARE_NODE_FIELD(relations);
925         COMPARE_SCALAR_FIELD(behavior);
926
927         return true;
928 }
929
930 static bool
931 _equalCommentStmt(CommentStmt *a, CommentStmt *b)
932 {
933         COMPARE_SCALAR_FIELD(objtype);
934         COMPARE_NODE_FIELD(objname);
935         COMPARE_NODE_FIELD(objargs);
936         COMPARE_STRING_FIELD(comment);
937
938         return true;
939 }
940
941 static bool
942 _equalFetchStmt(FetchStmt *a, FetchStmt *b)
943 {
944         COMPARE_SCALAR_FIELD(direction);
945         COMPARE_SCALAR_FIELD(howMany);
946         COMPARE_STRING_FIELD(portalname);
947         COMPARE_SCALAR_FIELD(ismove);
948
949         return true;
950 }
951
952 static bool
953 _equalIndexStmt(IndexStmt *a, IndexStmt *b)
954 {
955         COMPARE_STRING_FIELD(idxname);
956         COMPARE_NODE_FIELD(relation);
957         COMPARE_STRING_FIELD(accessMethod);
958         COMPARE_STRING_FIELD(tableSpace);
959         COMPARE_NODE_FIELD(indexParams);
960         COMPARE_NODE_FIELD(options);
961         COMPARE_NODE_FIELD(whereClause);
962         COMPARE_NODE_FIELD(rangetable);
963         COMPARE_SCALAR_FIELD(unique);
964         COMPARE_SCALAR_FIELD(primary);
965         COMPARE_SCALAR_FIELD(isconstraint);
966         COMPARE_SCALAR_FIELD(concurrent);
967
968         return true;
969 }
970
971 static bool
972 _equalCreateFunctionStmt(CreateFunctionStmt *a, CreateFunctionStmt *b)
973 {
974         COMPARE_SCALAR_FIELD(replace);
975         COMPARE_NODE_FIELD(funcname);
976         COMPARE_NODE_FIELD(parameters);
977         COMPARE_NODE_FIELD(returnType);
978         COMPARE_NODE_FIELD(options);
979         COMPARE_NODE_FIELD(withClause);
980
981         return true;
982 }
983
984 static bool
985 _equalFunctionParameter(FunctionParameter *a, FunctionParameter *b)
986 {
987         COMPARE_STRING_FIELD(name);
988         COMPARE_NODE_FIELD(argType);
989         COMPARE_SCALAR_FIELD(mode);
990
991         return true;
992 }
993
994 static bool
995 _equalAlterFunctionStmt(AlterFunctionStmt *a, AlterFunctionStmt *b)
996 {
997         COMPARE_NODE_FIELD(func);
998         COMPARE_NODE_FIELD(actions);
999
1000         return true;
1001 }
1002
1003 static bool
1004 _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b)
1005 {
1006         COMPARE_SCALAR_FIELD(kind);
1007         COMPARE_NODE_FIELD(name);
1008         COMPARE_NODE_FIELD(args);
1009         COMPARE_SCALAR_FIELD(behavior);
1010         COMPARE_SCALAR_FIELD(missing_ok);
1011
1012         return true;
1013 }
1014
1015 static bool
1016 _equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b)
1017 {
1018         COMPARE_NODE_FIELD(opclassname);
1019         COMPARE_STRING_FIELD(amname);
1020         COMPARE_SCALAR_FIELD(behavior);
1021         COMPARE_SCALAR_FIELD(missing_ok);
1022
1023         return true;
1024 }
1025
1026 static bool
1027 _equalRenameStmt(RenameStmt *a, RenameStmt *b)
1028 {
1029         COMPARE_SCALAR_FIELD(renameType);
1030         COMPARE_NODE_FIELD(relation);
1031         COMPARE_NODE_FIELD(object);
1032         COMPARE_NODE_FIELD(objarg);
1033         COMPARE_STRING_FIELD(subname);
1034         COMPARE_STRING_FIELD(newname);
1035
1036         return true;
1037 }
1038
1039 static bool
1040 _equalAlterObjectSchemaStmt(AlterObjectSchemaStmt *a, AlterObjectSchemaStmt *b)
1041 {
1042         COMPARE_SCALAR_FIELD(objectType);
1043         COMPARE_NODE_FIELD(relation);
1044         COMPARE_NODE_FIELD(object);
1045         COMPARE_NODE_FIELD(objarg);
1046         COMPARE_STRING_FIELD(addname);
1047         COMPARE_STRING_FIELD(newschema);
1048
1049         return true;
1050 }
1051
1052 static bool
1053 _equalAlterOwnerStmt(AlterOwnerStmt *a, AlterOwnerStmt *b)
1054 {
1055         COMPARE_SCALAR_FIELD(objectType);
1056         COMPARE_NODE_FIELD(relation);
1057         COMPARE_NODE_FIELD(object);
1058         COMPARE_NODE_FIELD(objarg);
1059         COMPARE_STRING_FIELD(addname);
1060         COMPARE_STRING_FIELD(newowner);
1061
1062         return true;
1063 }
1064
1065 static bool
1066 _equalRuleStmt(RuleStmt *a, RuleStmt *b)
1067 {
1068         COMPARE_NODE_FIELD(relation);
1069         COMPARE_STRING_FIELD(rulename);
1070         COMPARE_NODE_FIELD(whereClause);
1071         COMPARE_SCALAR_FIELD(event);
1072         COMPARE_SCALAR_FIELD(instead);
1073         COMPARE_NODE_FIELD(actions);
1074         COMPARE_SCALAR_FIELD(replace);
1075
1076         return true;
1077 }
1078
1079 static bool
1080 _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
1081 {
1082         COMPARE_NODE_FIELD(relation);
1083
1084         return true;
1085 }
1086
1087 static bool
1088 _equalListenStmt(ListenStmt *a, ListenStmt *b)
1089 {
1090         COMPARE_NODE_FIELD(relation);
1091
1092         return true;
1093 }
1094
1095 static bool
1096 _equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
1097 {
1098         COMPARE_NODE_FIELD(relation);
1099
1100         return true;
1101 }
1102
1103 static bool
1104 _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
1105 {
1106         COMPARE_SCALAR_FIELD(kind);
1107         COMPARE_NODE_FIELD(options);
1108         COMPARE_STRING_FIELD(gid);
1109
1110         return true;
1111 }
1112
1113 static bool
1114 _equalCompositeTypeStmt(CompositeTypeStmt *a, CompositeTypeStmt *b)
1115 {
1116         COMPARE_NODE_FIELD(typevar);
1117         COMPARE_NODE_FIELD(coldeflist);
1118
1119         return true;
1120 }
1121
1122 static bool
1123 _equalViewStmt(ViewStmt *a, ViewStmt *b)
1124 {
1125         COMPARE_NODE_FIELD(view);
1126         COMPARE_NODE_FIELD(aliases);
1127         COMPARE_NODE_FIELD(query);
1128         COMPARE_SCALAR_FIELD(replace);
1129
1130         return true;
1131 }
1132
1133 static bool
1134 _equalLoadStmt(LoadStmt *a, LoadStmt *b)
1135 {
1136         COMPARE_STRING_FIELD(filename);
1137
1138         return true;
1139 }
1140
1141 static bool
1142 _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b)
1143 {
1144         COMPARE_NODE_FIELD(domainname);
1145         COMPARE_NODE_FIELD(typename);
1146         COMPARE_NODE_FIELD(constraints);
1147
1148         return true;
1149 }
1150
1151 static bool
1152 _equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b)
1153 {
1154         COMPARE_NODE_FIELD(opclassname);
1155         COMPARE_STRING_FIELD(amname);
1156         COMPARE_NODE_FIELD(datatype);
1157         COMPARE_NODE_FIELD(items);
1158         COMPARE_SCALAR_FIELD(isDefault);
1159
1160         return true;
1161 }
1162
1163 static bool
1164 _equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b)
1165 {
1166         COMPARE_SCALAR_FIELD(itemtype);
1167         COMPARE_NODE_FIELD(name);
1168         COMPARE_NODE_FIELD(args);
1169         COMPARE_SCALAR_FIELD(number);
1170         COMPARE_SCALAR_FIELD(recheck);
1171         COMPARE_NODE_FIELD(storedtype);
1172
1173         return true;
1174 }
1175
1176 static bool
1177 _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
1178 {
1179         COMPARE_STRING_FIELD(dbname);
1180         COMPARE_NODE_FIELD(options);
1181
1182         return true;
1183 }
1184
1185 static bool
1186 _equalAlterDatabaseStmt(AlterDatabaseStmt *a, AlterDatabaseStmt *b)
1187 {
1188         COMPARE_STRING_FIELD(dbname);
1189         COMPARE_NODE_FIELD(options);
1190
1191         return true;
1192 }
1193
1194 static bool
1195 _equalAlterDatabaseSetStmt(AlterDatabaseSetStmt *a, AlterDatabaseSetStmt *b)
1196 {
1197         COMPARE_STRING_FIELD(dbname);
1198         COMPARE_STRING_FIELD(variable);
1199         COMPARE_NODE_FIELD(value);
1200
1201         return true;
1202 }
1203
1204 static bool
1205 _equalDropdbStmt(DropdbStmt *a, DropdbStmt *b)
1206 {
1207         COMPARE_STRING_FIELD(dbname);
1208         COMPARE_SCALAR_FIELD(missing_ok);
1209
1210         return true;
1211 }
1212
1213 static bool
1214 _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
1215 {
1216         COMPARE_SCALAR_FIELD(vacuum);
1217         COMPARE_SCALAR_FIELD(full);
1218         COMPARE_SCALAR_FIELD(analyze);
1219         COMPARE_SCALAR_FIELD(freeze);
1220         COMPARE_SCALAR_FIELD(verbose);
1221         COMPARE_NODE_FIELD(relation);
1222         COMPARE_NODE_FIELD(va_cols);
1223
1224         return true;
1225 }
1226
1227 static bool
1228 _equalExplainStmt(ExplainStmt *a, ExplainStmt *b)
1229 {
1230         COMPARE_NODE_FIELD(query);
1231         COMPARE_SCALAR_FIELD(verbose);
1232         COMPARE_SCALAR_FIELD(analyze);
1233
1234         return true;
1235 }
1236
1237 static bool
1238 _equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b)
1239 {
1240         COMPARE_NODE_FIELD(sequence);
1241         COMPARE_NODE_FIELD(options);
1242
1243         return true;
1244 }
1245
1246 static bool
1247 _equalAlterSeqStmt(AlterSeqStmt *a, AlterSeqStmt *b)
1248 {
1249         COMPARE_NODE_FIELD(sequence);
1250         COMPARE_NODE_FIELD(options);
1251
1252         return true;
1253 }
1254
1255 static bool
1256 _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
1257 {
1258         COMPARE_STRING_FIELD(name);
1259         COMPARE_NODE_FIELD(args);
1260         COMPARE_SCALAR_FIELD(is_local);
1261
1262         return true;
1263 }
1264
1265 static bool
1266 _equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b)
1267 {
1268         COMPARE_STRING_FIELD(name);
1269
1270         return true;
1271 }
1272
1273 static bool
1274 _equalVariableResetStmt(VariableResetStmt *a, VariableResetStmt *b)
1275 {
1276         COMPARE_STRING_FIELD(name);
1277
1278         return true;
1279 }
1280
1281 static bool
1282 _equalCreateTableSpaceStmt(CreateTableSpaceStmt *a, CreateTableSpaceStmt *b)
1283 {
1284         COMPARE_STRING_FIELD(tablespacename);
1285         COMPARE_STRING_FIELD(owner);
1286         COMPARE_STRING_FIELD(location);
1287
1288         return true;
1289 }
1290
1291 static bool
1292 _equalDropTableSpaceStmt(DropTableSpaceStmt *a, DropTableSpaceStmt *b)
1293 {
1294         COMPARE_STRING_FIELD(tablespacename);
1295         COMPARE_SCALAR_FIELD(missing_ok);
1296
1297         return true;
1298 }
1299
1300 static bool
1301 _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b)
1302 {
1303         COMPARE_STRING_FIELD(trigname);
1304         COMPARE_NODE_FIELD(relation);
1305         COMPARE_NODE_FIELD(funcname);
1306         COMPARE_NODE_FIELD(args);
1307         COMPARE_SCALAR_FIELD(before);
1308         COMPARE_SCALAR_FIELD(row);
1309         if (strcmp(a->actions, b->actions) != 0)        /* in-line string field */
1310                 return false;
1311         COMPARE_SCALAR_FIELD(isconstraint);
1312         COMPARE_SCALAR_FIELD(deferrable);
1313         COMPARE_SCALAR_FIELD(initdeferred);
1314         COMPARE_NODE_FIELD(constrrel);
1315
1316         return true;
1317 }
1318
1319 static bool
1320 _equalDropPropertyStmt(DropPropertyStmt *a, DropPropertyStmt *b)
1321 {
1322         COMPARE_NODE_FIELD(relation);
1323         COMPARE_STRING_FIELD(property);
1324         COMPARE_SCALAR_FIELD(removeType);
1325         COMPARE_SCALAR_FIELD(behavior);
1326         COMPARE_SCALAR_FIELD(missing_ok);
1327
1328         return true;
1329 }
1330
1331 static bool
1332 _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b)
1333 {
1334         COMPARE_STRING_FIELD(plname);
1335         COMPARE_NODE_FIELD(plhandler);
1336         COMPARE_NODE_FIELD(plvalidator);
1337         COMPARE_SCALAR_FIELD(pltrusted);
1338
1339         return true;
1340 }
1341
1342 static bool
1343 _equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b)
1344 {
1345         COMPARE_STRING_FIELD(plname);
1346         COMPARE_SCALAR_FIELD(behavior);
1347         COMPARE_SCALAR_FIELD(missing_ok);
1348
1349         return true;
1350 }
1351
1352 static bool
1353 _equalCreateRoleStmt(CreateRoleStmt *a, CreateRoleStmt *b)
1354 {
1355         COMPARE_SCALAR_FIELD(stmt_type);
1356         COMPARE_STRING_FIELD(role);
1357         COMPARE_NODE_FIELD(options);
1358
1359         return true;
1360 }
1361
1362 static bool
1363 _equalAlterRoleStmt(AlterRoleStmt *a, AlterRoleStmt *b)
1364 {
1365         COMPARE_STRING_FIELD(role);
1366         COMPARE_NODE_FIELD(options);
1367         COMPARE_SCALAR_FIELD(action);
1368
1369         return true;
1370 }
1371
1372 static bool
1373 _equalAlterRoleSetStmt(AlterRoleSetStmt *a, AlterRoleSetStmt *b)
1374 {
1375         COMPARE_STRING_FIELD(role);
1376         COMPARE_STRING_FIELD(variable);
1377         COMPARE_NODE_FIELD(value);
1378
1379         return true;
1380 }
1381
1382 static bool
1383 _equalDropRoleStmt(DropRoleStmt *a, DropRoleStmt *b)
1384 {
1385         COMPARE_NODE_FIELD(roles);
1386         COMPARE_SCALAR_FIELD(missing_ok);
1387
1388         return true;
1389 }
1390
1391 static bool
1392 _equalLockStmt(LockStmt *a, LockStmt *b)
1393 {
1394         COMPARE_NODE_FIELD(relations);
1395         COMPARE_SCALAR_FIELD(mode);
1396         COMPARE_SCALAR_FIELD(nowait);
1397
1398         return true;
1399 }
1400
1401 static bool
1402 _equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b)
1403 {
1404         COMPARE_NODE_FIELD(constraints);
1405         COMPARE_SCALAR_FIELD(deferred);
1406
1407         return true;
1408 }
1409
1410 static bool
1411 _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
1412 {
1413         COMPARE_SCALAR_FIELD(kind);
1414         COMPARE_NODE_FIELD(relation);
1415         COMPARE_STRING_FIELD(name);
1416         COMPARE_SCALAR_FIELD(do_system);
1417         COMPARE_SCALAR_FIELD(do_user);
1418
1419         return true;
1420 }
1421
1422 static bool
1423 _equalCreateSchemaStmt(CreateSchemaStmt *a, CreateSchemaStmt *b)
1424 {
1425         COMPARE_STRING_FIELD(schemaname);
1426         COMPARE_STRING_FIELD(authid);
1427         COMPARE_NODE_FIELD(schemaElts);
1428
1429         return true;
1430 }
1431
1432 static bool
1433 _equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b)
1434 {
1435         COMPARE_NODE_FIELD(conversion_name);
1436         COMPARE_STRING_FIELD(for_encoding_name);
1437         COMPARE_STRING_FIELD(to_encoding_name);
1438         COMPARE_NODE_FIELD(func_name);
1439         COMPARE_SCALAR_FIELD(def);
1440
1441         return true;
1442 }
1443
1444 static bool
1445 _equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b)
1446 {
1447         COMPARE_NODE_FIELD(sourcetype);
1448         COMPARE_NODE_FIELD(targettype);
1449         COMPARE_NODE_FIELD(func);
1450         COMPARE_SCALAR_FIELD(context);
1451
1452         return true;
1453 }
1454
1455 static bool
1456 _equalDropCastStmt(DropCastStmt *a, DropCastStmt *b)
1457 {
1458         COMPARE_NODE_FIELD(sourcetype);
1459         COMPARE_NODE_FIELD(targettype);
1460         COMPARE_SCALAR_FIELD(behavior);
1461         COMPARE_SCALAR_FIELD(missing_ok);
1462
1463         return true;
1464 }
1465
1466 static bool
1467 _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b)
1468 {
1469         COMPARE_STRING_FIELD(name);
1470         COMPARE_NODE_FIELD(argtypes);
1471         COMPARE_NODE_FIELD(argtype_oids);
1472         COMPARE_NODE_FIELD(query);
1473
1474         return true;
1475 }
1476
1477 static bool
1478 _equalExecuteStmt(ExecuteStmt *a, ExecuteStmt *b)
1479 {
1480         COMPARE_STRING_FIELD(name);
1481         COMPARE_NODE_FIELD(into);
1482         COMPARE_NODE_FIELD(intoOptions);
1483         COMPARE_SCALAR_FIELD(into_on_commit);
1484         COMPARE_STRING_FIELD(into_tbl_space);
1485         COMPARE_NODE_FIELD(params);
1486
1487         return true;
1488 }
1489
1490 static bool
1491 _equalDeallocateStmt(DeallocateStmt *a, DeallocateStmt *b)
1492 {
1493         COMPARE_STRING_FIELD(name);
1494
1495         return true;
1496 }
1497
1498 static bool
1499 _equalDropOwnedStmt(DropOwnedStmt *a, DropOwnedStmt *b)
1500 {
1501         COMPARE_NODE_FIELD(roles);
1502         COMPARE_SCALAR_FIELD(behavior);
1503
1504         return true;
1505 }
1506
1507 static bool
1508 _equalReassignOwnedStmt(ReassignOwnedStmt *a, ReassignOwnedStmt *b)
1509 {
1510         COMPARE_NODE_FIELD(roles);
1511         COMPARE_NODE_FIELD(newrole);
1512
1513         return true;
1514 }
1515
1516 static bool
1517 _equalAExpr(A_Expr *a, A_Expr *b)
1518 {
1519         COMPARE_SCALAR_FIELD(kind);
1520         COMPARE_NODE_FIELD(name);
1521         COMPARE_NODE_FIELD(lexpr);
1522         COMPARE_NODE_FIELD(rexpr);
1523         COMPARE_SCALAR_FIELD(location);
1524
1525         return true;
1526 }
1527
1528 static bool
1529 _equalColumnRef(ColumnRef *a, ColumnRef *b)
1530 {
1531         COMPARE_NODE_FIELD(fields);
1532         COMPARE_SCALAR_FIELD(location);
1533
1534         return true;
1535 }
1536
1537 static bool
1538 _equalParamRef(ParamRef *a, ParamRef *b)
1539 {
1540         COMPARE_SCALAR_FIELD(number);
1541
1542         return true;
1543 }
1544
1545 static bool
1546 _equalAConst(A_Const *a, A_Const *b)
1547 {
1548         if (!equal(&a->val, &b->val))           /* hack for in-line Value field */
1549                 return false;
1550         COMPARE_NODE_FIELD(typename);
1551
1552         return true;
1553 }
1554
1555 static bool
1556 _equalFuncCall(FuncCall *a, FuncCall *b)
1557 {
1558         COMPARE_NODE_FIELD(funcname);
1559         COMPARE_NODE_FIELD(args);
1560         COMPARE_SCALAR_FIELD(agg_star);
1561         COMPARE_SCALAR_FIELD(agg_distinct);
1562         COMPARE_SCALAR_FIELD(location);
1563
1564         return true;
1565 }
1566
1567 static bool
1568 _equalAIndices(A_Indices *a, A_Indices *b)
1569 {
1570         COMPARE_NODE_FIELD(lidx);
1571         COMPARE_NODE_FIELD(uidx);
1572
1573         return true;
1574 }
1575
1576 static bool
1577 _equalA_Indirection(A_Indirection *a, A_Indirection *b)
1578 {
1579         COMPARE_NODE_FIELD(arg);
1580         COMPARE_NODE_FIELD(indirection);
1581
1582         return true;
1583 }
1584
1585 static bool
1586 _equalResTarget(ResTarget *a, ResTarget *b)
1587 {
1588         COMPARE_STRING_FIELD(name);
1589         COMPARE_NODE_FIELD(indirection);
1590         COMPARE_NODE_FIELD(val);
1591         COMPARE_SCALAR_FIELD(location);
1592
1593         return true;
1594 }
1595
1596 static bool
1597 _equalTypeName(TypeName *a, TypeName *b)
1598 {
1599         COMPARE_NODE_FIELD(names);
1600         COMPARE_SCALAR_FIELD(typeid);
1601         COMPARE_SCALAR_FIELD(timezone);
1602         COMPARE_SCALAR_FIELD(setof);
1603         COMPARE_SCALAR_FIELD(pct_type);
1604         COMPARE_SCALAR_FIELD(typmod);
1605         COMPARE_NODE_FIELD(arrayBounds);
1606         COMPARE_SCALAR_FIELD(location);
1607
1608         return true;
1609 }
1610
1611 static bool
1612 _equalTypeCast(TypeCast *a, TypeCast *b)
1613 {
1614         COMPARE_NODE_FIELD(arg);
1615         COMPARE_NODE_FIELD(typename);
1616
1617         return true;
1618 }
1619
1620 static bool
1621 _equalSortBy(SortBy *a, SortBy *b)
1622 {
1623         COMPARE_SCALAR_FIELD(sortby_kind);
1624         COMPARE_NODE_FIELD(useOp);
1625         COMPARE_NODE_FIELD(node);
1626
1627         return true;
1628 }
1629
1630 static bool
1631 _equalRangeSubselect(RangeSubselect *a, RangeSubselect *b)
1632 {
1633         COMPARE_NODE_FIELD(subquery);
1634         COMPARE_NODE_FIELD(alias);
1635
1636         return true;
1637 }
1638
1639 static bool
1640 _equalRangeFunction(RangeFunction *a, RangeFunction *b)
1641 {
1642         COMPARE_NODE_FIELD(funccallnode);
1643         COMPARE_NODE_FIELD(alias);
1644         COMPARE_NODE_FIELD(coldeflist);
1645
1646         return true;
1647 }
1648
1649 static bool
1650 _equalIndexElem(IndexElem *a, IndexElem *b)
1651 {
1652         COMPARE_STRING_FIELD(name);
1653         COMPARE_NODE_FIELD(expr);
1654         COMPARE_NODE_FIELD(opclass);
1655
1656         return true;
1657 }
1658
1659 static bool
1660 _equalColumnDef(ColumnDef *a, ColumnDef *b)
1661 {
1662         COMPARE_STRING_FIELD(colname);
1663         COMPARE_NODE_FIELD(typename);
1664         COMPARE_SCALAR_FIELD(inhcount);
1665         COMPARE_SCALAR_FIELD(is_local);
1666         COMPARE_SCALAR_FIELD(is_not_null);
1667         COMPARE_NODE_FIELD(raw_default);
1668         COMPARE_STRING_FIELD(cooked_default);
1669         COMPARE_NODE_FIELD(constraints);
1670
1671         return true;
1672 }
1673
1674 static bool
1675 _equalConstraint(Constraint *a, Constraint *b)
1676 {
1677         COMPARE_SCALAR_FIELD(contype);
1678         COMPARE_STRING_FIELD(name);
1679         COMPARE_NODE_FIELD(raw_expr);
1680         COMPARE_STRING_FIELD(cooked_expr);
1681         COMPARE_NODE_FIELD(keys);
1682         COMPARE_NODE_FIELD(options);
1683         COMPARE_STRING_FIELD(indexspace);
1684
1685         return true;
1686 }
1687
1688 static bool
1689 _equalDefElem(DefElem *a, DefElem *b)
1690 {
1691         COMPARE_STRING_FIELD(defname);
1692         COMPARE_NODE_FIELD(arg);
1693
1694         return true;
1695 }
1696
1697 static bool
1698 _equalLockingClause(LockingClause *a, LockingClause *b)
1699 {
1700         COMPARE_NODE_FIELD(lockedRels);
1701         COMPARE_SCALAR_FIELD(forUpdate);
1702         COMPARE_SCALAR_FIELD(noWait);
1703
1704         return true;
1705 }
1706
1707 static bool
1708 _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
1709 {
1710         COMPARE_SCALAR_FIELD(rtekind);
1711         COMPARE_SCALAR_FIELD(relid);
1712         COMPARE_NODE_FIELD(subquery);
1713         COMPARE_NODE_FIELD(funcexpr);
1714         COMPARE_NODE_FIELD(funccoltypes);
1715         COMPARE_NODE_FIELD(funccoltypmods);
1716         COMPARE_NODE_FIELD(values_lists);
1717         COMPARE_SCALAR_FIELD(jointype);
1718         COMPARE_NODE_FIELD(joinaliasvars);
1719         COMPARE_NODE_FIELD(alias);
1720         COMPARE_NODE_FIELD(eref);
1721         COMPARE_SCALAR_FIELD(inh);
1722         COMPARE_SCALAR_FIELD(inFromCl);
1723         COMPARE_SCALAR_FIELD(requiredPerms);
1724         COMPARE_SCALAR_FIELD(checkAsUser);
1725
1726         return true;
1727 }
1728
1729 static bool
1730 _equalSortClause(SortClause *a, SortClause *b)
1731 {
1732         COMPARE_SCALAR_FIELD(tleSortGroupRef);
1733         COMPARE_SCALAR_FIELD(sortop);
1734
1735         return true;
1736 }
1737
1738 static bool
1739 _equalRowMarkClause(RowMarkClause *a, RowMarkClause *b)
1740 {
1741         COMPARE_SCALAR_FIELD(rti);
1742         COMPARE_SCALAR_FIELD(forUpdate);
1743         COMPARE_SCALAR_FIELD(noWait);
1744
1745         return true;
1746 }
1747
1748 static bool
1749 _equalFkConstraint(FkConstraint *a, FkConstraint *b)
1750 {
1751         COMPARE_STRING_FIELD(constr_name);
1752         COMPARE_NODE_FIELD(pktable);
1753         COMPARE_NODE_FIELD(fk_attrs);
1754         COMPARE_NODE_FIELD(pk_attrs);
1755         COMPARE_SCALAR_FIELD(fk_matchtype);
1756         COMPARE_SCALAR_FIELD(fk_upd_action);
1757         COMPARE_SCALAR_FIELD(fk_del_action);
1758         COMPARE_SCALAR_FIELD(deferrable);
1759         COMPARE_SCALAR_FIELD(initdeferred);
1760         COMPARE_SCALAR_FIELD(skip_validation);
1761
1762         return true;
1763 }
1764
1765
1766 /*
1767  * Stuff from pg_list.h
1768  */
1769
1770 static bool
1771 _equalList(List *a, List *b)
1772 {
1773         ListCell   *item_a;
1774         ListCell   *item_b;
1775
1776         /*
1777          * Try to reject by simple scalar checks before grovelling through all the
1778          * list elements...
1779          */
1780         COMPARE_SCALAR_FIELD(type);
1781         COMPARE_SCALAR_FIELD(length);
1782
1783         /*
1784          * We place the switch outside the loop for the sake of efficiency; this
1785          * may not be worth doing...
1786          */
1787         switch (a->type)
1788         {
1789                 case T_List:
1790                         forboth(item_a, a, item_b, b)
1791                         {
1792                                 if (!equal(lfirst(item_a), lfirst(item_b)))
1793                                         return false;
1794                         }
1795                         break;
1796                 case T_IntList:
1797                         forboth(item_a, a, item_b, b)
1798                         {
1799                                 if (lfirst_int(item_a) != lfirst_int(item_b))
1800                                         return false;
1801                         }
1802                         break;
1803                 case T_OidList:
1804                         forboth(item_a, a, item_b, b)
1805                         {
1806                                 if (lfirst_oid(item_a) != lfirst_oid(item_b))
1807                                         return false;
1808                         }
1809                         break;
1810                 default:
1811                         elog(ERROR, "unrecognized list node type: %d",
1812                                  (int) a->type);
1813                         return false;           /* keep compiler quiet */
1814         }
1815
1816         /*
1817          * If we got here, we should have run out of elements of both lists
1818          */
1819         Assert(item_a == NULL);
1820         Assert(item_b == NULL);
1821
1822         return true;
1823 }
1824
1825 /*
1826  * Stuff from value.h
1827  */
1828
1829 static bool
1830 _equalValue(Value *a, Value *b)
1831 {
1832         COMPARE_SCALAR_FIELD(type);
1833
1834         switch (a->type)
1835         {
1836                 case T_Integer:
1837                         COMPARE_SCALAR_FIELD(val.ival);
1838                         break;
1839                 case T_Float:
1840                 case T_String:
1841                 case T_BitString:
1842                         COMPARE_STRING_FIELD(val.str);
1843                         break;
1844                 case T_Null:
1845                         /* nothing to do */
1846                         break;
1847                 default:
1848                         elog(ERROR, "unrecognized node type: %d", (int) a->type);
1849                         break;
1850         }
1851
1852         return true;
1853 }
1854
1855 /*
1856  * equal
1857  *        returns whether two nodes are equal
1858  */
1859 bool
1860 equal(void *a, void *b)
1861 {
1862         bool            retval;
1863
1864         if (a == b)
1865                 return true;
1866
1867         /*
1868          * note that a!=b, so only one of them can be NULL
1869          */
1870         if (a == NULL || b == NULL)
1871                 return false;
1872
1873         /*
1874          * are they the same type of nodes?
1875          */
1876         if (nodeTag(a) != nodeTag(b))
1877                 return false;
1878
1879         switch (nodeTag(a))
1880         {
1881                         /*
1882                          * PRIMITIVE NODES
1883                          */
1884                 case T_Alias:
1885                         retval = _equalAlias(a, b);
1886                         break;
1887                 case T_RangeVar:
1888                         retval = _equalRangeVar(a, b);
1889                         break;
1890                 case T_Var:
1891                         retval = _equalVar(a, b);
1892                         break;
1893                 case T_Const:
1894                         retval = _equalConst(a, b);
1895                         break;
1896                 case T_Param:
1897                         retval = _equalParam(a, b);
1898                         break;
1899                 case T_Aggref:
1900                         retval = _equalAggref(a, b);
1901                         break;
1902                 case T_ArrayRef:
1903                         retval = _equalArrayRef(a, b);
1904                         break;
1905                 case T_FuncExpr:
1906                         retval = _equalFuncExpr(a, b);
1907                         break;
1908                 case T_OpExpr:
1909                         retval = _equalOpExpr(a, b);
1910                         break;
1911                 case T_DistinctExpr:
1912                         retval = _equalDistinctExpr(a, b);
1913                         break;
1914                 case T_ScalarArrayOpExpr:
1915                         retval = _equalScalarArrayOpExpr(a, b);
1916                         break;
1917                 case T_BoolExpr:
1918                         retval = _equalBoolExpr(a, b);
1919                         break;
1920                 case T_SubLink:
1921                         retval = _equalSubLink(a, b);
1922                         break;
1923                 case T_SubPlan:
1924                         retval = _equalSubPlan(a, b);
1925                         break;
1926                 case T_FieldSelect:
1927                         retval = _equalFieldSelect(a, b);
1928                         break;
1929                 case T_FieldStore:
1930                         retval = _equalFieldStore(a, b);
1931                         break;
1932                 case T_RelabelType:
1933                         retval = _equalRelabelType(a, b);
1934                         break;
1935                 case T_ConvertRowtypeExpr:
1936                         retval = _equalConvertRowtypeExpr(a, b);
1937                         break;
1938                 case T_CaseExpr:
1939                         retval = _equalCaseExpr(a, b);
1940                         break;
1941                 case T_CaseWhen:
1942                         retval = _equalCaseWhen(a, b);
1943                         break;
1944                 case T_CaseTestExpr:
1945                         retval = _equalCaseTestExpr(a, b);
1946                         break;
1947                 case T_ArrayExpr:
1948                         retval = _equalArrayExpr(a, b);
1949                         break;
1950                 case T_RowExpr:
1951                         retval = _equalRowExpr(a, b);
1952                         break;
1953                 case T_RowCompareExpr:
1954                         retval = _equalRowCompareExpr(a, b);
1955                         break;
1956                 case T_CoalesceExpr:
1957                         retval = _equalCoalesceExpr(a, b);
1958                         break;
1959                 case T_MinMaxExpr:
1960                         retval = _equalMinMaxExpr(a, b);
1961                         break;
1962                 case T_NullIfExpr:
1963                         retval = _equalNullIfExpr(a, b);
1964                         break;
1965                 case T_NullTest:
1966                         retval = _equalNullTest(a, b);
1967                         break;
1968                 case T_BooleanTest:
1969                         retval = _equalBooleanTest(a, b);
1970                         break;
1971                 case T_CoerceToDomain:
1972                         retval = _equalCoerceToDomain(a, b);
1973                         break;
1974                 case T_CoerceToDomainValue:
1975                         retval = _equalCoerceToDomainValue(a, b);
1976                         break;
1977                 case T_SetToDefault:
1978                         retval = _equalSetToDefault(a, b);
1979                         break;
1980                 case T_TargetEntry:
1981                         retval = _equalTargetEntry(a, b);
1982                         break;
1983                 case T_RangeTblRef:
1984                         retval = _equalRangeTblRef(a, b);
1985                         break;
1986                 case T_FromExpr:
1987                         retval = _equalFromExpr(a, b);
1988                         break;
1989                 case T_JoinExpr:
1990                         retval = _equalJoinExpr(a, b);
1991                         break;
1992
1993                         /*
1994                          * RELATION NODES
1995                          */
1996                 case T_PathKeyItem:
1997                         retval = _equalPathKeyItem(a, b);
1998                         break;
1999                 case T_RestrictInfo:
2000                         retval = _equalRestrictInfo(a, b);
2001                         break;
2002                 case T_OuterJoinInfo:
2003                         retval = _equalOuterJoinInfo(a, b);
2004                         break;
2005                 case T_InClauseInfo:
2006                         retval = _equalInClauseInfo(a, b);
2007                         break;
2008                 case T_AppendRelInfo:
2009                         retval = _equalAppendRelInfo(a, b);
2010                         break;
2011                 case T_List:
2012                 case T_IntList:
2013                 case T_OidList:
2014                         retval = _equalList(a, b);
2015                         break;
2016
2017                 case T_Integer:
2018                 case T_Float:
2019                 case T_String:
2020                 case T_BitString:
2021                 case T_Null:
2022                         retval = _equalValue(a, b);
2023                         break;
2024
2025                         /*
2026                          * PARSE NODES
2027                          */
2028                 case T_Query:
2029                         retval = _equalQuery(a, b);
2030                         break;
2031                 case T_InsertStmt:
2032                         retval = _equalInsertStmt(a, b);
2033                         break;
2034                 case T_DeleteStmt:
2035                         retval = _equalDeleteStmt(a, b);
2036                         break;
2037                 case T_UpdateStmt:
2038                         retval = _equalUpdateStmt(a, b);
2039                         break;
2040                 case T_SelectStmt:
2041                         retval = _equalSelectStmt(a, b);
2042                         break;
2043                 case T_SetOperationStmt:
2044                         retval = _equalSetOperationStmt(a, b);
2045                         break;
2046                 case T_AlterTableStmt:
2047                         retval = _equalAlterTableStmt(a, b);
2048                         break;
2049                 case T_AlterTableCmd:
2050                         retval = _equalAlterTableCmd(a, b);
2051                         break;
2052                 case T_AlterDomainStmt:
2053                         retval = _equalAlterDomainStmt(a, b);
2054                         break;
2055                 case T_GrantStmt:
2056                         retval = _equalGrantStmt(a, b);
2057                         break;
2058                 case T_GrantRoleStmt:
2059                         retval = _equalGrantRoleStmt(a, b);
2060                         break;
2061                 case T_DeclareCursorStmt:
2062                         retval = _equalDeclareCursorStmt(a, b);
2063                         break;
2064                 case T_ClosePortalStmt:
2065                         retval = _equalClosePortalStmt(a, b);
2066                         break;
2067                 case T_ClusterStmt:
2068                         retval = _equalClusterStmt(a, b);
2069                         break;
2070                 case T_CopyStmt:
2071                         retval = _equalCopyStmt(a, b);
2072                         break;
2073                 case T_CreateStmt:
2074                         retval = _equalCreateStmt(a, b);
2075                         break;
2076                 case T_InhRelation:
2077                         retval = _equalInhRelation(a, b);
2078                         break;
2079                 case T_DefineStmt:
2080                         retval = _equalDefineStmt(a, b);
2081                         break;
2082                 case T_DropStmt:
2083                         retval = _equalDropStmt(a, b);
2084                         break;
2085                 case T_TruncateStmt:
2086                         retval = _equalTruncateStmt(a, b);
2087                         break;
2088                 case T_CommentStmt:
2089                         retval = _equalCommentStmt(a, b);
2090                         break;
2091                 case T_FetchStmt:
2092                         retval = _equalFetchStmt(a, b);
2093                         break;
2094                 case T_IndexStmt:
2095                         retval = _equalIndexStmt(a, b);
2096                         break;
2097                 case T_CreateFunctionStmt:
2098                         retval = _equalCreateFunctionStmt(a, b);
2099                         break;
2100                 case T_FunctionParameter:
2101                         retval = _equalFunctionParameter(a, b);
2102                         break;
2103                 case T_AlterFunctionStmt:
2104                         retval = _equalAlterFunctionStmt(a, b);
2105                         break;
2106                 case T_RemoveFuncStmt:
2107                         retval = _equalRemoveFuncStmt(a, b);
2108                         break;
2109                 case T_RemoveOpClassStmt:
2110                         retval = _equalRemoveOpClassStmt(a, b);
2111                         break;
2112                 case T_RenameStmt:
2113                         retval = _equalRenameStmt(a, b);
2114                         break;
2115                 case T_AlterObjectSchemaStmt:
2116                         retval = _equalAlterObjectSchemaStmt(a, b);
2117                         break;
2118                 case T_AlterOwnerStmt:
2119                         retval = _equalAlterOwnerStmt(a, b);
2120                         break;
2121                 case T_RuleStmt:
2122                         retval = _equalRuleStmt(a, b);
2123                         break;
2124                 case T_NotifyStmt:
2125                         retval = _equalNotifyStmt(a, b);
2126                         break;
2127                 case T_ListenStmt:
2128                         retval = _equalListenStmt(a, b);
2129                         break;
2130                 case T_UnlistenStmt:
2131                         retval = _equalUnlistenStmt(a, b);
2132                         break;
2133                 case T_TransactionStmt:
2134                         retval = _equalTransactionStmt(a, b);
2135                         break;
2136                 case T_CompositeTypeStmt:
2137                         retval = _equalCompositeTypeStmt(a, b);
2138                         break;
2139                 case T_ViewStmt:
2140                         retval = _equalViewStmt(a, b);
2141                         break;
2142                 case T_LoadStmt:
2143                         retval = _equalLoadStmt(a, b);
2144                         break;
2145                 case T_CreateDomainStmt:
2146                         retval = _equalCreateDomainStmt(a, b);
2147                         break;
2148                 case T_CreateOpClassStmt:
2149                         retval = _equalCreateOpClassStmt(a, b);
2150                         break;
2151                 case T_CreateOpClassItem:
2152                         retval = _equalCreateOpClassItem(a, b);
2153                         break;
2154                 case T_CreatedbStmt:
2155                         retval = _equalCreatedbStmt(a, b);
2156                         break;
2157                 case T_AlterDatabaseStmt:
2158                         retval = _equalAlterDatabaseStmt(a, b);
2159                         break;
2160                 case T_AlterDatabaseSetStmt:
2161                         retval = _equalAlterDatabaseSetStmt(a, b);
2162                         break;
2163                 case T_DropdbStmt:
2164                         retval = _equalDropdbStmt(a, b);
2165                         break;
2166                 case T_VacuumStmt:
2167                         retval = _equalVacuumStmt(a, b);
2168                         break;
2169                 case T_ExplainStmt:
2170                         retval = _equalExplainStmt(a, b);
2171                         break;
2172                 case T_CreateSeqStmt:
2173                         retval = _equalCreateSeqStmt(a, b);
2174                         break;
2175                 case T_AlterSeqStmt:
2176                         retval = _equalAlterSeqStmt(a, b);
2177                         break;
2178                 case T_VariableSetStmt:
2179                         retval = _equalVariableSetStmt(a, b);
2180                         break;
2181                 case T_VariableShowStmt:
2182                         retval = _equalVariableShowStmt(a, b);
2183                         break;
2184                 case T_VariableResetStmt:
2185                         retval = _equalVariableResetStmt(a, b);
2186                         break;
2187                 case T_CreateTableSpaceStmt:
2188                         retval = _equalCreateTableSpaceStmt(a, b);
2189                         break;
2190                 case T_DropTableSpaceStmt:
2191                         retval = _equalDropTableSpaceStmt(a, b);
2192                         break;
2193                 case T_CreateTrigStmt:
2194                         retval = _equalCreateTrigStmt(a, b);
2195                         break;
2196                 case T_DropPropertyStmt:
2197                         retval = _equalDropPropertyStmt(a, b);
2198                         break;
2199                 case T_CreatePLangStmt:
2200                         retval = _equalCreatePLangStmt(a, b);
2201                         break;
2202                 case T_DropPLangStmt:
2203                         retval = _equalDropPLangStmt(a, b);
2204                         break;
2205                 case T_CreateRoleStmt:
2206                         retval = _equalCreateRoleStmt(a, b);
2207                         break;
2208                 case T_AlterRoleStmt:
2209                         retval = _equalAlterRoleStmt(a, b);
2210                         break;
2211                 case T_AlterRoleSetStmt:
2212                         retval = _equalAlterRoleSetStmt(a, b);
2213                         break;
2214                 case T_DropRoleStmt:
2215                         retval = _equalDropRoleStmt(a, b);
2216                         break;
2217                 case T_LockStmt:
2218                         retval = _equalLockStmt(a, b);
2219                         break;
2220                 case T_ConstraintsSetStmt:
2221                         retval = _equalConstraintsSetStmt(a, b);
2222                         break;
2223                 case T_ReindexStmt:
2224                         retval = _equalReindexStmt(a, b);
2225                         break;
2226                 case T_CheckPointStmt:
2227                         retval = true;
2228                         break;
2229                 case T_CreateSchemaStmt:
2230                         retval = _equalCreateSchemaStmt(a, b);
2231                         break;
2232                 case T_CreateConversionStmt:
2233                         retval = _equalCreateConversionStmt(a, b);
2234                         break;
2235                 case T_CreateCastStmt:
2236                         retval = _equalCreateCastStmt(a, b);
2237                         break;
2238                 case T_DropCastStmt:
2239                         retval = _equalDropCastStmt(a, b);
2240                         break;
2241                 case T_PrepareStmt:
2242                         retval = _equalPrepareStmt(a, b);
2243                         break;
2244                 case T_ExecuteStmt:
2245                         retval = _equalExecuteStmt(a, b);
2246                         break;
2247                 case T_DeallocateStmt:
2248                         retval = _equalDeallocateStmt(a, b);
2249                         break;
2250                 case T_DropOwnedStmt:
2251                         retval = _equalDropOwnedStmt(a, b);
2252                         break;
2253
2254                 case T_ReassignOwnedStmt:
2255                         retval = _equalReassignOwnedStmt(a, b);
2256                         break;
2257
2258                 case T_A_Expr:
2259                         retval = _equalAExpr(a, b);
2260                         break;
2261                 case T_ColumnRef:
2262                         retval = _equalColumnRef(a, b);
2263                         break;
2264                 case T_ParamRef:
2265                         retval = _equalParamRef(a, b);
2266                         break;
2267                 case T_A_Const:
2268                         retval = _equalAConst(a, b);
2269                         break;
2270                 case T_FuncCall:
2271                         retval = _equalFuncCall(a, b);
2272                         break;
2273                 case T_A_Indices:
2274                         retval = _equalAIndices(a, b);
2275                         break;
2276                 case T_A_Indirection:
2277                         retval = _equalA_Indirection(a, b);
2278                         break;
2279                 case T_ResTarget:
2280                         retval = _equalResTarget(a, b);
2281                         break;
2282                 case T_TypeCast:
2283                         retval = _equalTypeCast(a, b);
2284                         break;
2285                 case T_SortBy:
2286                         retval = _equalSortBy(a, b);
2287                         break;
2288                 case T_RangeSubselect:
2289                         retval = _equalRangeSubselect(a, b);
2290                         break;
2291                 case T_RangeFunction:
2292                         retval = _equalRangeFunction(a, b);
2293                         break;
2294                 case T_TypeName:
2295                         retval = _equalTypeName(a, b);
2296                         break;
2297                 case T_IndexElem:
2298                         retval = _equalIndexElem(a, b);
2299                         break;
2300                 case T_ColumnDef:
2301                         retval = _equalColumnDef(a, b);
2302                         break;
2303                 case T_Constraint:
2304                         retval = _equalConstraint(a, b);
2305                         break;
2306                 case T_DefElem:
2307                         retval = _equalDefElem(a, b);
2308                         break;
2309                 case T_LockingClause:
2310                         retval = _equalLockingClause(a, b);
2311                         break;
2312                 case T_RangeTblEntry:
2313                         retval = _equalRangeTblEntry(a, b);
2314                         break;
2315                 case T_SortClause:
2316                         retval = _equalSortClause(a, b);
2317                         break;
2318                 case T_GroupClause:
2319                         /* GroupClause is equivalent to SortClause */
2320                         retval = _equalSortClause(a, b);
2321                         break;
2322                 case T_RowMarkClause:
2323                         retval = _equalRowMarkClause(a, b);
2324                         break;
2325                 case T_FkConstraint:
2326                         retval = _equalFkConstraint(a, b);
2327                         break;
2328                 case T_PrivGrantee:
2329                         retval = _equalPrivGrantee(a, b);
2330                         break;
2331                 case T_FuncWithArgs:
2332                         retval = _equalFuncWithArgs(a, b);
2333                         break;
2334
2335                 default:
2336                         elog(ERROR, "unrecognized node type: %d",
2337                                  (int) nodeTag(a));
2338                         retval = false;         /* keep compiler quiet */
2339                         break;
2340         }
2341
2342         return retval;
2343 }