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