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