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