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