]> granicus.if.org Git - postgresql/blob - src/backend/nodes/equalfuncs.c
Support the syntax
[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.269 2006/04/15 17:45:34 tgl Exp $
22  *
23  *-------------------------------------------------------------------------
24  */
25
26 #include "postgres.h"
27
28 #include "nodes/params.h"
29 #include "nodes/parsenodes.h"
30 #include "nodes/relation.h"
31 #include "utils/datum.h"
32
33
34 /*
35  * Macros to simplify comparison of different kinds of fields.  Use these
36  * wherever possible to reduce the chance for silly typos.      Note that these
37  * hard-wire the convention that the local variables in an Equal routine are
38  * named 'a' and 'b'.
39  */
40
41 /* Compare a simple scalar field (int, float, bool, enum, etc) */
42 #define COMPARE_SCALAR_FIELD(fldname) \
43         do { \
44                 if (a->fldname != b->fldname) \
45                         return false; \
46         } while (0)
47
48 /* Compare a field that is a pointer to some kind of Node or Node tree */
49 #define COMPARE_NODE_FIELD(fldname) \
50         do { \
51                 if (!equal(a->fldname, b->fldname)) \
52                         return false; \
53         } while (0)
54
55 /* Compare a field that is a pointer to a Bitmapset */
56 #define COMPARE_BITMAPSET_FIELD(fldname) \
57         do { \
58                 if (!bms_equal(a->fldname, b->fldname)) \
59                         return false; \
60         } while (0)
61
62 /* Compare a field that is a pointer to a C string, or perhaps NULL */
63 #define COMPARE_STRING_FIELD(fldname) \
64         do { \
65                 if (!equalstr(a->fldname, b->fldname)) \
66                         return false; \
67         } while (0)
68
69 /* Macro for comparing string fields that might be NULL */
70 #define equalstr(a, b)  \
71         (((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
72
73 /* Compare a field that is a pointer to a simple palloc'd object of size sz */
74 #define COMPARE_POINTER_FIELD(fldname, sz) \
75         do { \
76                 if (memcmp(a->fldname, b->fldname, (sz)) != 0) \
77                         return false; \
78         } while (0)
79
80
81 /*
82  *      Stuff from primnodes.h
83  */
84
85 static bool
86 _equalAlias(Alias *a, Alias *b)
87 {
88         COMPARE_STRING_FIELD(aliasname);
89         COMPARE_NODE_FIELD(colnames);
90
91         return true;
92 }
93
94 static bool
95 _equalRangeVar(RangeVar *a, RangeVar *b)
96 {
97         COMPARE_STRING_FIELD(catalogname);
98         COMPARE_STRING_FIELD(schemaname);
99         COMPARE_STRING_FIELD(relname);
100         COMPARE_SCALAR_FIELD(inhOpt);
101         COMPARE_SCALAR_FIELD(istemp);
102         COMPARE_NODE_FIELD(alias);
103
104         return true;
105 }
106
107 /*
108  * We don't need an _equalExpr because Expr is an abstract supertype which
109  * should never actually get instantiated.      Also, since it has no common
110  * fields except NodeTag, there's no need for a helper routine to factor
111  * out comparing the common fields...
112  */
113
114 static bool
115 _equalVar(Var *a, Var *b)
116 {
117         COMPARE_SCALAR_FIELD(varno);
118         COMPARE_SCALAR_FIELD(varattno);
119         COMPARE_SCALAR_FIELD(vartype);
120         COMPARE_SCALAR_FIELD(vartypmod);
121         COMPARE_SCALAR_FIELD(varlevelsup);
122         COMPARE_SCALAR_FIELD(varnoold);
123         COMPARE_SCALAR_FIELD(varoattno);
124
125         return true;
126 }
127
128 static bool
129 _equalConst(Const *a, Const *b)
130 {
131         COMPARE_SCALAR_FIELD(consttype);
132         COMPARE_SCALAR_FIELD(constlen);
133         COMPARE_SCALAR_FIELD(constisnull);
134         COMPARE_SCALAR_FIELD(constbyval);
135
136         /*
137          * We treat all NULL constants of the same type as equal. Someday this
138          * might need to change?  But datumIsEqual doesn't work on nulls, so...
139          */
140         if (a->constisnull)
141                 return true;
142         return datumIsEqual(a->constvalue, b->constvalue,
143                                                 a->constbyval, a->constlen);
144 }
145
146 static bool
147 _equalParam(Param *a, Param *b)
148 {
149         COMPARE_SCALAR_FIELD(paramkind);
150         COMPARE_SCALAR_FIELD(paramtype);
151
152         switch (a->paramkind)
153         {
154                 case PARAM_NAMED:
155                         COMPARE_STRING_FIELD(paramname);
156                         break;
157                 case PARAM_NUM:
158                 case PARAM_EXEC:
159                 case PARAM_SUBLINK:
160                         COMPARE_SCALAR_FIELD(paramid);
161                         break;
162                 default:
163                         elog(ERROR, "unrecognized paramkind: %d",
164                                  a->paramkind);
165         }
166
167         return true;
168 }
169
170 static bool
171 _equalAggref(Aggref *a, Aggref *b)
172 {
173         COMPARE_SCALAR_FIELD(aggfnoid);
174         COMPARE_SCALAR_FIELD(aggtype);
175         COMPARE_NODE_FIELD(target);
176         COMPARE_SCALAR_FIELD(agglevelsup);
177         COMPARE_SCALAR_FIELD(aggstar);
178         COMPARE_SCALAR_FIELD(aggdistinct);
179
180         return true;
181 }
182
183 static bool
184 _equalArrayRef(ArrayRef *a, ArrayRef *b)
185 {
186         COMPARE_SCALAR_FIELD(refrestype);
187         COMPARE_SCALAR_FIELD(refarraytype);
188         COMPARE_SCALAR_FIELD(refelemtype);
189         COMPARE_NODE_FIELD(refupperindexpr);
190         COMPARE_NODE_FIELD(reflowerindexpr);
191         COMPARE_NODE_FIELD(refexpr);
192         COMPARE_NODE_FIELD(refassgnexpr);
193
194         return true;
195 }
196
197 static bool
198 _equalFuncExpr(FuncExpr *a, FuncExpr *b)
199 {
200         COMPARE_SCALAR_FIELD(funcid);
201         COMPARE_SCALAR_FIELD(funcresulttype);
202         COMPARE_SCALAR_FIELD(funcretset);
203
204         /*
205          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
206          * that are equal() to both explicit and implicit coercions.
207          */
208         if (a->funcformat != b->funcformat &&
209                 a->funcformat != COERCE_DONTCARE &&
210                 b->funcformat != COERCE_DONTCARE)
211                 return false;
212
213         COMPARE_NODE_FIELD(args);
214
215         return true;
216 }
217
218 static bool
219 _equalOpExpr(OpExpr *a, OpExpr *b)
220 {
221         COMPARE_SCALAR_FIELD(opno);
222
223         /*
224          * Special-case opfuncid: it is allowable for it to differ if one node
225          * contains zero and the other doesn't.  This just means that the one node
226          * isn't as far along in the parse/plan pipeline and hasn't had the
227          * opfuncid cache filled yet.
228          */
229         if (a->opfuncid != b->opfuncid &&
230                 a->opfuncid != 0 &&
231                 b->opfuncid != 0)
232                 return false;
233
234         COMPARE_SCALAR_FIELD(opresulttype);
235         COMPARE_SCALAR_FIELD(opretset);
236         COMPARE_NODE_FIELD(args);
237
238         return true;
239 }
240
241 static bool
242 _equalDistinctExpr(DistinctExpr *a, DistinctExpr *b)
243 {
244         COMPARE_SCALAR_FIELD(opno);
245
246         /*
247          * Special-case opfuncid: it is allowable for it to differ if one node
248          * contains zero and the other doesn't.  This just means that the one node
249          * isn't as far along in the parse/plan pipeline and hasn't had the
250          * opfuncid cache filled yet.
251          */
252         if (a->opfuncid != b->opfuncid &&
253                 a->opfuncid != 0 &&
254                 b->opfuncid != 0)
255                 return false;
256
257         COMPARE_SCALAR_FIELD(opresulttype);
258         COMPARE_SCALAR_FIELD(opretset);
259         COMPARE_NODE_FIELD(args);
260
261         return true;
262 }
263
264 static bool
265 _equalScalarArrayOpExpr(ScalarArrayOpExpr *a, ScalarArrayOpExpr *b)
266 {
267         COMPARE_SCALAR_FIELD(opno);
268
269         /*
270          * Special-case opfuncid: it is allowable for it to differ if one node
271          * contains zero and the other doesn't.  This just means that the one node
272          * isn't as far along in the parse/plan pipeline and hasn't had the
273          * opfuncid cache filled yet.
274          */
275         if (a->opfuncid != b->opfuncid &&
276                 a->opfuncid != 0 &&
277                 b->opfuncid != 0)
278                 return false;
279
280         COMPARE_SCALAR_FIELD(useOr);
281         COMPARE_NODE_FIELD(args);
282
283         return true;
284 }
285
286 static bool
287 _equalBoolExpr(BoolExpr *a, BoolExpr *b)
288 {
289         COMPARE_SCALAR_FIELD(boolop);
290         COMPARE_NODE_FIELD(args);
291
292         return true;
293 }
294
295 static bool
296 _equalSubLink(SubLink *a, SubLink *b)
297 {
298         COMPARE_SCALAR_FIELD(subLinkType);
299         COMPARE_NODE_FIELD(testexpr);
300         COMPARE_NODE_FIELD(operName);
301         COMPARE_NODE_FIELD(subselect);
302
303         return true;
304 }
305
306 static bool
307 _equalSubPlan(SubPlan *a, SubPlan *b)
308 {
309         COMPARE_SCALAR_FIELD(subLinkType);
310         COMPARE_NODE_FIELD(testexpr);
311         COMPARE_NODE_FIELD(paramIds);
312         /* should compare plans, but have to settle for comparing plan IDs */
313         COMPARE_SCALAR_FIELD(plan_id);
314         COMPARE_NODE_FIELD(rtable);
315         COMPARE_SCALAR_FIELD(useHashTable);
316         COMPARE_SCALAR_FIELD(unknownEqFalse);
317         COMPARE_NODE_FIELD(setParam);
318         COMPARE_NODE_FIELD(parParam);
319         COMPARE_NODE_FIELD(args);
320
321         return true;
322 }
323
324 static bool
325 _equalFieldSelect(FieldSelect *a, FieldSelect *b)
326 {
327         COMPARE_NODE_FIELD(arg);
328         COMPARE_SCALAR_FIELD(fieldnum);
329         COMPARE_SCALAR_FIELD(resulttype);
330         COMPARE_SCALAR_FIELD(resulttypmod);
331
332         return true;
333 }
334
335 static bool
336 _equalFieldStore(FieldStore *a, FieldStore *b)
337 {
338         COMPARE_NODE_FIELD(arg);
339         COMPARE_NODE_FIELD(newvals);
340         COMPARE_NODE_FIELD(fieldnums);
341         COMPARE_SCALAR_FIELD(resulttype);
342
343         return true;
344 }
345
346 static bool
347 _equalRelabelType(RelabelType *a, RelabelType *b)
348 {
349         COMPARE_NODE_FIELD(arg);
350         COMPARE_SCALAR_FIELD(resulttype);
351         COMPARE_SCALAR_FIELD(resulttypmod);
352
353         /*
354          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
355          * that are equal() to both explicit and implicit coercions.
356          */
357         if (a->relabelformat != b->relabelformat &&
358                 a->relabelformat != COERCE_DONTCARE &&
359                 b->relabelformat != COERCE_DONTCARE)
360                 return false;
361
362         return true;
363 }
364
365 static bool
366 _equalConvertRowtypeExpr(ConvertRowtypeExpr *a, ConvertRowtypeExpr *b)
367 {
368         COMPARE_NODE_FIELD(arg);
369         COMPARE_SCALAR_FIELD(resulttype);
370
371         /*
372          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
373          * that are equal() to both explicit and implicit coercions.
374          */
375         if (a->convertformat != b->convertformat &&
376                 a->convertformat != COERCE_DONTCARE &&
377                 b->convertformat != COERCE_DONTCARE)
378                 return false;
379
380         return true;
381 }
382
383 static bool
384 _equalCaseExpr(CaseExpr *a, CaseExpr *b)
385 {
386         COMPARE_SCALAR_FIELD(casetype);
387         COMPARE_NODE_FIELD(arg);
388         COMPARE_NODE_FIELD(args);
389         COMPARE_NODE_FIELD(defresult);
390
391         return true;
392 }
393
394 static bool
395 _equalCaseWhen(CaseWhen *a, CaseWhen *b)
396 {
397         COMPARE_NODE_FIELD(expr);
398         COMPARE_NODE_FIELD(result);
399
400         return true;
401 }
402
403 static bool
404 _equalCaseTestExpr(CaseTestExpr *a, CaseTestExpr *b)
405 {
406         COMPARE_SCALAR_FIELD(typeId);
407         COMPARE_SCALAR_FIELD(typeMod);
408
409         return true;
410 }
411
412 static bool
413 _equalArrayExpr(ArrayExpr *a, ArrayExpr *b)
414 {
415         COMPARE_SCALAR_FIELD(array_typeid);
416         COMPARE_SCALAR_FIELD(element_typeid);
417         COMPARE_NODE_FIELD(elements);
418         COMPARE_SCALAR_FIELD(multidims);
419
420         return true;
421 }
422
423 static bool
424 _equalRowExpr(RowExpr *a, RowExpr *b)
425 {
426         COMPARE_NODE_FIELD(args);
427         COMPARE_SCALAR_FIELD(row_typeid);
428
429         /*
430          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
431          * that are equal() to both explicit and implicit coercions.
432          */
433         if (a->row_format != b->row_format &&
434                 a->row_format != COERCE_DONTCARE &&
435                 b->row_format != COERCE_DONTCARE)
436                 return false;
437
438         return true;
439 }
440
441 static bool
442 _equalRowCompareExpr(RowCompareExpr *a, RowCompareExpr *b)
443 {
444         COMPARE_SCALAR_FIELD(rctype);
445         COMPARE_NODE_FIELD(opnos);
446         COMPARE_NODE_FIELD(opclasses);
447         COMPARE_NODE_FIELD(largs);
448         COMPARE_NODE_FIELD(rargs);
449
450         return true;
451 }
452
453 static bool
454 _equalCoalesceExpr(CoalesceExpr *a, CoalesceExpr *b)
455 {
456         COMPARE_SCALAR_FIELD(coalescetype);
457         COMPARE_NODE_FIELD(args);
458
459         return true;
460 }
461
462 static bool
463 _equalMinMaxExpr(MinMaxExpr *a, MinMaxExpr *b)
464 {
465         COMPARE_SCALAR_FIELD(minmaxtype);
466         COMPARE_SCALAR_FIELD(op);
467         COMPARE_NODE_FIELD(args);
468
469         return true;
470 }
471
472 static bool
473 _equalNullIfExpr(NullIfExpr *a, NullIfExpr *b)
474 {
475         COMPARE_SCALAR_FIELD(opno);
476
477         /*
478          * Special-case opfuncid: it is allowable for it to differ if one node
479          * contains zero and the other doesn't.  This just means that the one node
480          * isn't as far along in the parse/plan pipeline and hasn't had the
481          * opfuncid cache filled yet.
482          */
483         if (a->opfuncid != b->opfuncid &&
484                 a->opfuncid != 0 &&
485                 b->opfuncid != 0)
486                 return false;
487
488         COMPARE_SCALAR_FIELD(opresulttype);
489         COMPARE_SCALAR_FIELD(opretset);
490         COMPARE_NODE_FIELD(args);
491
492         return true;
493 }
494
495 static bool
496 _equalNullTest(NullTest *a, NullTest *b)
497 {
498         COMPARE_NODE_FIELD(arg);
499         COMPARE_SCALAR_FIELD(nulltesttype);
500
501         return true;
502 }
503
504 static bool
505 _equalBooleanTest(BooleanTest *a, BooleanTest *b)
506 {
507         COMPARE_NODE_FIELD(arg);
508         COMPARE_SCALAR_FIELD(booltesttype);
509
510         return true;
511 }
512
513 static bool
514 _equalCoerceToDomain(CoerceToDomain *a, CoerceToDomain *b)
515 {
516         COMPARE_NODE_FIELD(arg);
517         COMPARE_SCALAR_FIELD(resulttype);
518         COMPARE_SCALAR_FIELD(resulttypmod);
519
520         /*
521          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
522          * that are equal() to both explicit and implicit coercions.
523          */
524         if (a->coercionformat != b->coercionformat &&
525                 a->coercionformat != COERCE_DONTCARE &&
526                 b->coercionformat != COERCE_DONTCARE)
527                 return false;
528
529         return true;
530 }
531
532 static bool
533 _equalCoerceToDomainValue(CoerceToDomainValue *a, CoerceToDomainValue *b)
534 {
535         COMPARE_SCALAR_FIELD(typeId);
536         COMPARE_SCALAR_FIELD(typeMod);
537
538         return true;
539 }
540
541 static bool
542 _equalSetToDefault(SetToDefault *a, SetToDefault *b)
543 {
544         COMPARE_SCALAR_FIELD(typeId);
545         COMPARE_SCALAR_FIELD(typeMod);
546
547         return true;
548 }
549
550 static bool
551 _equalTargetEntry(TargetEntry *a, TargetEntry *b)
552 {
553         COMPARE_NODE_FIELD(expr);
554         COMPARE_SCALAR_FIELD(resno);
555         COMPARE_STRING_FIELD(resname);
556         COMPARE_SCALAR_FIELD(ressortgroupref);
557         COMPARE_SCALAR_FIELD(resorigtbl);
558         COMPARE_SCALAR_FIELD(resorigcol);
559         COMPARE_SCALAR_FIELD(resjunk);
560
561         return true;
562 }
563
564 static bool
565 _equalRangeTblRef(RangeTblRef *a, RangeTblRef *b)
566 {
567         COMPARE_SCALAR_FIELD(rtindex);
568
569         return true;
570 }
571
572 static bool
573 _equalJoinExpr(JoinExpr *a, JoinExpr *b)
574 {
575         COMPARE_SCALAR_FIELD(jointype);
576         COMPARE_SCALAR_FIELD(isNatural);
577         COMPARE_NODE_FIELD(larg);
578         COMPARE_NODE_FIELD(rarg);
579         COMPARE_NODE_FIELD(using);
580         COMPARE_NODE_FIELD(quals);
581         COMPARE_NODE_FIELD(alias);
582         COMPARE_SCALAR_FIELD(rtindex);
583
584         return true;
585 }
586
587 static bool
588 _equalFromExpr(FromExpr *a, FromExpr *b)
589 {
590         COMPARE_NODE_FIELD(fromlist);
591         COMPARE_NODE_FIELD(quals);
592
593         return true;
594 }
595
596
597 /*
598  * Stuff from relation.h
599  */
600
601 static bool
602 _equalPathKeyItem(PathKeyItem *a, PathKeyItem *b)
603 {
604         COMPARE_NODE_FIELD(key);
605         COMPARE_SCALAR_FIELD(sortop);
606
607         return true;
608 }
609
610 static bool
611 _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
612 {
613         COMPARE_NODE_FIELD(clause);
614         COMPARE_SCALAR_FIELD(is_pushed_down);
615         COMPARE_SCALAR_FIELD(outerjoin_delayed);
616         COMPARE_BITMAPSET_FIELD(required_relids);
617
618         /*
619          * We ignore all the remaining fields, since they may not be set yet, and
620          * should be derivable from the clause anyway.
621          */
622
623         return true;
624 }
625
626 static bool
627 _equalOuterJoinInfo(OuterJoinInfo *a, OuterJoinInfo *b)
628 {
629         COMPARE_BITMAPSET_FIELD(min_lefthand);
630         COMPARE_BITMAPSET_FIELD(min_righthand);
631         COMPARE_SCALAR_FIELD(is_full_join);
632         COMPARE_SCALAR_FIELD(lhs_strict);
633
634         return true;
635 }
636
637 static bool
638 _equalInClauseInfo(InClauseInfo *a, InClauseInfo *b)
639 {
640         COMPARE_BITMAPSET_FIELD(lefthand);
641         COMPARE_BITMAPSET_FIELD(righthand);
642         COMPARE_NODE_FIELD(sub_targetlist);
643
644         return true;
645 }
646
647 static bool
648 _equalAppendRelInfo(AppendRelInfo *a, AppendRelInfo *b)
649 {
650         COMPARE_SCALAR_FIELD(parent_relid);
651         COMPARE_SCALAR_FIELD(child_relid);
652         COMPARE_SCALAR_FIELD(parent_reltype);
653         COMPARE_SCALAR_FIELD(child_reltype);
654         COMPARE_NODE_FIELD(col_mappings);
655         COMPARE_NODE_FIELD(translated_vars);
656         COMPARE_SCALAR_FIELD(parent_reloid);
657
658         return true;
659 }
660
661
662 /*
663  * Stuff from parsenodes.h
664  */
665
666 static bool
667 _equalQuery(Query *a, Query *b)
668 {
669         COMPARE_SCALAR_FIELD(commandType);
670         COMPARE_SCALAR_FIELD(querySource);
671         COMPARE_SCALAR_FIELD(canSetTag);
672         COMPARE_NODE_FIELD(utilityStmt);
673         COMPARE_SCALAR_FIELD(resultRelation);
674         COMPARE_NODE_FIELD(into);
675         COMPARE_SCALAR_FIELD(intoHasOids);
676         COMPARE_SCALAR_FIELD(intoOnCommit);
677         COMPARE_STRING_FIELD(intoTableSpaceName);
678         COMPARE_SCALAR_FIELD(hasAggs);
679         COMPARE_SCALAR_FIELD(hasSubLinks);
680         COMPARE_NODE_FIELD(rtable);
681         COMPARE_NODE_FIELD(jointree);
682         COMPARE_NODE_FIELD(rowMarks);
683         COMPARE_SCALAR_FIELD(forUpdate);
684         COMPARE_SCALAR_FIELD(rowNoWait);
685         COMPARE_NODE_FIELD(targetList);
686         COMPARE_NODE_FIELD(groupClause);
687         COMPARE_NODE_FIELD(havingQual);
688         COMPARE_NODE_FIELD(distinctClause);
689         COMPARE_NODE_FIELD(sortClause);
690         COMPARE_NODE_FIELD(limitOffset);
691         COMPARE_NODE_FIELD(limitCount);
692         COMPARE_NODE_FIELD(setOperations);
693         COMPARE_NODE_FIELD(resultRelations);
694
695         return true;
696 }
697
698 static bool
699 _equalInsertStmt(InsertStmt *a, InsertStmt *b)
700 {
701         COMPARE_NODE_FIELD(relation);
702         COMPARE_NODE_FIELD(cols);
703         COMPARE_NODE_FIELD(targetList);
704         COMPARE_NODE_FIELD(selectStmt);
705
706         return true;
707 }
708
709 static bool
710 _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
711 {
712         COMPARE_NODE_FIELD(relation);
713         COMPARE_NODE_FIELD(whereClause);
714         COMPARE_NODE_FIELD(usingClause);
715
716         return true;
717 }
718
719 static bool
720 _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
721 {
722         COMPARE_NODE_FIELD(relation);
723         COMPARE_NODE_FIELD(targetList);
724         COMPARE_NODE_FIELD(whereClause);
725         COMPARE_NODE_FIELD(fromClause);
726
727         return true;
728 }
729
730 static bool
731 _equalSelectStmt(SelectStmt *a, SelectStmt *b)
732 {
733         COMPARE_NODE_FIELD(distinctClause);
734         COMPARE_NODE_FIELD(into);
735         COMPARE_NODE_FIELD(intoColNames);
736         COMPARE_SCALAR_FIELD(intoHasOids);
737         COMPARE_SCALAR_FIELD(intoOnCommit);
738         COMPARE_STRING_FIELD(intoTableSpaceName);
739         COMPARE_NODE_FIELD(targetList);
740         COMPARE_NODE_FIELD(fromClause);
741         COMPARE_NODE_FIELD(whereClause);
742         COMPARE_NODE_FIELD(groupClause);
743         COMPARE_NODE_FIELD(havingClause);
744         COMPARE_NODE_FIELD(sortClause);
745         COMPARE_NODE_FIELD(limitOffset);
746         COMPARE_NODE_FIELD(limitCount);
747         COMPARE_NODE_FIELD(lockingClause);
748         COMPARE_SCALAR_FIELD(op);
749         COMPARE_SCALAR_FIELD(all);
750         COMPARE_NODE_FIELD(larg);
751         COMPARE_NODE_FIELD(rarg);
752
753         return true;
754 }
755
756 static bool
757 _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b)
758 {
759         COMPARE_SCALAR_FIELD(op);
760         COMPARE_SCALAR_FIELD(all);
761         COMPARE_NODE_FIELD(larg);
762         COMPARE_NODE_FIELD(rarg);
763         COMPARE_NODE_FIELD(colTypes);
764
765         return true;
766 }
767
768 static bool
769 _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
770 {
771         COMPARE_NODE_FIELD(relation);
772         COMPARE_NODE_FIELD(cmds);
773         COMPARE_SCALAR_FIELD(relkind);
774
775         return true;
776 }
777
778 static bool
779 _equalAlterTableCmd(AlterTableCmd *a, AlterTableCmd *b)
780 {
781         COMPARE_SCALAR_FIELD(subtype);
782         COMPARE_STRING_FIELD(name);
783         COMPARE_NODE_FIELD(def);
784         COMPARE_NODE_FIELD(transform);
785         COMPARE_SCALAR_FIELD(behavior);
786
787         return true;
788 }
789
790 static bool
791 _equalAlterDomainStmt(AlterDomainStmt *a, AlterDomainStmt *b)
792 {
793         COMPARE_SCALAR_FIELD(subtype);
794         COMPARE_NODE_FIELD(typename);
795         COMPARE_STRING_FIELD(name);
796         COMPARE_NODE_FIELD(def);
797         COMPARE_SCALAR_FIELD(behavior);
798
799         return true;
800 }
801
802 static bool
803 _equalGrantStmt(GrantStmt *a, GrantStmt *b)
804 {
805         COMPARE_SCALAR_FIELD(is_grant);
806         COMPARE_SCALAR_FIELD(objtype);
807         COMPARE_NODE_FIELD(objects);
808         COMPARE_NODE_FIELD(privileges);
809         COMPARE_NODE_FIELD(grantees);
810         COMPARE_SCALAR_FIELD(grant_option);
811         COMPARE_SCALAR_FIELD(behavior);
812
813         return true;
814 }
815
816 static bool
817 _equalPrivGrantee(PrivGrantee *a, PrivGrantee *b)
818 {
819         COMPARE_STRING_FIELD(rolname);
820
821         return true;
822 }
823
824 static bool
825 _equalFuncWithArgs(FuncWithArgs *a, FuncWithArgs *b)
826 {
827         COMPARE_NODE_FIELD(funcname);
828         COMPARE_NODE_FIELD(funcargs);
829
830         return true;
831 }
832
833 static bool
834 _equalGrantRoleStmt(GrantRoleStmt *a, GrantRoleStmt *b)
835 {
836         COMPARE_NODE_FIELD(granted_roles);
837         COMPARE_NODE_FIELD(grantee_roles);
838         COMPARE_SCALAR_FIELD(is_grant);
839         COMPARE_SCALAR_FIELD(admin_opt);
840         COMPARE_STRING_FIELD(grantor);
841         COMPARE_SCALAR_FIELD(behavior);
842
843         return true;
844 }
845
846 static bool
847 _equalDeclareCursorStmt(DeclareCursorStmt *a, DeclareCursorStmt *b)
848 {
849         COMPARE_STRING_FIELD(portalname);
850         COMPARE_SCALAR_FIELD(options);
851         COMPARE_NODE_FIELD(query);
852
853         return true;
854 }
855
856 static bool
857 _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
858 {
859         COMPARE_STRING_FIELD(portalname);
860
861         return true;
862 }
863
864 static bool
865 _equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
866 {
867         COMPARE_NODE_FIELD(relation);
868         COMPARE_STRING_FIELD(indexname);
869
870         return true;
871 }
872
873 static bool
874 _equalCopyStmt(CopyStmt *a, CopyStmt *b)
875 {
876         COMPARE_NODE_FIELD(relation);
877         COMPARE_NODE_FIELD(attlist);
878         COMPARE_SCALAR_FIELD(is_from);
879         COMPARE_STRING_FIELD(filename);
880         COMPARE_NODE_FIELD(options);
881
882         return true;
883 }
884
885 static bool
886 _equalCreateStmt(CreateStmt *a, CreateStmt *b)
887 {
888         COMPARE_NODE_FIELD(relation);
889         COMPARE_NODE_FIELD(tableElts);
890         COMPARE_NODE_FIELD(inhRelations);
891         COMPARE_NODE_FIELD(constraints);
892         COMPARE_SCALAR_FIELD(hasoids);
893         COMPARE_SCALAR_FIELD(oncommit);
894         COMPARE_STRING_FIELD(tablespacename);
895
896         return true;
897 }
898
899 static bool
900 _equalInhRelation(InhRelation *a, InhRelation *b)
901 {
902         COMPARE_NODE_FIELD(relation);
903         COMPARE_SCALAR_FIELD(including_defaults);
904
905         return true;
906 }
907
908 static bool
909 _equalDefineStmt(DefineStmt *a, DefineStmt *b)
910 {
911         COMPARE_SCALAR_FIELD(kind);
912         COMPARE_SCALAR_FIELD(oldstyle);
913         COMPARE_NODE_FIELD(defnames);
914         COMPARE_NODE_FIELD(args);
915         COMPARE_NODE_FIELD(definition);
916
917         return true;
918 }
919
920 static bool
921 _equalDropStmt(DropStmt *a, DropStmt *b)
922 {
923         COMPARE_NODE_FIELD(objects);
924         COMPARE_SCALAR_FIELD(removeType);
925         COMPARE_SCALAR_FIELD(behavior);
926         COMPARE_SCALAR_FIELD(missing_ok);
927
928         return true;
929 }
930
931 static bool
932 _equalTruncateStmt(TruncateStmt *a, TruncateStmt *b)
933 {
934         COMPARE_NODE_FIELD(relations);
935         COMPARE_SCALAR_FIELD(behavior);
936
937         return true;
938 }
939
940 static bool
941 _equalCommentStmt(CommentStmt *a, CommentStmt *b)
942 {
943         COMPARE_SCALAR_FIELD(objtype);
944         COMPARE_NODE_FIELD(objname);
945         COMPARE_NODE_FIELD(objargs);
946         COMPARE_STRING_FIELD(comment);
947
948         return true;
949 }
950
951 static bool
952 _equalFetchStmt(FetchStmt *a, FetchStmt *b)
953 {
954         COMPARE_SCALAR_FIELD(direction);
955         COMPARE_SCALAR_FIELD(howMany);
956         COMPARE_STRING_FIELD(portalname);
957         COMPARE_SCALAR_FIELD(ismove);
958
959         return true;
960 }
961
962 static bool
963 _equalIndexStmt(IndexStmt *a, IndexStmt *b)
964 {
965         COMPARE_STRING_FIELD(idxname);
966         COMPARE_NODE_FIELD(relation);
967         COMPARE_STRING_FIELD(accessMethod);
968         COMPARE_STRING_FIELD(tableSpace);
969         COMPARE_NODE_FIELD(indexParams);
970         COMPARE_NODE_FIELD(whereClause);
971         COMPARE_NODE_FIELD(rangetable);
972         COMPARE_SCALAR_FIELD(unique);
973         COMPARE_SCALAR_FIELD(primary);
974         COMPARE_SCALAR_FIELD(isconstraint);
975
976         return true;
977 }
978
979 static bool
980 _equalCreateFunctionStmt(CreateFunctionStmt *a, CreateFunctionStmt *b)
981 {
982         COMPARE_SCALAR_FIELD(replace);
983         COMPARE_NODE_FIELD(funcname);
984         COMPARE_NODE_FIELD(parameters);
985         COMPARE_NODE_FIELD(returnType);
986         COMPARE_NODE_FIELD(options);
987         COMPARE_NODE_FIELD(withClause);
988
989         return true;
990 }
991
992 static bool
993 _equalFunctionParameter(FunctionParameter *a, FunctionParameter *b)
994 {
995         COMPARE_STRING_FIELD(name);
996         COMPARE_NODE_FIELD(argType);
997         COMPARE_SCALAR_FIELD(mode);
998
999         return true;
1000 }
1001
1002 static bool
1003 _equalAlterFunctionStmt(AlterFunctionStmt *a, AlterFunctionStmt *b)
1004 {
1005         COMPARE_NODE_FIELD(func);
1006         COMPARE_NODE_FIELD(actions);
1007
1008         return true;
1009 }
1010
1011 static bool
1012 _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b)
1013 {
1014         COMPARE_SCALAR_FIELD(kind);
1015         COMPARE_NODE_FIELD(name);
1016         COMPARE_NODE_FIELD(args);
1017         COMPARE_SCALAR_FIELD(behavior);
1018
1019         return true;
1020 }
1021
1022 static bool
1023 _equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b)
1024 {
1025         COMPARE_NODE_FIELD(opclassname);
1026         COMPARE_STRING_FIELD(amname);
1027         COMPARE_SCALAR_FIELD(behavior);
1028
1029         return true;
1030 }
1031
1032 static bool
1033 _equalRenameStmt(RenameStmt *a, RenameStmt *b)
1034 {
1035         COMPARE_SCALAR_FIELD(renameType);
1036         COMPARE_NODE_FIELD(relation);
1037         COMPARE_NODE_FIELD(object);
1038         COMPARE_NODE_FIELD(objarg);
1039         COMPARE_STRING_FIELD(subname);
1040         COMPARE_STRING_FIELD(newname);
1041
1042         return true;
1043 }
1044
1045 static bool
1046 _equalAlterObjectSchemaStmt(AlterObjectSchemaStmt *a, AlterObjectSchemaStmt *b)
1047 {
1048         COMPARE_SCALAR_FIELD(objectType);
1049         COMPARE_NODE_FIELD(relation);
1050         COMPARE_NODE_FIELD(object);
1051         COMPARE_NODE_FIELD(objarg);
1052         COMPARE_STRING_FIELD(addname);
1053         COMPARE_STRING_FIELD(newschema);
1054
1055         return true;
1056 }
1057
1058 static bool
1059 _equalAlterOwnerStmt(AlterOwnerStmt *a, AlterOwnerStmt *b)
1060 {
1061         COMPARE_SCALAR_FIELD(objectType);
1062         COMPARE_NODE_FIELD(relation);
1063         COMPARE_NODE_FIELD(object);
1064         COMPARE_NODE_FIELD(objarg);
1065         COMPARE_STRING_FIELD(addname);
1066         COMPARE_STRING_FIELD(newowner);
1067
1068         return true;
1069 }
1070
1071 static bool
1072 _equalRuleStmt(RuleStmt *a, RuleStmt *b)
1073 {
1074         COMPARE_NODE_FIELD(relation);
1075         COMPARE_STRING_FIELD(rulename);
1076         COMPARE_NODE_FIELD(whereClause);
1077         COMPARE_SCALAR_FIELD(event);
1078         COMPARE_SCALAR_FIELD(instead);
1079         COMPARE_NODE_FIELD(actions);
1080         COMPARE_SCALAR_FIELD(replace);
1081
1082         return true;
1083 }
1084
1085 static bool
1086 _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
1087 {
1088         COMPARE_NODE_FIELD(relation);
1089
1090         return true;
1091 }
1092
1093 static bool
1094 _equalListenStmt(ListenStmt *a, ListenStmt *b)
1095 {
1096         COMPARE_NODE_FIELD(relation);
1097
1098         return true;
1099 }
1100
1101 static bool
1102 _equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
1103 {
1104         COMPARE_NODE_FIELD(relation);
1105
1106         return true;
1107 }
1108
1109 static bool
1110 _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
1111 {
1112         COMPARE_SCALAR_FIELD(kind);
1113         COMPARE_NODE_FIELD(options);
1114         COMPARE_STRING_FIELD(gid);
1115
1116         return true;
1117 }
1118
1119 static bool
1120 _equalCompositeTypeStmt(CompositeTypeStmt *a, CompositeTypeStmt *b)
1121 {
1122         COMPARE_NODE_FIELD(typevar);
1123         COMPARE_NODE_FIELD(coldeflist);
1124
1125         return true;
1126 }
1127
1128 static bool
1129 _equalViewStmt(ViewStmt *a, ViewStmt *b)
1130 {
1131         COMPARE_NODE_FIELD(view);
1132         COMPARE_NODE_FIELD(aliases);
1133         COMPARE_NODE_FIELD(query);
1134         COMPARE_SCALAR_FIELD(replace);
1135
1136         return true;
1137 }
1138
1139 static bool
1140 _equalLoadStmt(LoadStmt *a, LoadStmt *b)
1141 {
1142         COMPARE_STRING_FIELD(filename);
1143
1144         return true;
1145 }
1146
1147 static bool
1148 _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b)
1149 {
1150         COMPARE_NODE_FIELD(domainname);
1151         COMPARE_NODE_FIELD(typename);
1152         COMPARE_NODE_FIELD(constraints);
1153
1154         return true;
1155 }
1156
1157 static bool
1158 _equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b)
1159 {
1160         COMPARE_NODE_FIELD(opclassname);
1161         COMPARE_STRING_FIELD(amname);
1162         COMPARE_NODE_FIELD(datatype);
1163         COMPARE_NODE_FIELD(items);
1164         COMPARE_SCALAR_FIELD(isDefault);
1165
1166         return true;
1167 }
1168
1169 static bool
1170 _equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b)
1171 {
1172         COMPARE_SCALAR_FIELD(itemtype);
1173         COMPARE_NODE_FIELD(name);
1174         COMPARE_NODE_FIELD(args);
1175         COMPARE_SCALAR_FIELD(number);
1176         COMPARE_SCALAR_FIELD(recheck);
1177         COMPARE_NODE_FIELD(storedtype);
1178
1179         return true;
1180 }
1181
1182 static bool
1183 _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
1184 {
1185         COMPARE_STRING_FIELD(dbname);
1186         COMPARE_NODE_FIELD(options);
1187
1188         return true;
1189 }
1190
1191 static bool
1192 _equalAlterDatabaseStmt(AlterDatabaseStmt *a, AlterDatabaseStmt *b)
1193 {
1194         COMPARE_STRING_FIELD(dbname);
1195         COMPARE_NODE_FIELD(options);
1196
1197         return true;
1198 }
1199
1200 static bool
1201 _equalAlterDatabaseSetStmt(AlterDatabaseSetStmt *a, AlterDatabaseSetStmt *b)
1202 {
1203         COMPARE_STRING_FIELD(dbname);
1204         COMPARE_STRING_FIELD(variable);
1205         COMPARE_NODE_FIELD(value);
1206
1207         return true;
1208 }
1209
1210 static bool
1211 _equalDropdbStmt(DropdbStmt *a, DropdbStmt *b)
1212 {
1213         COMPARE_STRING_FIELD(dbname);
1214         COMPARE_SCALAR_FIELD(missing_ok);
1215
1216         return true;
1217 }
1218
1219 static bool
1220 _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
1221 {
1222         COMPARE_SCALAR_FIELD(vacuum);
1223         COMPARE_SCALAR_FIELD(full);
1224         COMPARE_SCALAR_FIELD(analyze);
1225         COMPARE_SCALAR_FIELD(freeze);
1226         COMPARE_SCALAR_FIELD(verbose);
1227         COMPARE_NODE_FIELD(relation);
1228         COMPARE_NODE_FIELD(va_cols);
1229
1230         return true;
1231 }
1232
1233 static bool
1234 _equalExplainStmt(ExplainStmt *a, ExplainStmt *b)
1235 {
1236         COMPARE_NODE_FIELD(query);
1237         COMPARE_SCALAR_FIELD(verbose);
1238         COMPARE_SCALAR_FIELD(analyze);
1239
1240         return true;
1241 }
1242
1243 static bool
1244 _equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b)
1245 {
1246         COMPARE_NODE_FIELD(sequence);
1247         COMPARE_NODE_FIELD(options);
1248
1249         return true;
1250 }
1251
1252 static bool
1253 _equalAlterSeqStmt(AlterSeqStmt *a, AlterSeqStmt *b)
1254 {
1255         COMPARE_NODE_FIELD(sequence);
1256         COMPARE_NODE_FIELD(options);
1257
1258         return true;
1259 }
1260
1261 static bool
1262 _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
1263 {
1264         COMPARE_STRING_FIELD(name);
1265         COMPARE_NODE_FIELD(args);
1266         COMPARE_SCALAR_FIELD(is_local);
1267
1268         return true;
1269 }
1270
1271 static bool
1272 _equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b)
1273 {
1274         COMPARE_STRING_FIELD(name);
1275
1276         return true;
1277 }
1278
1279 static bool
1280 _equalVariableResetStmt(VariableResetStmt *a, VariableResetStmt *b)
1281 {
1282         COMPARE_STRING_FIELD(name);
1283
1284         return true;
1285 }
1286
1287 static bool
1288 _equalCreateTableSpaceStmt(CreateTableSpaceStmt *a, CreateTableSpaceStmt *b)
1289 {
1290         COMPARE_STRING_FIELD(tablespacename);
1291         COMPARE_STRING_FIELD(owner);
1292         COMPARE_STRING_FIELD(location);
1293
1294         return true;
1295 }
1296
1297 static bool
1298 _equalDropTableSpaceStmt(DropTableSpaceStmt *a, DropTableSpaceStmt *b)
1299 {
1300         COMPARE_STRING_FIELD(tablespacename);
1301
1302         return true;
1303 }
1304
1305 static bool
1306 _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b)
1307 {
1308         COMPARE_STRING_FIELD(trigname);
1309         COMPARE_NODE_FIELD(relation);
1310         COMPARE_NODE_FIELD(funcname);
1311         COMPARE_NODE_FIELD(args);
1312         COMPARE_SCALAR_FIELD(before);
1313         COMPARE_SCALAR_FIELD(row);
1314         if (strcmp(a->actions, b->actions) != 0)        /* in-line string field */
1315                 return false;
1316         COMPARE_SCALAR_FIELD(isconstraint);
1317         COMPARE_SCALAR_FIELD(deferrable);
1318         COMPARE_SCALAR_FIELD(initdeferred);
1319         COMPARE_NODE_FIELD(constrrel);
1320
1321         return true;
1322 }
1323
1324 static bool
1325 _equalDropPropertyStmt(DropPropertyStmt *a, DropPropertyStmt *b)
1326 {
1327         COMPARE_NODE_FIELD(relation);
1328         COMPARE_STRING_FIELD(property);
1329         COMPARE_SCALAR_FIELD(removeType);
1330         COMPARE_SCALAR_FIELD(behavior);
1331
1332         return true;
1333 }
1334
1335 static bool
1336 _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b)
1337 {
1338         COMPARE_STRING_FIELD(plname);
1339         COMPARE_NODE_FIELD(plhandler);
1340         COMPARE_NODE_FIELD(plvalidator);
1341         COMPARE_SCALAR_FIELD(pltrusted);
1342
1343         return true;
1344 }
1345
1346 static bool
1347 _equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b)
1348 {
1349         COMPARE_STRING_FIELD(plname);
1350         COMPARE_SCALAR_FIELD(behavior);
1351
1352         return true;
1353 }
1354
1355 static bool
1356 _equalCreateRoleStmt(CreateRoleStmt *a, CreateRoleStmt *b)
1357 {
1358         COMPARE_SCALAR_FIELD(stmt_type);
1359         COMPARE_STRING_FIELD(role);
1360         COMPARE_NODE_FIELD(options);
1361
1362         return true;
1363 }
1364
1365 static bool
1366 _equalAlterRoleStmt(AlterRoleStmt *a, AlterRoleStmt *b)
1367 {
1368         COMPARE_STRING_FIELD(role);
1369         COMPARE_NODE_FIELD(options);
1370         COMPARE_SCALAR_FIELD(action);
1371
1372         return true;
1373 }
1374
1375 static bool
1376 _equalAlterRoleSetStmt(AlterRoleSetStmt *a, AlterRoleSetStmt *b)
1377 {
1378         COMPARE_STRING_FIELD(role);
1379         COMPARE_STRING_FIELD(variable);
1380         COMPARE_NODE_FIELD(value);
1381
1382         return true;
1383 }
1384
1385 static bool
1386 _equalDropRoleStmt(DropRoleStmt *a, DropRoleStmt *b)
1387 {
1388         COMPARE_NODE_FIELD(roles);
1389         COMPARE_SCALAR_FIELD(missing_ok);
1390
1391         return true;
1392 }
1393
1394 static bool
1395 _equalLockStmt(LockStmt *a, LockStmt *b)
1396 {
1397         COMPARE_NODE_FIELD(relations);
1398         COMPARE_SCALAR_FIELD(mode);
1399         COMPARE_SCALAR_FIELD(nowait);
1400
1401         return true;
1402 }
1403
1404 static bool
1405 _equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b)
1406 {
1407         COMPARE_NODE_FIELD(constraints);
1408         COMPARE_SCALAR_FIELD(deferred);
1409
1410         return true;
1411 }
1412
1413 static bool
1414 _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
1415 {
1416         COMPARE_SCALAR_FIELD(kind);
1417         COMPARE_NODE_FIELD(relation);
1418         COMPARE_STRING_FIELD(name);
1419         COMPARE_SCALAR_FIELD(do_system);
1420         COMPARE_SCALAR_FIELD(do_user);
1421
1422         return true;
1423 }
1424
1425 static bool
1426 _equalCreateSchemaStmt(CreateSchemaStmt *a, CreateSchemaStmt *b)
1427 {
1428         COMPARE_STRING_FIELD(schemaname);
1429         COMPARE_STRING_FIELD(authid);
1430         COMPARE_NODE_FIELD(schemaElts);
1431
1432         return true;
1433 }
1434
1435 static bool
1436 _equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b)
1437 {
1438         COMPARE_NODE_FIELD(conversion_name);
1439         COMPARE_STRING_FIELD(for_encoding_name);
1440         COMPARE_STRING_FIELD(to_encoding_name);
1441         COMPARE_NODE_FIELD(func_name);
1442         COMPARE_SCALAR_FIELD(def);
1443
1444         return true;
1445 }
1446
1447 static bool
1448 _equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b)
1449 {
1450         COMPARE_NODE_FIELD(sourcetype);
1451         COMPARE_NODE_FIELD(targettype);
1452         COMPARE_NODE_FIELD(func);
1453         COMPARE_SCALAR_FIELD(context);
1454
1455         return true;
1456 }
1457
1458 static bool
1459 _equalDropCastStmt(DropCastStmt *a, DropCastStmt *b)
1460 {
1461         COMPARE_NODE_FIELD(sourcetype);
1462         COMPARE_NODE_FIELD(targettype);
1463         COMPARE_SCALAR_FIELD(behavior);
1464
1465         return true;
1466 }
1467
1468 static bool
1469 _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b)
1470 {
1471         COMPARE_STRING_FIELD(name);
1472         COMPARE_NODE_FIELD(argtypes);
1473         COMPARE_NODE_FIELD(argtype_oids);
1474         COMPARE_NODE_FIELD(query);
1475
1476         return true;
1477 }
1478
1479 static bool
1480 _equalExecuteStmt(ExecuteStmt *a, ExecuteStmt *b)
1481 {
1482         COMPARE_STRING_FIELD(name);
1483         COMPARE_NODE_FIELD(into);
1484         COMPARE_SCALAR_FIELD(into_contains_oids);
1485         COMPARE_SCALAR_FIELD(into_has_oids);
1486         COMPARE_SCALAR_FIELD(into_on_commit);
1487         COMPARE_STRING_FIELD(into_tbl_space);
1488         COMPARE_NODE_FIELD(params);
1489
1490         return true;
1491 }
1492
1493 static bool
1494 _equalDeallocateStmt(DeallocateStmt *a, DeallocateStmt *b)
1495 {
1496         COMPARE_STRING_FIELD(name);
1497
1498         return true;
1499 }
1500
1501 static bool
1502 _equalDropOwnedStmt(DropOwnedStmt * a, DropOwnedStmt * b)
1503 {
1504         COMPARE_NODE_FIELD(roles);
1505         COMPARE_SCALAR_FIELD(behavior);
1506
1507         return true;
1508 }
1509
1510 static bool
1511 _equalReassignOwnedStmt(ReassignOwnedStmt * a, ReassignOwnedStmt * b)
1512 {
1513         COMPARE_NODE_FIELD(roles);
1514         COMPARE_NODE_FIELD(newrole);
1515
1516         return true;
1517 }
1518
1519 static bool
1520 _equalAExpr(A_Expr *a, A_Expr *b)
1521 {
1522         COMPARE_SCALAR_FIELD(kind);
1523         COMPARE_NODE_FIELD(name);
1524         COMPARE_NODE_FIELD(lexpr);
1525         COMPARE_NODE_FIELD(rexpr);
1526         COMPARE_SCALAR_FIELD(location);
1527
1528         return true;
1529 }
1530
1531 static bool
1532 _equalColumnRef(ColumnRef *a, ColumnRef *b)
1533 {
1534         COMPARE_NODE_FIELD(fields);
1535         COMPARE_SCALAR_FIELD(location);
1536
1537         return true;
1538 }
1539
1540 static bool
1541 _equalParamRef(ParamRef *a, ParamRef *b)
1542 {
1543         COMPARE_SCALAR_FIELD(number);
1544
1545         return true;
1546 }
1547
1548 static bool
1549 _equalAConst(A_Const *a, A_Const *b)
1550 {
1551         if (!equal(&a->val, &b->val))           /* hack for in-line Value field */
1552                 return false;
1553         COMPARE_NODE_FIELD(typename);
1554
1555         return true;
1556 }
1557
1558 static bool
1559 _equalFuncCall(FuncCall *a, FuncCall *b)
1560 {
1561         COMPARE_NODE_FIELD(funcname);
1562         COMPARE_NODE_FIELD(args);
1563         COMPARE_SCALAR_FIELD(agg_star);
1564         COMPARE_SCALAR_FIELD(agg_distinct);
1565         COMPARE_SCALAR_FIELD(location);
1566
1567         return true;
1568 }
1569
1570 static bool
1571 _equalAIndices(A_Indices *a, A_Indices *b)
1572 {
1573         COMPARE_NODE_FIELD(lidx);
1574         COMPARE_NODE_FIELD(uidx);
1575
1576         return true;
1577 }
1578
1579 static bool
1580 _equalA_Indirection(A_Indirection *a, A_Indirection *b)
1581 {
1582         COMPARE_NODE_FIELD(arg);
1583         COMPARE_NODE_FIELD(indirection);
1584
1585         return true;
1586 }
1587
1588 static bool
1589 _equalResTarget(ResTarget *a, ResTarget *b)
1590 {
1591         COMPARE_STRING_FIELD(name);
1592         COMPARE_NODE_FIELD(indirection);
1593         COMPARE_NODE_FIELD(val);
1594         COMPARE_SCALAR_FIELD(location);
1595
1596         return true;
1597 }
1598
1599 static bool
1600 _equalTypeName(TypeName *a, TypeName *b)
1601 {
1602         COMPARE_NODE_FIELD(names);
1603         COMPARE_SCALAR_FIELD(typeid);
1604         COMPARE_SCALAR_FIELD(timezone);
1605         COMPARE_SCALAR_FIELD(setof);
1606         COMPARE_SCALAR_FIELD(pct_type);
1607         COMPARE_SCALAR_FIELD(typmod);
1608         COMPARE_NODE_FIELD(arrayBounds);
1609         COMPARE_SCALAR_FIELD(location);
1610
1611         return true;
1612 }
1613
1614 static bool
1615 _equalTypeCast(TypeCast *a, TypeCast *b)
1616 {
1617         COMPARE_NODE_FIELD(arg);
1618         COMPARE_NODE_FIELD(typename);
1619
1620         return true;
1621 }
1622
1623 static bool
1624 _equalSortBy(SortBy *a, SortBy *b)
1625 {
1626         COMPARE_SCALAR_FIELD(sortby_kind);
1627         COMPARE_NODE_FIELD(useOp);
1628         COMPARE_NODE_FIELD(node);
1629
1630         return true;
1631 }
1632
1633 static bool
1634 _equalRangeSubselect(RangeSubselect *a, RangeSubselect *b)
1635 {
1636         COMPARE_NODE_FIELD(subquery);
1637         COMPARE_NODE_FIELD(alias);
1638
1639         return true;
1640 }
1641
1642 static bool
1643 _equalRangeFunction(RangeFunction *a, RangeFunction *b)
1644 {
1645         COMPARE_NODE_FIELD(funccallnode);
1646         COMPARE_NODE_FIELD(alias);
1647         COMPARE_NODE_FIELD(coldeflist);
1648
1649         return true;
1650 }
1651
1652 static bool
1653 _equalIndexElem(IndexElem *a, IndexElem *b)
1654 {
1655         COMPARE_STRING_FIELD(name);
1656         COMPARE_NODE_FIELD(expr);
1657         COMPARE_NODE_FIELD(opclass);
1658
1659         return true;
1660 }
1661
1662 static bool
1663 _equalColumnDef(ColumnDef *a, ColumnDef *b)
1664 {
1665         COMPARE_STRING_FIELD(colname);
1666         COMPARE_NODE_FIELD(typename);
1667         COMPARE_SCALAR_FIELD(inhcount);
1668         COMPARE_SCALAR_FIELD(is_local);
1669         COMPARE_SCALAR_FIELD(is_not_null);
1670         COMPARE_NODE_FIELD(raw_default);
1671         COMPARE_STRING_FIELD(cooked_default);
1672         COMPARE_NODE_FIELD(constraints);
1673         COMPARE_NODE_FIELD(support);
1674
1675         return true;
1676 }
1677
1678 static bool
1679 _equalConstraint(Constraint *a, Constraint *b)
1680 {
1681         COMPARE_SCALAR_FIELD(contype);
1682         COMPARE_STRING_FIELD(name);
1683         COMPARE_NODE_FIELD(raw_expr);
1684         COMPARE_STRING_FIELD(cooked_expr);
1685         COMPARE_NODE_FIELD(keys);
1686         COMPARE_STRING_FIELD(indexspace);
1687
1688         return true;
1689 }
1690
1691 static bool
1692 _equalDefElem(DefElem *a, DefElem *b)
1693 {
1694         COMPARE_STRING_FIELD(defname);
1695         COMPARE_NODE_FIELD(arg);
1696
1697         return true;
1698 }
1699
1700 static bool
1701 _equalLockingClause(LockingClause *a, LockingClause *b)
1702 {
1703         COMPARE_NODE_FIELD(lockedRels);
1704         COMPARE_SCALAR_FIELD(forUpdate);
1705         COMPARE_SCALAR_FIELD(nowait);
1706
1707         return true;
1708 }
1709
1710 static bool
1711 _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
1712 {
1713         COMPARE_SCALAR_FIELD(rtekind);
1714         COMPARE_SCALAR_FIELD(relid);
1715         COMPARE_NODE_FIELD(subquery);
1716         COMPARE_NODE_FIELD(funcexpr);
1717         COMPARE_NODE_FIELD(funccoltypes);
1718         COMPARE_NODE_FIELD(funccoltypmods);
1719         COMPARE_SCALAR_FIELD(jointype);
1720         COMPARE_NODE_FIELD(joinaliasvars);
1721         COMPARE_NODE_FIELD(alias);
1722         COMPARE_NODE_FIELD(eref);
1723         COMPARE_SCALAR_FIELD(inh);
1724         COMPARE_SCALAR_FIELD(inFromCl);
1725         COMPARE_SCALAR_FIELD(requiredPerms);
1726         COMPARE_SCALAR_FIELD(checkAsUser);
1727
1728         return true;
1729 }
1730
1731 static bool
1732 _equalSortClause(SortClause *a, SortClause *b)
1733 {
1734         COMPARE_SCALAR_FIELD(tleSortGroupRef);
1735         COMPARE_SCALAR_FIELD(sortop);
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_FkConstraint:
2315                         retval = _equalFkConstraint(a, b);
2316                         break;
2317                 case T_PrivGrantee:
2318                         retval = _equalPrivGrantee(a, b);
2319                         break;
2320                 case T_FuncWithArgs:
2321                         retval = _equalFuncWithArgs(a, b);
2322                         break;
2323
2324                 default:
2325                         elog(ERROR, "unrecognized node type: %d",
2326                                  (int) nodeTag(a));
2327                         retval = false;         /* keep compiler quiet */
2328                         break;
2329         }
2330
2331         return retval;
2332 }