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