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