]> granicus.if.org Git - postgresql/blob - src/backend/nodes/equalfuncs.c
Support CREATE SCHEMA IF NOT EXISTS.
[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  * NOTE: it is intentional that parse location fields (in nodes that have
17  * one) are not compared.  This is because we want, for example, a variable
18  * "x" to be considered equal() to another reference to "x" in the query.
19  *
20  *
21  * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
22  * Portions Copyright (c) 1994, Regents of the University of California
23  *
24  * IDENTIFICATION
25  *        src/backend/nodes/equalfuncs.c
26  *
27  *-------------------------------------------------------------------------
28  */
29
30 #include "postgres.h"
31
32 #include "nodes/relation.h"
33 #include "utils/datum.h"
34
35
36 /*
37  * Macros to simplify comparison of different kinds of fields.  Use these
38  * wherever possible to reduce the chance for silly typos.      Note that these
39  * hard-wire the convention that the local variables in an Equal routine are
40  * named 'a' and 'b'.
41  */
42
43 /* Compare a simple scalar field (int, float, bool, enum, etc) */
44 #define COMPARE_SCALAR_FIELD(fldname) \
45         do { \
46                 if (a->fldname != b->fldname) \
47                         return false; \
48         } while (0)
49
50 /* Compare a field that is a pointer to some kind of Node or Node tree */
51 #define COMPARE_NODE_FIELD(fldname) \
52         do { \
53                 if (!equal(a->fldname, b->fldname)) \
54                         return false; \
55         } while (0)
56
57 /* Compare a field that is a pointer to a Bitmapset */
58 #define COMPARE_BITMAPSET_FIELD(fldname) \
59         do { \
60                 if (!bms_equal(a->fldname, b->fldname)) \
61                         return false; \
62         } while (0)
63
64 /* Compare a field that is a pointer to a C string, or perhaps NULL */
65 #define COMPARE_STRING_FIELD(fldname) \
66         do { \
67                 if (!equalstr(a->fldname, b->fldname)) \
68                         return false; \
69         } while (0)
70
71 /* Macro for comparing string fields that might be NULL */
72 #define equalstr(a, b)  \
73         (((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
74
75 /* Compare a field that is a pointer to a simple palloc'd object of size sz */
76 #define COMPARE_POINTER_FIELD(fldname, sz) \
77         do { \
78                 if (memcmp(a->fldname, b->fldname, (sz)) != 0) \
79                         return false; \
80         } while (0)
81
82 /* Compare a parse location field (this is a no-op, per note above) */
83 #define COMPARE_LOCATION_FIELD(fldname) \
84         ((void) 0)
85
86
87 /*
88  *      Stuff from primnodes.h
89  */
90
91 static bool
92 _equalAlias(const Alias *a, const Alias *b)
93 {
94         COMPARE_STRING_FIELD(aliasname);
95         COMPARE_NODE_FIELD(colnames);
96
97         return true;
98 }
99
100 static bool
101 _equalRangeVar(const RangeVar *a, const RangeVar *b)
102 {
103         COMPARE_STRING_FIELD(catalogname);
104         COMPARE_STRING_FIELD(schemaname);
105         COMPARE_STRING_FIELD(relname);
106         COMPARE_SCALAR_FIELD(inhOpt);
107         COMPARE_SCALAR_FIELD(relpersistence);
108         COMPARE_NODE_FIELD(alias);
109         COMPARE_LOCATION_FIELD(location);
110
111         return true;
112 }
113
114 static bool
115 _equalIntoClause(const IntoClause *a, const IntoClause *b)
116 {
117         COMPARE_NODE_FIELD(rel);
118         COMPARE_NODE_FIELD(colNames);
119         COMPARE_NODE_FIELD(options);
120         COMPARE_SCALAR_FIELD(onCommit);
121         COMPARE_STRING_FIELD(tableSpaceName);
122         COMPARE_SCALAR_FIELD(skipData);
123
124         return true;
125 }
126
127 /*
128  * We don't need an _equalExpr because Expr is an abstract supertype which
129  * should never actually get instantiated.      Also, since it has no common
130  * fields except NodeTag, there's no need for a helper routine to factor
131  * out comparing the common fields...
132  */
133
134 static bool
135 _equalVar(const Var *a, const Var *b)
136 {
137         COMPARE_SCALAR_FIELD(varno);
138         COMPARE_SCALAR_FIELD(varattno);
139         COMPARE_SCALAR_FIELD(vartype);
140         COMPARE_SCALAR_FIELD(vartypmod);
141         COMPARE_SCALAR_FIELD(varcollid);
142         COMPARE_SCALAR_FIELD(varlevelsup);
143         COMPARE_SCALAR_FIELD(varnoold);
144         COMPARE_SCALAR_FIELD(varoattno);
145         COMPARE_LOCATION_FIELD(location);
146
147         return true;
148 }
149
150 static bool
151 _equalConst(const Const *a, const Const *b)
152 {
153         COMPARE_SCALAR_FIELD(consttype);
154         COMPARE_SCALAR_FIELD(consttypmod);
155         COMPARE_SCALAR_FIELD(constcollid);
156         COMPARE_SCALAR_FIELD(constlen);
157         COMPARE_SCALAR_FIELD(constisnull);
158         COMPARE_SCALAR_FIELD(constbyval);
159         COMPARE_LOCATION_FIELD(location);
160
161         /*
162          * We treat all NULL constants of the same type as equal. Someday this
163          * might need to change?  But datumIsEqual doesn't work on nulls, so...
164          */
165         if (a->constisnull)
166                 return true;
167         return datumIsEqual(a->constvalue, b->constvalue,
168                                                 a->constbyval, a->constlen);
169 }
170
171 static bool
172 _equalParam(const Param *a, const Param *b)
173 {
174         COMPARE_SCALAR_FIELD(paramkind);
175         COMPARE_SCALAR_FIELD(paramid);
176         COMPARE_SCALAR_FIELD(paramtype);
177         COMPARE_SCALAR_FIELD(paramtypmod);
178         COMPARE_SCALAR_FIELD(paramcollid);
179         COMPARE_LOCATION_FIELD(location);
180
181         return true;
182 }
183
184 static bool
185 _equalAggref(const Aggref *a, const Aggref *b)
186 {
187         COMPARE_SCALAR_FIELD(aggfnoid);
188         COMPARE_SCALAR_FIELD(aggtype);
189         COMPARE_SCALAR_FIELD(aggcollid);
190         COMPARE_SCALAR_FIELD(inputcollid);
191         COMPARE_NODE_FIELD(args);
192         COMPARE_NODE_FIELD(aggorder);
193         COMPARE_NODE_FIELD(aggdistinct);
194         COMPARE_SCALAR_FIELD(aggstar);
195         COMPARE_SCALAR_FIELD(agglevelsup);
196         COMPARE_LOCATION_FIELD(location);
197
198         return true;
199 }
200
201 static bool
202 _equalWindowFunc(const WindowFunc *a, const WindowFunc *b)
203 {
204         COMPARE_SCALAR_FIELD(winfnoid);
205         COMPARE_SCALAR_FIELD(wintype);
206         COMPARE_SCALAR_FIELD(wincollid);
207         COMPARE_SCALAR_FIELD(inputcollid);
208         COMPARE_NODE_FIELD(args);
209         COMPARE_SCALAR_FIELD(winref);
210         COMPARE_SCALAR_FIELD(winstar);
211         COMPARE_SCALAR_FIELD(winagg);
212         COMPARE_LOCATION_FIELD(location);
213
214         return true;
215 }
216
217 static bool
218 _equalArrayRef(const ArrayRef *a, const ArrayRef *b)
219 {
220         COMPARE_SCALAR_FIELD(refarraytype);
221         COMPARE_SCALAR_FIELD(refelemtype);
222         COMPARE_SCALAR_FIELD(reftypmod);
223         COMPARE_SCALAR_FIELD(refcollid);
224         COMPARE_NODE_FIELD(refupperindexpr);
225         COMPARE_NODE_FIELD(reflowerindexpr);
226         COMPARE_NODE_FIELD(refexpr);
227         COMPARE_NODE_FIELD(refassgnexpr);
228
229         return true;
230 }
231
232 static bool
233 _equalFuncExpr(const FuncExpr *a, const FuncExpr *b)
234 {
235         COMPARE_SCALAR_FIELD(funcid);
236         COMPARE_SCALAR_FIELD(funcresulttype);
237         COMPARE_SCALAR_FIELD(funcretset);
238
239         /*
240          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
241          * that are equal() to both explicit and implicit coercions.
242          */
243         if (a->funcformat != b->funcformat &&
244                 a->funcformat != COERCE_DONTCARE &&
245                 b->funcformat != COERCE_DONTCARE)
246                 return false;
247
248         COMPARE_SCALAR_FIELD(funccollid);
249         COMPARE_SCALAR_FIELD(inputcollid);
250         COMPARE_NODE_FIELD(args);
251         COMPARE_LOCATION_FIELD(location);
252
253         return true;
254 }
255
256 static bool
257 _equalNamedArgExpr(const NamedArgExpr *a, const NamedArgExpr *b)
258 {
259         COMPARE_NODE_FIELD(arg);
260         COMPARE_STRING_FIELD(name);
261         COMPARE_SCALAR_FIELD(argnumber);
262         COMPARE_LOCATION_FIELD(location);
263
264         return true;
265 }
266
267 static bool
268 _equalOpExpr(const OpExpr *a, const OpExpr *b)
269 {
270         COMPARE_SCALAR_FIELD(opno);
271
272         /*
273          * Special-case opfuncid: it is allowable for it to differ if one node
274          * contains zero and the other doesn't.  This just means that the one node
275          * isn't as far along in the parse/plan pipeline and hasn't had the
276          * opfuncid cache filled yet.
277          */
278         if (a->opfuncid != b->opfuncid &&
279                 a->opfuncid != 0 &&
280                 b->opfuncid != 0)
281                 return false;
282
283         COMPARE_SCALAR_FIELD(opresulttype);
284         COMPARE_SCALAR_FIELD(opretset);
285         COMPARE_SCALAR_FIELD(opcollid);
286         COMPARE_SCALAR_FIELD(inputcollid);
287         COMPARE_NODE_FIELD(args);
288         COMPARE_LOCATION_FIELD(location);
289
290         return true;
291 }
292
293 static bool
294 _equalDistinctExpr(const DistinctExpr *a, const DistinctExpr *b)
295 {
296         COMPARE_SCALAR_FIELD(opno);
297
298         /*
299          * Special-case opfuncid: it is allowable for it to differ if one node
300          * contains zero and the other doesn't.  This just means that the one node
301          * isn't as far along in the parse/plan pipeline and hasn't had the
302          * opfuncid cache filled yet.
303          */
304         if (a->opfuncid != b->opfuncid &&
305                 a->opfuncid != 0 &&
306                 b->opfuncid != 0)
307                 return false;
308
309         COMPARE_SCALAR_FIELD(opresulttype);
310         COMPARE_SCALAR_FIELD(opretset);
311         COMPARE_SCALAR_FIELD(opcollid);
312         COMPARE_SCALAR_FIELD(inputcollid);
313         COMPARE_NODE_FIELD(args);
314         COMPARE_LOCATION_FIELD(location);
315
316         return true;
317 }
318
319 static bool
320 _equalNullIfExpr(const NullIfExpr *a, const NullIfExpr *b)
321 {
322         COMPARE_SCALAR_FIELD(opno);
323
324         /*
325          * Special-case opfuncid: it is allowable for it to differ if one node
326          * contains zero and the other doesn't.  This just means that the one node
327          * isn't as far along in the parse/plan pipeline and hasn't had the
328          * opfuncid cache filled yet.
329          */
330         if (a->opfuncid != b->opfuncid &&
331                 a->opfuncid != 0 &&
332                 b->opfuncid != 0)
333                 return false;
334
335         COMPARE_SCALAR_FIELD(opresulttype);
336         COMPARE_SCALAR_FIELD(opretset);
337         COMPARE_SCALAR_FIELD(opcollid);
338         COMPARE_SCALAR_FIELD(inputcollid);
339         COMPARE_NODE_FIELD(args);
340         COMPARE_LOCATION_FIELD(location);
341
342         return true;
343 }
344
345 static bool
346 _equalScalarArrayOpExpr(const ScalarArrayOpExpr *a, const ScalarArrayOpExpr *b)
347 {
348         COMPARE_SCALAR_FIELD(opno);
349
350         /*
351          * Special-case opfuncid: it is allowable for it to differ if one node
352          * contains zero and the other doesn't.  This just means that the one node
353          * isn't as far along in the parse/plan pipeline and hasn't had the
354          * opfuncid cache filled yet.
355          */
356         if (a->opfuncid != b->opfuncid &&
357                 a->opfuncid != 0 &&
358                 b->opfuncid != 0)
359                 return false;
360
361         COMPARE_SCALAR_FIELD(useOr);
362         COMPARE_SCALAR_FIELD(inputcollid);
363         COMPARE_NODE_FIELD(args);
364         COMPARE_LOCATION_FIELD(location);
365
366         return true;
367 }
368
369 static bool
370 _equalBoolExpr(const BoolExpr *a, const BoolExpr *b)
371 {
372         COMPARE_SCALAR_FIELD(boolop);
373         COMPARE_NODE_FIELD(args);
374         COMPARE_LOCATION_FIELD(location);
375
376         return true;
377 }
378
379 static bool
380 _equalSubLink(const SubLink *a, const SubLink *b)
381 {
382         COMPARE_SCALAR_FIELD(subLinkType);
383         COMPARE_NODE_FIELD(testexpr);
384         COMPARE_NODE_FIELD(operName);
385         COMPARE_NODE_FIELD(subselect);
386         COMPARE_LOCATION_FIELD(location);
387
388         return true;
389 }
390
391 static bool
392 _equalSubPlan(const SubPlan *a, const SubPlan *b)
393 {
394         COMPARE_SCALAR_FIELD(subLinkType);
395         COMPARE_NODE_FIELD(testexpr);
396         COMPARE_NODE_FIELD(paramIds);
397         COMPARE_SCALAR_FIELD(plan_id);
398         COMPARE_STRING_FIELD(plan_name);
399         COMPARE_SCALAR_FIELD(firstColType);
400         COMPARE_SCALAR_FIELD(firstColTypmod);
401         COMPARE_SCALAR_FIELD(firstColCollation);
402         COMPARE_SCALAR_FIELD(useHashTable);
403         COMPARE_SCALAR_FIELD(unknownEqFalse);
404         COMPARE_NODE_FIELD(setParam);
405         COMPARE_NODE_FIELD(parParam);
406         COMPARE_NODE_FIELD(args);
407         COMPARE_SCALAR_FIELD(startup_cost);
408         COMPARE_SCALAR_FIELD(per_call_cost);
409
410         return true;
411 }
412
413 static bool
414 _equalAlternativeSubPlan(const AlternativeSubPlan *a, const AlternativeSubPlan *b)
415 {
416         COMPARE_NODE_FIELD(subplans);
417
418         return true;
419 }
420
421 static bool
422 _equalFieldSelect(const FieldSelect *a, const FieldSelect *b)
423 {
424         COMPARE_NODE_FIELD(arg);
425         COMPARE_SCALAR_FIELD(fieldnum);
426         COMPARE_SCALAR_FIELD(resulttype);
427         COMPARE_SCALAR_FIELD(resulttypmod);
428         COMPARE_SCALAR_FIELD(resultcollid);
429
430         return true;
431 }
432
433 static bool
434 _equalFieldStore(const FieldStore *a, const FieldStore *b)
435 {
436         COMPARE_NODE_FIELD(arg);
437         COMPARE_NODE_FIELD(newvals);
438         COMPARE_NODE_FIELD(fieldnums);
439         COMPARE_SCALAR_FIELD(resulttype);
440
441         return true;
442 }
443
444 static bool
445 _equalRelabelType(const RelabelType *a, const RelabelType *b)
446 {
447         COMPARE_NODE_FIELD(arg);
448         COMPARE_SCALAR_FIELD(resulttype);
449         COMPARE_SCALAR_FIELD(resulttypmod);
450         COMPARE_SCALAR_FIELD(resultcollid);
451
452         /*
453          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
454          * that are equal() to both explicit and implicit coercions.
455          */
456         if (a->relabelformat != b->relabelformat &&
457                 a->relabelformat != COERCE_DONTCARE &&
458                 b->relabelformat != COERCE_DONTCARE)
459                 return false;
460
461         COMPARE_LOCATION_FIELD(location);
462
463         return true;
464 }
465
466 static bool
467 _equalCoerceViaIO(const CoerceViaIO *a, const CoerceViaIO *b)
468 {
469         COMPARE_NODE_FIELD(arg);
470         COMPARE_SCALAR_FIELD(resulttype);
471         COMPARE_SCALAR_FIELD(resultcollid);
472
473         /*
474          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
475          * that are equal() to both explicit and implicit coercions.
476          */
477         if (a->coerceformat != b->coerceformat &&
478                 a->coerceformat != COERCE_DONTCARE &&
479                 b->coerceformat != COERCE_DONTCARE)
480                 return false;
481
482         COMPARE_LOCATION_FIELD(location);
483
484         return true;
485 }
486
487 static bool
488 _equalArrayCoerceExpr(const ArrayCoerceExpr *a, const ArrayCoerceExpr *b)
489 {
490         COMPARE_NODE_FIELD(arg);
491         COMPARE_SCALAR_FIELD(elemfuncid);
492         COMPARE_SCALAR_FIELD(resulttype);
493         COMPARE_SCALAR_FIELD(resulttypmod);
494         COMPARE_SCALAR_FIELD(resultcollid);
495         COMPARE_SCALAR_FIELD(isExplicit);
496
497         /*
498          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
499          * that are equal() to both explicit and implicit coercions.
500          */
501         if (a->coerceformat != b->coerceformat &&
502                 a->coerceformat != COERCE_DONTCARE &&
503                 b->coerceformat != COERCE_DONTCARE)
504                 return false;
505
506         COMPARE_LOCATION_FIELD(location);
507
508         return true;
509 }
510
511 static bool
512 _equalConvertRowtypeExpr(const ConvertRowtypeExpr *a, const ConvertRowtypeExpr *b)
513 {
514         COMPARE_NODE_FIELD(arg);
515         COMPARE_SCALAR_FIELD(resulttype);
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->convertformat != b->convertformat &&
522                 a->convertformat != COERCE_DONTCARE &&
523                 b->convertformat != COERCE_DONTCARE)
524                 return false;
525
526         COMPARE_LOCATION_FIELD(location);
527
528         return true;
529 }
530
531 static bool
532 _equalCollateExpr(const CollateExpr *a, const CollateExpr *b)
533 {
534         COMPARE_NODE_FIELD(arg);
535         COMPARE_SCALAR_FIELD(collOid);
536         COMPARE_LOCATION_FIELD(location);
537
538         return true;
539 }
540
541 static bool
542 _equalCaseExpr(const CaseExpr *a, const CaseExpr *b)
543 {
544         COMPARE_SCALAR_FIELD(casetype);
545         COMPARE_SCALAR_FIELD(casecollid);
546         COMPARE_NODE_FIELD(arg);
547         COMPARE_NODE_FIELD(args);
548         COMPARE_NODE_FIELD(defresult);
549         COMPARE_LOCATION_FIELD(location);
550
551         return true;
552 }
553
554 static bool
555 _equalCaseWhen(const CaseWhen *a, const CaseWhen *b)
556 {
557         COMPARE_NODE_FIELD(expr);
558         COMPARE_NODE_FIELD(result);
559         COMPARE_LOCATION_FIELD(location);
560
561         return true;
562 }
563
564 static bool
565 _equalCaseTestExpr(const CaseTestExpr *a, const CaseTestExpr *b)
566 {
567         COMPARE_SCALAR_FIELD(typeId);
568         COMPARE_SCALAR_FIELD(typeMod);
569         COMPARE_SCALAR_FIELD(collation);
570
571         return true;
572 }
573
574 static bool
575 _equalArrayExpr(const ArrayExpr *a, const ArrayExpr *b)
576 {
577         COMPARE_SCALAR_FIELD(array_typeid);
578         COMPARE_SCALAR_FIELD(array_collid);
579         COMPARE_SCALAR_FIELD(element_typeid);
580         COMPARE_NODE_FIELD(elements);
581         COMPARE_SCALAR_FIELD(multidims);
582         COMPARE_LOCATION_FIELD(location);
583
584         return true;
585 }
586
587 static bool
588 _equalRowExpr(const RowExpr *a, const RowExpr *b)
589 {
590         COMPARE_NODE_FIELD(args);
591         COMPARE_SCALAR_FIELD(row_typeid);
592
593         /*
594          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
595          * that are equal() to both explicit and implicit coercions.
596          */
597         if (a->row_format != b->row_format &&
598                 a->row_format != COERCE_DONTCARE &&
599                 b->row_format != COERCE_DONTCARE)
600                 return false;
601
602         COMPARE_NODE_FIELD(colnames);
603         COMPARE_LOCATION_FIELD(location);
604
605         return true;
606 }
607
608 static bool
609 _equalRowCompareExpr(const RowCompareExpr *a, const RowCompareExpr *b)
610 {
611         COMPARE_SCALAR_FIELD(rctype);
612         COMPARE_NODE_FIELD(opnos);
613         COMPARE_NODE_FIELD(opfamilies);
614         COMPARE_NODE_FIELD(inputcollids);
615         COMPARE_NODE_FIELD(largs);
616         COMPARE_NODE_FIELD(rargs);
617
618         return true;
619 }
620
621 static bool
622 _equalCoalesceExpr(const CoalesceExpr *a, const CoalesceExpr *b)
623 {
624         COMPARE_SCALAR_FIELD(coalescetype);
625         COMPARE_SCALAR_FIELD(coalescecollid);
626         COMPARE_NODE_FIELD(args);
627         COMPARE_LOCATION_FIELD(location);
628
629         return true;
630 }
631
632 static bool
633 _equalMinMaxExpr(const MinMaxExpr *a, const MinMaxExpr *b)
634 {
635         COMPARE_SCALAR_FIELD(minmaxtype);
636         COMPARE_SCALAR_FIELD(minmaxcollid);
637         COMPARE_SCALAR_FIELD(inputcollid);
638         COMPARE_SCALAR_FIELD(op);
639         COMPARE_NODE_FIELD(args);
640         COMPARE_LOCATION_FIELD(location);
641
642         return true;
643 }
644
645 static bool
646 _equalXmlExpr(const XmlExpr *a, const XmlExpr *b)
647 {
648         COMPARE_SCALAR_FIELD(op);
649         COMPARE_STRING_FIELD(name);
650         COMPARE_NODE_FIELD(named_args);
651         COMPARE_NODE_FIELD(arg_names);
652         COMPARE_NODE_FIELD(args);
653         COMPARE_SCALAR_FIELD(xmloption);
654         COMPARE_SCALAR_FIELD(type);
655         COMPARE_SCALAR_FIELD(typmod);
656         COMPARE_LOCATION_FIELD(location);
657
658         return true;
659 }
660
661 static bool
662 _equalNullTest(const NullTest *a, const NullTest *b)
663 {
664         COMPARE_NODE_FIELD(arg);
665         COMPARE_SCALAR_FIELD(nulltesttype);
666         COMPARE_SCALAR_FIELD(argisrow);
667
668         return true;
669 }
670
671 static bool
672 _equalBooleanTest(const BooleanTest *a, const BooleanTest *b)
673 {
674         COMPARE_NODE_FIELD(arg);
675         COMPARE_SCALAR_FIELD(booltesttype);
676
677         return true;
678 }
679
680 static bool
681 _equalCoerceToDomain(const CoerceToDomain *a, const CoerceToDomain *b)
682 {
683         COMPARE_NODE_FIELD(arg);
684         COMPARE_SCALAR_FIELD(resulttype);
685         COMPARE_SCALAR_FIELD(resulttypmod);
686         COMPARE_SCALAR_FIELD(resultcollid);
687
688         /*
689          * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
690          * that are equal() to both explicit and implicit coercions.
691          */
692         if (a->coercionformat != b->coercionformat &&
693                 a->coercionformat != COERCE_DONTCARE &&
694                 b->coercionformat != COERCE_DONTCARE)
695                 return false;
696
697         COMPARE_LOCATION_FIELD(location);
698
699         return true;
700 }
701
702 static bool
703 _equalCoerceToDomainValue(const CoerceToDomainValue *a, const CoerceToDomainValue *b)
704 {
705         COMPARE_SCALAR_FIELD(typeId);
706         COMPARE_SCALAR_FIELD(typeMod);
707         COMPARE_SCALAR_FIELD(collation);
708         COMPARE_LOCATION_FIELD(location);
709
710         return true;
711 }
712
713 static bool
714 _equalSetToDefault(const SetToDefault *a, const SetToDefault *b)
715 {
716         COMPARE_SCALAR_FIELD(typeId);
717         COMPARE_SCALAR_FIELD(typeMod);
718         COMPARE_SCALAR_FIELD(collation);
719         COMPARE_LOCATION_FIELD(location);
720
721         return true;
722 }
723
724 static bool
725 _equalCurrentOfExpr(const CurrentOfExpr *a, const CurrentOfExpr *b)
726 {
727         COMPARE_SCALAR_FIELD(cvarno);
728         COMPARE_STRING_FIELD(cursor_name);
729         COMPARE_SCALAR_FIELD(cursor_param);
730
731         return true;
732 }
733
734 static bool
735 _equalTargetEntry(const TargetEntry *a, const TargetEntry *b)
736 {
737         COMPARE_NODE_FIELD(expr);
738         COMPARE_SCALAR_FIELD(resno);
739         COMPARE_STRING_FIELD(resname);
740         COMPARE_SCALAR_FIELD(ressortgroupref);
741         COMPARE_SCALAR_FIELD(resorigtbl);
742         COMPARE_SCALAR_FIELD(resorigcol);
743         COMPARE_SCALAR_FIELD(resjunk);
744
745         return true;
746 }
747
748 static bool
749 _equalRangeTblRef(const RangeTblRef *a, const RangeTblRef *b)
750 {
751         COMPARE_SCALAR_FIELD(rtindex);
752
753         return true;
754 }
755
756 static bool
757 _equalJoinExpr(const JoinExpr *a, const JoinExpr *b)
758 {
759         COMPARE_SCALAR_FIELD(jointype);
760         COMPARE_SCALAR_FIELD(isNatural);
761         COMPARE_NODE_FIELD(larg);
762         COMPARE_NODE_FIELD(rarg);
763         COMPARE_NODE_FIELD(usingClause);
764         COMPARE_NODE_FIELD(quals);
765         COMPARE_NODE_FIELD(alias);
766         COMPARE_SCALAR_FIELD(rtindex);
767
768         return true;
769 }
770
771 static bool
772 _equalFromExpr(const FromExpr *a, const FromExpr *b)
773 {
774         COMPARE_NODE_FIELD(fromlist);
775         COMPARE_NODE_FIELD(quals);
776
777         return true;
778 }
779
780
781 /*
782  * Stuff from relation.h
783  */
784
785 static bool
786 _equalPathKey(const PathKey *a, const PathKey *b)
787 {
788         /*
789          * This is normally used on non-canonicalized PathKeys, so must chase up
790          * to the topmost merged EquivalenceClass and see if those are the same
791          * (by pointer equality).
792          */
793         EquivalenceClass *a_eclass;
794         EquivalenceClass *b_eclass;
795
796         a_eclass = a->pk_eclass;
797         while (a_eclass->ec_merged)
798                 a_eclass = a_eclass->ec_merged;
799         b_eclass = b->pk_eclass;
800         while (b_eclass->ec_merged)
801                 b_eclass = b_eclass->ec_merged;
802         if (a_eclass != b_eclass)
803                 return false;
804         COMPARE_SCALAR_FIELD(pk_opfamily);
805         COMPARE_SCALAR_FIELD(pk_strategy);
806         COMPARE_SCALAR_FIELD(pk_nulls_first);
807
808         return true;
809 }
810
811 static bool
812 _equalRestrictInfo(const RestrictInfo *a, const RestrictInfo *b)
813 {
814         COMPARE_NODE_FIELD(clause);
815         COMPARE_SCALAR_FIELD(is_pushed_down);
816         COMPARE_SCALAR_FIELD(outerjoin_delayed);
817         COMPARE_BITMAPSET_FIELD(required_relids);
818         COMPARE_BITMAPSET_FIELD(outer_relids);
819         COMPARE_BITMAPSET_FIELD(nullable_relids);
820
821         /*
822          * We ignore all the remaining fields, since they may not be set yet, and
823          * should be derivable from the clause anyway.
824          */
825
826         return true;
827 }
828
829 static bool
830 _equalPlaceHolderVar(const PlaceHolderVar *a, const PlaceHolderVar *b)
831 {
832         /*
833          * We intentionally do not compare phexpr.      Two PlaceHolderVars with the
834          * same ID and levelsup should be considered equal even if the contained
835          * expressions have managed to mutate to different states.      One way in
836          * which that can happen is that initplan sublinks would get replaced by
837          * differently-numbered Params when sublink folding is done.  (The end
838          * result of such a situation would be some unreferenced initplans, which
839          * is annoying but not really a problem.)
840          *
841          * COMPARE_NODE_FIELD(phexpr);
842          */
843         COMPARE_BITMAPSET_FIELD(phrels);
844         COMPARE_SCALAR_FIELD(phid);
845         COMPARE_SCALAR_FIELD(phlevelsup);
846
847         return true;
848 }
849
850 static bool
851 _equalSpecialJoinInfo(const SpecialJoinInfo *a, const SpecialJoinInfo *b)
852 {
853         COMPARE_BITMAPSET_FIELD(min_lefthand);
854         COMPARE_BITMAPSET_FIELD(min_righthand);
855         COMPARE_BITMAPSET_FIELD(syn_lefthand);
856         COMPARE_BITMAPSET_FIELD(syn_righthand);
857         COMPARE_SCALAR_FIELD(jointype);
858         COMPARE_SCALAR_FIELD(lhs_strict);
859         COMPARE_SCALAR_FIELD(delay_upper_joins);
860         COMPARE_NODE_FIELD(join_quals);
861
862         return true;
863 }
864
865 static bool
866 _equalLateralJoinInfo(const LateralJoinInfo *a, const LateralJoinInfo *b)
867 {
868         COMPARE_SCALAR_FIELD(lateral_rhs);
869         COMPARE_BITMAPSET_FIELD(lateral_lhs);
870
871         return true;
872 }
873
874 static bool
875 _equalAppendRelInfo(const AppendRelInfo *a, const AppendRelInfo *b)
876 {
877         COMPARE_SCALAR_FIELD(parent_relid);
878         COMPARE_SCALAR_FIELD(child_relid);
879         COMPARE_SCALAR_FIELD(parent_reltype);
880         COMPARE_SCALAR_FIELD(child_reltype);
881         COMPARE_NODE_FIELD(translated_vars);
882         COMPARE_SCALAR_FIELD(parent_reloid);
883
884         return true;
885 }
886
887 static bool
888 _equalPlaceHolderInfo(const PlaceHolderInfo *a, const PlaceHolderInfo *b)
889 {
890         COMPARE_SCALAR_FIELD(phid);
891         COMPARE_NODE_FIELD(ph_var);
892         COMPARE_BITMAPSET_FIELD(ph_eval_at);
893         COMPARE_BITMAPSET_FIELD(ph_needed);
894         COMPARE_BITMAPSET_FIELD(ph_may_need);
895         COMPARE_SCALAR_FIELD(ph_width);
896
897         return true;
898 }
899
900
901 /*
902  * Stuff from parsenodes.h
903  */
904
905 static bool
906 _equalQuery(const Query *a, const Query *b)
907 {
908         COMPARE_SCALAR_FIELD(commandType);
909         COMPARE_SCALAR_FIELD(querySource);
910         /* we intentionally ignore queryId, since it might not be set */
911         COMPARE_SCALAR_FIELD(canSetTag);
912         COMPARE_NODE_FIELD(utilityStmt);
913         COMPARE_SCALAR_FIELD(resultRelation);
914         COMPARE_SCALAR_FIELD(hasAggs);
915         COMPARE_SCALAR_FIELD(hasWindowFuncs);
916         COMPARE_SCALAR_FIELD(hasSubLinks);
917         COMPARE_SCALAR_FIELD(hasDistinctOn);
918         COMPARE_SCALAR_FIELD(hasRecursive);
919         COMPARE_SCALAR_FIELD(hasModifyingCTE);
920         COMPARE_SCALAR_FIELD(hasForUpdate);
921         COMPARE_NODE_FIELD(cteList);
922         COMPARE_NODE_FIELD(rtable);
923         COMPARE_NODE_FIELD(jointree);
924         COMPARE_NODE_FIELD(targetList);
925         COMPARE_NODE_FIELD(returningList);
926         COMPARE_NODE_FIELD(groupClause);
927         COMPARE_NODE_FIELD(havingQual);
928         COMPARE_NODE_FIELD(windowClause);
929         COMPARE_NODE_FIELD(distinctClause);
930         COMPARE_NODE_FIELD(sortClause);
931         COMPARE_NODE_FIELD(limitOffset);
932         COMPARE_NODE_FIELD(limitCount);
933         COMPARE_NODE_FIELD(rowMarks);
934         COMPARE_NODE_FIELD(setOperations);
935         COMPARE_NODE_FIELD(constraintDeps);
936
937         return true;
938 }
939
940 static bool
941 _equalInsertStmt(const InsertStmt *a, const InsertStmt *b)
942 {
943         COMPARE_NODE_FIELD(relation);
944         COMPARE_NODE_FIELD(cols);
945         COMPARE_NODE_FIELD(selectStmt);
946         COMPARE_NODE_FIELD(returningList);
947         COMPARE_NODE_FIELD(withClause);
948
949         return true;
950 }
951
952 static bool
953 _equalDeleteStmt(const DeleteStmt *a, const DeleteStmt *b)
954 {
955         COMPARE_NODE_FIELD(relation);
956         COMPARE_NODE_FIELD(usingClause);
957         COMPARE_NODE_FIELD(whereClause);
958         COMPARE_NODE_FIELD(returningList);
959         COMPARE_NODE_FIELD(withClause);
960
961         return true;
962 }
963
964 static bool
965 _equalUpdateStmt(const UpdateStmt *a, const UpdateStmt *b)
966 {
967         COMPARE_NODE_FIELD(relation);
968         COMPARE_NODE_FIELD(targetList);
969         COMPARE_NODE_FIELD(whereClause);
970         COMPARE_NODE_FIELD(fromClause);
971         COMPARE_NODE_FIELD(returningList);
972         COMPARE_NODE_FIELD(withClause);
973
974         return true;
975 }
976
977 static bool
978 _equalSelectStmt(const SelectStmt *a, const SelectStmt *b)
979 {
980         COMPARE_NODE_FIELD(distinctClause);
981         COMPARE_NODE_FIELD(intoClause);
982         COMPARE_NODE_FIELD(targetList);
983         COMPARE_NODE_FIELD(fromClause);
984         COMPARE_NODE_FIELD(whereClause);
985         COMPARE_NODE_FIELD(groupClause);
986         COMPARE_NODE_FIELD(havingClause);
987         COMPARE_NODE_FIELD(windowClause);
988         COMPARE_NODE_FIELD(valuesLists);
989         COMPARE_NODE_FIELD(sortClause);
990         COMPARE_NODE_FIELD(limitOffset);
991         COMPARE_NODE_FIELD(limitCount);
992         COMPARE_NODE_FIELD(lockingClause);
993         COMPARE_NODE_FIELD(withClause);
994         COMPARE_SCALAR_FIELD(op);
995         COMPARE_SCALAR_FIELD(all);
996         COMPARE_NODE_FIELD(larg);
997         COMPARE_NODE_FIELD(rarg);
998
999         return true;
1000 }
1001
1002 static bool
1003 _equalSetOperationStmt(const SetOperationStmt *a, const SetOperationStmt *b)
1004 {
1005         COMPARE_SCALAR_FIELD(op);
1006         COMPARE_SCALAR_FIELD(all);
1007         COMPARE_NODE_FIELD(larg);
1008         COMPARE_NODE_FIELD(rarg);
1009         COMPARE_NODE_FIELD(colTypes);
1010         COMPARE_NODE_FIELD(colTypmods);
1011         COMPARE_NODE_FIELD(colCollations);
1012         COMPARE_NODE_FIELD(groupClauses);
1013
1014         return true;
1015 }
1016
1017 static bool
1018 _equalAlterTableStmt(const AlterTableStmt *a, const AlterTableStmt *b)
1019 {
1020         COMPARE_NODE_FIELD(relation);
1021         COMPARE_NODE_FIELD(cmds);
1022         COMPARE_SCALAR_FIELD(relkind);
1023         COMPARE_SCALAR_FIELD(missing_ok);
1024
1025         return true;
1026 }
1027
1028 static bool
1029 _equalAlterTableCmd(const AlterTableCmd *a, const AlterTableCmd *b)
1030 {
1031         COMPARE_SCALAR_FIELD(subtype);
1032         COMPARE_STRING_FIELD(name);
1033         COMPARE_NODE_FIELD(def);
1034         COMPARE_SCALAR_FIELD(behavior);
1035         COMPARE_SCALAR_FIELD(missing_ok);
1036
1037         return true;
1038 }
1039
1040 static bool
1041 _equalAlterDomainStmt(const AlterDomainStmt *a, const AlterDomainStmt *b)
1042 {
1043         COMPARE_SCALAR_FIELD(subtype);
1044         COMPARE_NODE_FIELD(typeName);
1045         COMPARE_STRING_FIELD(name);
1046         COMPARE_NODE_FIELD(def);
1047         COMPARE_SCALAR_FIELD(behavior);
1048         COMPARE_SCALAR_FIELD(missing_ok);
1049
1050         return true;
1051 }
1052
1053 static bool
1054 _equalGrantStmt(const GrantStmt *a, const GrantStmt *b)
1055 {
1056         COMPARE_SCALAR_FIELD(is_grant);
1057         COMPARE_SCALAR_FIELD(targtype);
1058         COMPARE_SCALAR_FIELD(objtype);
1059         COMPARE_NODE_FIELD(objects);
1060         COMPARE_NODE_FIELD(privileges);
1061         COMPARE_NODE_FIELD(grantees);
1062         COMPARE_SCALAR_FIELD(grant_option);
1063         COMPARE_SCALAR_FIELD(behavior);
1064
1065         return true;
1066 }
1067
1068 static bool
1069 _equalPrivGrantee(const PrivGrantee *a, const PrivGrantee *b)
1070 {
1071         COMPARE_STRING_FIELD(rolname);
1072
1073         return true;
1074 }
1075
1076 static bool
1077 _equalFuncWithArgs(const FuncWithArgs *a, const FuncWithArgs *b)
1078 {
1079         COMPARE_NODE_FIELD(funcname);
1080         COMPARE_NODE_FIELD(funcargs);
1081
1082         return true;
1083 }
1084
1085 static bool
1086 _equalAccessPriv(const AccessPriv *a, const AccessPriv *b)
1087 {
1088         COMPARE_STRING_FIELD(priv_name);
1089         COMPARE_NODE_FIELD(cols);
1090
1091         return true;
1092 }
1093
1094 static bool
1095 _equalGrantRoleStmt(const GrantRoleStmt *a, const GrantRoleStmt *b)
1096 {
1097         COMPARE_NODE_FIELD(granted_roles);
1098         COMPARE_NODE_FIELD(grantee_roles);
1099         COMPARE_SCALAR_FIELD(is_grant);
1100         COMPARE_SCALAR_FIELD(admin_opt);
1101         COMPARE_STRING_FIELD(grantor);
1102         COMPARE_SCALAR_FIELD(behavior);
1103
1104         return true;
1105 }
1106
1107 static bool
1108 _equalAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *a, const AlterDefaultPrivilegesStmt *b)
1109 {
1110         COMPARE_NODE_FIELD(options);
1111         COMPARE_NODE_FIELD(action);
1112
1113         return true;
1114 }
1115
1116 static bool
1117 _equalDeclareCursorStmt(const DeclareCursorStmt *a, const DeclareCursorStmt *b)
1118 {
1119         COMPARE_STRING_FIELD(portalname);
1120         COMPARE_SCALAR_FIELD(options);
1121         COMPARE_NODE_FIELD(query);
1122
1123         return true;
1124 }
1125
1126 static bool
1127 _equalClosePortalStmt(const ClosePortalStmt *a, const ClosePortalStmt *b)
1128 {
1129         COMPARE_STRING_FIELD(portalname);
1130
1131         return true;
1132 }
1133
1134 static bool
1135 _equalClusterStmt(const ClusterStmt *a, const ClusterStmt *b)
1136 {
1137         COMPARE_NODE_FIELD(relation);
1138         COMPARE_STRING_FIELD(indexname);
1139         COMPARE_SCALAR_FIELD(verbose);
1140
1141         return true;
1142 }
1143
1144 static bool
1145 _equalCopyStmt(const CopyStmt *a, const CopyStmt *b)
1146 {
1147         COMPARE_NODE_FIELD(relation);
1148         COMPARE_NODE_FIELD(query);
1149         COMPARE_NODE_FIELD(attlist);
1150         COMPARE_SCALAR_FIELD(is_from);
1151         COMPARE_STRING_FIELD(filename);
1152         COMPARE_NODE_FIELD(options);
1153
1154         return true;
1155 }
1156
1157 static bool
1158 _equalCreateStmt(const CreateStmt *a, const CreateStmt *b)
1159 {
1160         COMPARE_NODE_FIELD(relation);
1161         COMPARE_NODE_FIELD(tableElts);
1162         COMPARE_NODE_FIELD(inhRelations);
1163         COMPARE_NODE_FIELD(ofTypename);
1164         COMPARE_NODE_FIELD(constraints);
1165         COMPARE_NODE_FIELD(options);
1166         COMPARE_SCALAR_FIELD(oncommit);
1167         COMPARE_STRING_FIELD(tablespacename);
1168         COMPARE_SCALAR_FIELD(if_not_exists);
1169
1170         return true;
1171 }
1172
1173 static bool
1174 _equalTableLikeClause(const TableLikeClause *a, const TableLikeClause *b)
1175 {
1176         COMPARE_NODE_FIELD(relation);
1177         COMPARE_SCALAR_FIELD(options);
1178
1179         return true;
1180 }
1181
1182 static bool
1183 _equalDefineStmt(const DefineStmt *a, const DefineStmt *b)
1184 {
1185         COMPARE_SCALAR_FIELD(kind);
1186         COMPARE_SCALAR_FIELD(oldstyle);
1187         COMPARE_NODE_FIELD(defnames);
1188         COMPARE_NODE_FIELD(args);
1189         COMPARE_NODE_FIELD(definition);
1190
1191         return true;
1192 }
1193
1194 static bool
1195 _equalDropStmt(const DropStmt *a, const DropStmt *b)
1196 {
1197         COMPARE_NODE_FIELD(objects);
1198         COMPARE_NODE_FIELD(arguments);
1199         COMPARE_SCALAR_FIELD(removeType);
1200         COMPARE_SCALAR_FIELD(behavior);
1201         COMPARE_SCALAR_FIELD(missing_ok);
1202         COMPARE_SCALAR_FIELD(concurrent);
1203
1204         return true;
1205 }
1206
1207 static bool
1208 _equalTruncateStmt(const TruncateStmt *a, const TruncateStmt *b)
1209 {
1210         COMPARE_NODE_FIELD(relations);
1211         COMPARE_SCALAR_FIELD(restart_seqs);
1212         COMPARE_SCALAR_FIELD(behavior);
1213
1214         return true;
1215 }
1216
1217 static bool
1218 _equalCommentStmt(const CommentStmt *a, const CommentStmt *b)
1219 {
1220         COMPARE_SCALAR_FIELD(objtype);
1221         COMPARE_NODE_FIELD(objname);
1222         COMPARE_NODE_FIELD(objargs);
1223         COMPARE_STRING_FIELD(comment);
1224
1225         return true;
1226 }
1227
1228 static bool
1229 _equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b)
1230 {
1231         COMPARE_SCALAR_FIELD(objtype);
1232         COMPARE_NODE_FIELD(objname);
1233         COMPARE_NODE_FIELD(objargs);
1234         COMPARE_STRING_FIELD(provider);
1235         COMPARE_STRING_FIELD(label);
1236
1237         return true;
1238 }
1239
1240 static bool
1241 _equalFetchStmt(const FetchStmt *a, const FetchStmt *b)
1242 {
1243         COMPARE_SCALAR_FIELD(direction);
1244         COMPARE_SCALAR_FIELD(howMany);
1245         COMPARE_STRING_FIELD(portalname);
1246         COMPARE_SCALAR_FIELD(ismove);
1247
1248         return true;
1249 }
1250
1251 static bool
1252 _equalIndexStmt(const IndexStmt *a, const IndexStmt *b)
1253 {
1254         COMPARE_STRING_FIELD(idxname);
1255         COMPARE_NODE_FIELD(relation);
1256         COMPARE_STRING_FIELD(accessMethod);
1257         COMPARE_STRING_FIELD(tableSpace);
1258         COMPARE_NODE_FIELD(indexParams);
1259         COMPARE_NODE_FIELD(options);
1260         COMPARE_NODE_FIELD(whereClause);
1261         COMPARE_NODE_FIELD(excludeOpNames);
1262         COMPARE_STRING_FIELD(idxcomment);
1263         COMPARE_SCALAR_FIELD(indexOid);
1264         COMPARE_SCALAR_FIELD(oldNode);
1265         COMPARE_SCALAR_FIELD(unique);
1266         COMPARE_SCALAR_FIELD(primary);
1267         COMPARE_SCALAR_FIELD(isconstraint);
1268         COMPARE_SCALAR_FIELD(deferrable);
1269         COMPARE_SCALAR_FIELD(initdeferred);
1270         COMPARE_SCALAR_FIELD(concurrent);
1271
1272         return true;
1273 }
1274
1275 static bool
1276 _equalCreateFunctionStmt(const CreateFunctionStmt *a, const CreateFunctionStmt *b)
1277 {
1278         COMPARE_SCALAR_FIELD(replace);
1279         COMPARE_NODE_FIELD(funcname);
1280         COMPARE_NODE_FIELD(parameters);
1281         COMPARE_NODE_FIELD(returnType);
1282         COMPARE_NODE_FIELD(options);
1283         COMPARE_NODE_FIELD(withClause);
1284
1285         return true;
1286 }
1287
1288 static bool
1289 _equalFunctionParameter(const FunctionParameter *a, const FunctionParameter *b)
1290 {
1291         COMPARE_STRING_FIELD(name);
1292         COMPARE_NODE_FIELD(argType);
1293         COMPARE_SCALAR_FIELD(mode);
1294         COMPARE_NODE_FIELD(defexpr);
1295
1296         return true;
1297 }
1298
1299 static bool
1300 _equalAlterFunctionStmt(const AlterFunctionStmt *a, const AlterFunctionStmt *b)
1301 {
1302         COMPARE_NODE_FIELD(func);
1303         COMPARE_NODE_FIELD(actions);
1304
1305         return true;
1306 }
1307
1308 static bool
1309 _equalDoStmt(const DoStmt *a, const DoStmt *b)
1310 {
1311         COMPARE_NODE_FIELD(args);
1312
1313         return true;
1314 }
1315
1316 static bool
1317 _equalRenameStmt(const RenameStmt *a, const RenameStmt *b)
1318 {
1319         COMPARE_SCALAR_FIELD(renameType);
1320         COMPARE_SCALAR_FIELD(relationType);
1321         COMPARE_NODE_FIELD(relation);
1322         COMPARE_NODE_FIELD(object);
1323         COMPARE_NODE_FIELD(objarg);
1324         COMPARE_STRING_FIELD(subname);
1325         COMPARE_STRING_FIELD(newname);
1326         COMPARE_SCALAR_FIELD(behavior);
1327         COMPARE_SCALAR_FIELD(missing_ok);
1328
1329         return true;
1330 }
1331
1332 static bool
1333 _equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt *a, const AlterObjectSchemaStmt *b)
1334 {
1335         COMPARE_SCALAR_FIELD(objectType);
1336         COMPARE_NODE_FIELD(relation);
1337         COMPARE_NODE_FIELD(object);
1338         COMPARE_NODE_FIELD(objarg);
1339         COMPARE_STRING_FIELD(newschema);
1340         COMPARE_SCALAR_FIELD(missing_ok);
1341
1342         return true;
1343 }
1344
1345 static bool
1346 _equalAlterOwnerStmt(const AlterOwnerStmt *a, const AlterOwnerStmt *b)
1347 {
1348         COMPARE_SCALAR_FIELD(objectType);
1349         COMPARE_NODE_FIELD(relation);
1350         COMPARE_NODE_FIELD(object);
1351         COMPARE_NODE_FIELD(objarg);
1352         COMPARE_STRING_FIELD(newowner);
1353
1354         return true;
1355 }
1356
1357 static bool
1358 _equalRuleStmt(const RuleStmt *a, const RuleStmt *b)
1359 {
1360         COMPARE_NODE_FIELD(relation);
1361         COMPARE_STRING_FIELD(rulename);
1362         COMPARE_NODE_FIELD(whereClause);
1363         COMPARE_SCALAR_FIELD(event);
1364         COMPARE_SCALAR_FIELD(instead);
1365         COMPARE_NODE_FIELD(actions);
1366         COMPARE_SCALAR_FIELD(replace);
1367
1368         return true;
1369 }
1370
1371 static bool
1372 _equalNotifyStmt(const NotifyStmt *a, const NotifyStmt *b)
1373 {
1374         COMPARE_STRING_FIELD(conditionname);
1375         COMPARE_STRING_FIELD(payload);
1376
1377         return true;
1378 }
1379
1380 static bool
1381 _equalListenStmt(const ListenStmt *a, const ListenStmt *b)
1382 {
1383         COMPARE_STRING_FIELD(conditionname);
1384
1385         return true;
1386 }
1387
1388 static bool
1389 _equalUnlistenStmt(const UnlistenStmt *a, const UnlistenStmt *b)
1390 {
1391         COMPARE_STRING_FIELD(conditionname);
1392
1393         return true;
1394 }
1395
1396 static bool
1397 _equalTransactionStmt(const TransactionStmt *a, const TransactionStmt *b)
1398 {
1399         COMPARE_SCALAR_FIELD(kind);
1400         COMPARE_NODE_FIELD(options);
1401         COMPARE_STRING_FIELD(gid);
1402
1403         return true;
1404 }
1405
1406 static bool
1407 _equalCompositeTypeStmt(const CompositeTypeStmt *a, const CompositeTypeStmt *b)
1408 {
1409         COMPARE_NODE_FIELD(typevar);
1410         COMPARE_NODE_FIELD(coldeflist);
1411
1412         return true;
1413 }
1414
1415 static bool
1416 _equalCreateEnumStmt(const CreateEnumStmt *a, const CreateEnumStmt *b)
1417 {
1418         COMPARE_NODE_FIELD(typeName);
1419         COMPARE_NODE_FIELD(vals);
1420
1421         return true;
1422 }
1423
1424 static bool
1425 _equalCreateRangeStmt(const CreateRangeStmt *a, const CreateRangeStmt *b)
1426 {
1427         COMPARE_NODE_FIELD(typeName);
1428         COMPARE_NODE_FIELD(params);
1429
1430         return true;
1431 }
1432
1433 static bool
1434 _equalAlterEnumStmt(const AlterEnumStmt *a, const AlterEnumStmt *b)
1435 {
1436         COMPARE_NODE_FIELD(typeName);
1437         COMPARE_STRING_FIELD(newVal);
1438         COMPARE_STRING_FIELD(newValNeighbor);
1439         COMPARE_SCALAR_FIELD(newValIsAfter);
1440         COMPARE_SCALAR_FIELD(skipIfExists);
1441
1442         return true;
1443 }
1444
1445 static bool
1446 _equalViewStmt(const ViewStmt *a, const ViewStmt *b)
1447 {
1448         COMPARE_NODE_FIELD(view);
1449         COMPARE_NODE_FIELD(aliases);
1450         COMPARE_NODE_FIELD(query);
1451         COMPARE_SCALAR_FIELD(replace);
1452         COMPARE_NODE_FIELD(options);
1453
1454         return true;
1455 }
1456
1457 static bool
1458 _equalLoadStmt(const LoadStmt *a, const LoadStmt *b)
1459 {
1460         COMPARE_STRING_FIELD(filename);
1461
1462         return true;
1463 }
1464
1465 static bool
1466 _equalCreateDomainStmt(const CreateDomainStmt *a, const CreateDomainStmt *b)
1467 {
1468         COMPARE_NODE_FIELD(domainname);
1469         COMPARE_NODE_FIELD(typeName);
1470         COMPARE_NODE_FIELD(collClause);
1471         COMPARE_NODE_FIELD(constraints);
1472
1473         return true;
1474 }
1475
1476 static bool
1477 _equalCreateOpClassStmt(const CreateOpClassStmt *a, const CreateOpClassStmt *b)
1478 {
1479         COMPARE_NODE_FIELD(opclassname);
1480         COMPARE_NODE_FIELD(opfamilyname);
1481         COMPARE_STRING_FIELD(amname);
1482         COMPARE_NODE_FIELD(datatype);
1483         COMPARE_NODE_FIELD(items);
1484         COMPARE_SCALAR_FIELD(isDefault);
1485
1486         return true;
1487 }
1488
1489 static bool
1490 _equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b)
1491 {
1492         COMPARE_SCALAR_FIELD(itemtype);
1493         COMPARE_NODE_FIELD(name);
1494         COMPARE_NODE_FIELD(args);
1495         COMPARE_SCALAR_FIELD(number);
1496         COMPARE_NODE_FIELD(order_family);
1497         COMPARE_NODE_FIELD(class_args);
1498         COMPARE_NODE_FIELD(storedtype);
1499
1500         return true;
1501 }
1502
1503 static bool
1504 _equalCreateOpFamilyStmt(const CreateOpFamilyStmt *a, const CreateOpFamilyStmt *b)
1505 {
1506         COMPARE_NODE_FIELD(opfamilyname);
1507         COMPARE_STRING_FIELD(amname);
1508
1509         return true;
1510 }
1511
1512 static bool
1513 _equalAlterOpFamilyStmt(const AlterOpFamilyStmt *a, const AlterOpFamilyStmt *b)
1514 {
1515         COMPARE_NODE_FIELD(opfamilyname);
1516         COMPARE_STRING_FIELD(amname);
1517         COMPARE_SCALAR_FIELD(isDrop);
1518         COMPARE_NODE_FIELD(items);
1519
1520         return true;
1521 }
1522
1523 static bool
1524 _equalCreatedbStmt(const CreatedbStmt *a, const CreatedbStmt *b)
1525 {
1526         COMPARE_STRING_FIELD(dbname);
1527         COMPARE_NODE_FIELD(options);
1528
1529         return true;
1530 }
1531
1532 static bool
1533 _equalAlterDatabaseStmt(const AlterDatabaseStmt *a, const AlterDatabaseStmt *b)
1534 {
1535         COMPARE_STRING_FIELD(dbname);
1536         COMPARE_NODE_FIELD(options);
1537
1538         return true;
1539 }
1540
1541 static bool
1542 _equalAlterDatabaseSetStmt(const AlterDatabaseSetStmt *a, const AlterDatabaseSetStmt *b)
1543 {
1544         COMPARE_STRING_FIELD(dbname);
1545         COMPARE_NODE_FIELD(setstmt);
1546
1547         return true;
1548 }
1549
1550 static bool
1551 _equalDropdbStmt(const DropdbStmt *a, const DropdbStmt *b)
1552 {
1553         COMPARE_STRING_FIELD(dbname);
1554         COMPARE_SCALAR_FIELD(missing_ok);
1555
1556         return true;
1557 }
1558
1559 static bool
1560 _equalVacuumStmt(const VacuumStmt *a, const VacuumStmt *b)
1561 {
1562         COMPARE_SCALAR_FIELD(options);
1563         COMPARE_SCALAR_FIELD(freeze_min_age);
1564         COMPARE_SCALAR_FIELD(freeze_table_age);
1565         COMPARE_NODE_FIELD(relation);
1566         COMPARE_NODE_FIELD(va_cols);
1567
1568         return true;
1569 }
1570
1571 static bool
1572 _equalExplainStmt(const ExplainStmt *a, const ExplainStmt *b)
1573 {
1574         COMPARE_NODE_FIELD(query);
1575         COMPARE_NODE_FIELD(options);
1576
1577         return true;
1578 }
1579
1580 static bool
1581 _equalCreateTableAsStmt(const CreateTableAsStmt *a, const CreateTableAsStmt *b)
1582 {
1583         COMPARE_NODE_FIELD(query);
1584         COMPARE_NODE_FIELD(into);
1585         COMPARE_SCALAR_FIELD(is_select_into);
1586
1587         return true;
1588 }
1589
1590 static bool
1591 _equalCreateSeqStmt(const CreateSeqStmt *a, const CreateSeqStmt *b)
1592 {
1593         COMPARE_NODE_FIELD(sequence);
1594         COMPARE_NODE_FIELD(options);
1595         COMPARE_SCALAR_FIELD(ownerId);
1596
1597         return true;
1598 }
1599
1600 static bool
1601 _equalAlterSeqStmt(const AlterSeqStmt *a, const AlterSeqStmt *b)
1602 {
1603         COMPARE_NODE_FIELD(sequence);
1604         COMPARE_NODE_FIELD(options);
1605         COMPARE_SCALAR_FIELD(missing_ok);
1606
1607         return true;
1608 }
1609
1610 static bool
1611 _equalVariableSetStmt(const VariableSetStmt *a, const VariableSetStmt *b)
1612 {
1613         COMPARE_SCALAR_FIELD(kind);
1614         COMPARE_STRING_FIELD(name);
1615         COMPARE_NODE_FIELD(args);
1616         COMPARE_SCALAR_FIELD(is_local);
1617
1618         return true;
1619 }
1620
1621 static bool
1622 _equalVariableShowStmt(const VariableShowStmt *a, const VariableShowStmt *b)
1623 {
1624         COMPARE_STRING_FIELD(name);
1625
1626         return true;
1627 }
1628
1629 static bool
1630 _equalDiscardStmt(const DiscardStmt *a, const DiscardStmt *b)
1631 {
1632         COMPARE_SCALAR_FIELD(target);
1633
1634         return true;
1635 }
1636
1637 static bool
1638 _equalCreateTableSpaceStmt(const CreateTableSpaceStmt *a, const CreateTableSpaceStmt *b)
1639 {
1640         COMPARE_STRING_FIELD(tablespacename);
1641         COMPARE_STRING_FIELD(owner);
1642         COMPARE_STRING_FIELD(location);
1643
1644         return true;
1645 }
1646
1647 static bool
1648 _equalDropTableSpaceStmt(const DropTableSpaceStmt *a, const DropTableSpaceStmt *b)
1649 {
1650         COMPARE_STRING_FIELD(tablespacename);
1651         COMPARE_SCALAR_FIELD(missing_ok);
1652
1653         return true;
1654 }
1655
1656 static bool
1657 _equalAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *a,
1658                                                                  const AlterTableSpaceOptionsStmt *b)
1659 {
1660         COMPARE_STRING_FIELD(tablespacename);
1661         COMPARE_NODE_FIELD(options);
1662         COMPARE_SCALAR_FIELD(isReset);
1663
1664         return true;
1665 }
1666
1667 static bool
1668 _equalCreateExtensionStmt(const CreateExtensionStmt *a, const CreateExtensionStmt *b)
1669 {
1670         COMPARE_STRING_FIELD(extname);
1671         COMPARE_SCALAR_FIELD(if_not_exists);
1672         COMPARE_NODE_FIELD(options);
1673
1674         return true;
1675 }
1676
1677 static bool
1678 _equalAlterExtensionStmt(const AlterExtensionStmt *a, const AlterExtensionStmt *b)
1679 {
1680         COMPARE_STRING_FIELD(extname);
1681         COMPARE_NODE_FIELD(options);
1682
1683         return true;
1684 }
1685
1686 static bool
1687 _equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const AlterExtensionContentsStmt *b)
1688 {
1689         COMPARE_STRING_FIELD(extname);
1690         COMPARE_SCALAR_FIELD(action);
1691         COMPARE_SCALAR_FIELD(objtype);
1692         COMPARE_NODE_FIELD(objname);
1693         COMPARE_NODE_FIELD(objargs);
1694
1695         return true;
1696 }
1697
1698 static bool
1699 _equalCreateFdwStmt(const CreateFdwStmt *a, const CreateFdwStmt *b)
1700 {
1701         COMPARE_STRING_FIELD(fdwname);
1702         COMPARE_NODE_FIELD(func_options);
1703         COMPARE_NODE_FIELD(options);
1704
1705         return true;
1706 }
1707
1708 static bool
1709 _equalAlterFdwStmt(const AlterFdwStmt *a, const AlterFdwStmt *b)
1710 {
1711         COMPARE_STRING_FIELD(fdwname);
1712         COMPARE_NODE_FIELD(func_options);
1713         COMPARE_NODE_FIELD(options);
1714
1715         return true;
1716 }
1717
1718 static bool
1719 _equalCreateForeignServerStmt(const CreateForeignServerStmt *a, const CreateForeignServerStmt *b)
1720 {
1721         COMPARE_STRING_FIELD(servername);
1722         COMPARE_STRING_FIELD(servertype);
1723         COMPARE_STRING_FIELD(version);
1724         COMPARE_STRING_FIELD(fdwname);
1725         COMPARE_NODE_FIELD(options);
1726
1727         return true;
1728 }
1729
1730 static bool
1731 _equalAlterForeignServerStmt(const AlterForeignServerStmt *a, const AlterForeignServerStmt *b)
1732 {
1733         COMPARE_STRING_FIELD(servername);
1734         COMPARE_STRING_FIELD(version);
1735         COMPARE_NODE_FIELD(options);
1736         COMPARE_SCALAR_FIELD(has_version);
1737
1738         return true;
1739 }
1740
1741 static bool
1742 _equalCreateUserMappingStmt(const CreateUserMappingStmt *a, const CreateUserMappingStmt *b)
1743 {
1744         COMPARE_STRING_FIELD(username);
1745         COMPARE_STRING_FIELD(servername);
1746         COMPARE_NODE_FIELD(options);
1747
1748         return true;
1749 }
1750
1751 static bool
1752 _equalAlterUserMappingStmt(const AlterUserMappingStmt *a, const AlterUserMappingStmt *b)
1753 {
1754         COMPARE_STRING_FIELD(username);
1755         COMPARE_STRING_FIELD(servername);
1756         COMPARE_NODE_FIELD(options);
1757
1758         return true;
1759 }
1760
1761 static bool
1762 _equalDropUserMappingStmt(const DropUserMappingStmt *a, const DropUserMappingStmt *b)
1763 {
1764         COMPARE_STRING_FIELD(username);
1765         COMPARE_STRING_FIELD(servername);
1766         COMPARE_SCALAR_FIELD(missing_ok);
1767
1768         return true;
1769 }
1770
1771 static bool
1772 _equalCreateForeignTableStmt(const CreateForeignTableStmt *a, const CreateForeignTableStmt *b)
1773 {
1774         if (!_equalCreateStmt(&a->base, &b->base))
1775                 return false;
1776
1777         COMPARE_STRING_FIELD(servername);
1778         COMPARE_NODE_FIELD(options);
1779
1780         return true;
1781 }
1782
1783 static bool
1784 _equalCreateTrigStmt(const CreateTrigStmt *a, const CreateTrigStmt *b)
1785 {
1786         COMPARE_STRING_FIELD(trigname);
1787         COMPARE_NODE_FIELD(relation);
1788         COMPARE_NODE_FIELD(funcname);
1789         COMPARE_NODE_FIELD(args);
1790         COMPARE_SCALAR_FIELD(row);
1791         COMPARE_SCALAR_FIELD(timing);
1792         COMPARE_SCALAR_FIELD(events);
1793         COMPARE_NODE_FIELD(columns);
1794         COMPARE_NODE_FIELD(whenClause);
1795         COMPARE_SCALAR_FIELD(isconstraint);
1796         COMPARE_SCALAR_FIELD(deferrable);
1797         COMPARE_SCALAR_FIELD(initdeferred);
1798         COMPARE_NODE_FIELD(constrrel);
1799
1800         return true;
1801 }
1802
1803 static bool
1804 _equalCreateEventTrigStmt(const CreateEventTrigStmt *a, const CreateEventTrigStmt *b)
1805 {
1806         COMPARE_STRING_FIELD(trigname);
1807         COMPARE_SCALAR_FIELD(eventname);
1808         COMPARE_NODE_FIELD(funcname);
1809         COMPARE_NODE_FIELD(whenclause);
1810
1811         return true;
1812 }
1813
1814 static bool
1815 _equalAlterEventTrigStmt(const AlterEventTrigStmt *a, const AlterEventTrigStmt *b)
1816 {
1817         COMPARE_STRING_FIELD(trigname);
1818         COMPARE_SCALAR_FIELD(tgenabled);
1819
1820         return true;
1821 }
1822
1823 static bool
1824 _equalCreatePLangStmt(const CreatePLangStmt *a, const CreatePLangStmt *b)
1825 {
1826         COMPARE_SCALAR_FIELD(replace);
1827         COMPARE_STRING_FIELD(plname);
1828         COMPARE_NODE_FIELD(plhandler);
1829         COMPARE_NODE_FIELD(plinline);
1830         COMPARE_NODE_FIELD(plvalidator);
1831         COMPARE_SCALAR_FIELD(pltrusted);
1832
1833         return true;
1834 }
1835
1836 static bool
1837 _equalCreateRoleStmt(const CreateRoleStmt *a, const CreateRoleStmt *b)
1838 {
1839         COMPARE_SCALAR_FIELD(stmt_type);
1840         COMPARE_STRING_FIELD(role);
1841         COMPARE_NODE_FIELD(options);
1842
1843         return true;
1844 }
1845
1846 static bool
1847 _equalAlterRoleStmt(const AlterRoleStmt *a, const AlterRoleStmt *b)
1848 {
1849         COMPARE_STRING_FIELD(role);
1850         COMPARE_NODE_FIELD(options);
1851         COMPARE_SCALAR_FIELD(action);
1852
1853         return true;
1854 }
1855
1856 static bool
1857 _equalAlterRoleSetStmt(const AlterRoleSetStmt *a, const AlterRoleSetStmt *b)
1858 {
1859         COMPARE_STRING_FIELD(role);
1860         COMPARE_STRING_FIELD(database);
1861         COMPARE_NODE_FIELD(setstmt);
1862
1863         return true;
1864 }
1865
1866 static bool
1867 _equalDropRoleStmt(const DropRoleStmt *a, const DropRoleStmt *b)
1868 {
1869         COMPARE_NODE_FIELD(roles);
1870         COMPARE_SCALAR_FIELD(missing_ok);
1871
1872         return true;
1873 }
1874
1875 static bool
1876 _equalLockStmt(const LockStmt *a, const LockStmt *b)
1877 {
1878         COMPARE_NODE_FIELD(relations);
1879         COMPARE_SCALAR_FIELD(mode);
1880         COMPARE_SCALAR_FIELD(nowait);
1881
1882         return true;
1883 }
1884
1885 static bool
1886 _equalConstraintsSetStmt(const ConstraintsSetStmt *a, const ConstraintsSetStmt *b)
1887 {
1888         COMPARE_NODE_FIELD(constraints);
1889         COMPARE_SCALAR_FIELD(deferred);
1890
1891         return true;
1892 }
1893
1894 static bool
1895 _equalReindexStmt(const ReindexStmt *a, const ReindexStmt *b)
1896 {
1897         COMPARE_SCALAR_FIELD(kind);
1898         COMPARE_NODE_FIELD(relation);
1899         COMPARE_STRING_FIELD(name);
1900         COMPARE_SCALAR_FIELD(do_system);
1901         COMPARE_SCALAR_FIELD(do_user);
1902
1903         return true;
1904 }
1905
1906 static bool
1907 _equalCreateSchemaStmt(const CreateSchemaStmt *a, const CreateSchemaStmt *b)
1908 {
1909         COMPARE_STRING_FIELD(schemaname);
1910         COMPARE_STRING_FIELD(authid);
1911         COMPARE_NODE_FIELD(schemaElts);
1912         COMPARE_SCALAR_FIELD(if_not_exists);
1913
1914         return true;
1915 }
1916
1917 static bool
1918 _equalCreateConversionStmt(const CreateConversionStmt *a, const CreateConversionStmt *b)
1919 {
1920         COMPARE_NODE_FIELD(conversion_name);
1921         COMPARE_STRING_FIELD(for_encoding_name);
1922         COMPARE_STRING_FIELD(to_encoding_name);
1923         COMPARE_NODE_FIELD(func_name);
1924         COMPARE_SCALAR_FIELD(def);
1925
1926         return true;
1927 }
1928
1929 static bool
1930 _equalCreateCastStmt(const CreateCastStmt *a, const CreateCastStmt *b)
1931 {
1932         COMPARE_NODE_FIELD(sourcetype);
1933         COMPARE_NODE_FIELD(targettype);
1934         COMPARE_NODE_FIELD(func);
1935         COMPARE_SCALAR_FIELD(context);
1936         COMPARE_SCALAR_FIELD(inout);
1937
1938         return true;
1939 }
1940
1941 static bool
1942 _equalPrepareStmt(const PrepareStmt *a, const PrepareStmt *b)
1943 {
1944         COMPARE_STRING_FIELD(name);
1945         COMPARE_NODE_FIELD(argtypes);
1946         COMPARE_NODE_FIELD(query);
1947
1948         return true;
1949 }
1950
1951 static bool
1952 _equalExecuteStmt(const ExecuteStmt *a, const ExecuteStmt *b)
1953 {
1954         COMPARE_STRING_FIELD(name);
1955         COMPARE_NODE_FIELD(params);
1956
1957         return true;
1958 }
1959
1960 static bool
1961 _equalDeallocateStmt(const DeallocateStmt *a, const DeallocateStmt *b)
1962 {
1963         COMPARE_STRING_FIELD(name);
1964
1965         return true;
1966 }
1967
1968 static bool
1969 _equalDropOwnedStmt(const DropOwnedStmt *a, const DropOwnedStmt *b)
1970 {
1971         COMPARE_NODE_FIELD(roles);
1972         COMPARE_SCALAR_FIELD(behavior);
1973
1974         return true;
1975 }
1976
1977 static bool
1978 _equalReassignOwnedStmt(const ReassignOwnedStmt *a, const ReassignOwnedStmt *b)
1979 {
1980         COMPARE_NODE_FIELD(roles);
1981         COMPARE_STRING_FIELD(newrole);
1982
1983         return true;
1984 }
1985
1986 static bool
1987 _equalAlterTSDictionaryStmt(const AlterTSDictionaryStmt *a, const AlterTSDictionaryStmt *b)
1988 {
1989         COMPARE_NODE_FIELD(dictname);
1990         COMPARE_NODE_FIELD(options);
1991
1992         return true;
1993 }
1994
1995 static bool
1996 _equalAlterTSConfigurationStmt(const AlterTSConfigurationStmt *a,
1997                                                            const AlterTSConfigurationStmt *b)
1998 {
1999         COMPARE_NODE_FIELD(cfgname);
2000         COMPARE_NODE_FIELD(tokentype);
2001         COMPARE_NODE_FIELD(dicts);
2002         COMPARE_SCALAR_FIELD(override);
2003         COMPARE_SCALAR_FIELD(replace);
2004         COMPARE_SCALAR_FIELD(missing_ok);
2005
2006         return true;
2007 }
2008
2009 static bool
2010 _equalAExpr(const A_Expr *a, const A_Expr *b)
2011 {
2012         COMPARE_SCALAR_FIELD(kind);
2013         COMPARE_NODE_FIELD(name);
2014         COMPARE_NODE_FIELD(lexpr);
2015         COMPARE_NODE_FIELD(rexpr);
2016         COMPARE_LOCATION_FIELD(location);
2017
2018         return true;
2019 }
2020
2021 static bool
2022 _equalColumnRef(const ColumnRef *a, const ColumnRef *b)
2023 {
2024         COMPARE_NODE_FIELD(fields);
2025         COMPARE_LOCATION_FIELD(location);
2026
2027         return true;
2028 }
2029
2030 static bool
2031 _equalParamRef(const ParamRef *a, const ParamRef *b)
2032 {
2033         COMPARE_SCALAR_FIELD(number);
2034         COMPARE_LOCATION_FIELD(location);
2035
2036         return true;
2037 }
2038
2039 static bool
2040 _equalAConst(const A_Const *a, const A_Const *b)
2041 {
2042         if (!equal(&a->val, &b->val))           /* hack for in-line Value field */
2043                 return false;
2044         COMPARE_LOCATION_FIELD(location);
2045
2046         return true;
2047 }
2048
2049 static bool
2050 _equalFuncCall(const FuncCall *a, const FuncCall *b)
2051 {
2052         COMPARE_NODE_FIELD(funcname);
2053         COMPARE_NODE_FIELD(args);
2054         COMPARE_NODE_FIELD(agg_order);
2055         COMPARE_SCALAR_FIELD(agg_star);
2056         COMPARE_SCALAR_FIELD(agg_distinct);
2057         COMPARE_SCALAR_FIELD(func_variadic);
2058         COMPARE_NODE_FIELD(over);
2059         COMPARE_LOCATION_FIELD(location);
2060
2061         return true;
2062 }
2063
2064 static bool
2065 _equalAStar(const A_Star *a, const A_Star *b)
2066 {
2067         return true;
2068 }
2069
2070 static bool
2071 _equalAIndices(const A_Indices *a, const A_Indices *b)
2072 {
2073         COMPARE_NODE_FIELD(lidx);
2074         COMPARE_NODE_FIELD(uidx);
2075
2076         return true;
2077 }
2078
2079 static bool
2080 _equalA_Indirection(const A_Indirection *a, const A_Indirection *b)
2081 {
2082         COMPARE_NODE_FIELD(arg);
2083         COMPARE_NODE_FIELD(indirection);
2084
2085         return true;
2086 }
2087
2088 static bool
2089 _equalA_ArrayExpr(const A_ArrayExpr *a, const A_ArrayExpr *b)
2090 {
2091         COMPARE_NODE_FIELD(elements);
2092         COMPARE_LOCATION_FIELD(location);
2093
2094         return true;
2095 }
2096
2097 static bool
2098 _equalResTarget(const ResTarget *a, const ResTarget *b)
2099 {
2100         COMPARE_STRING_FIELD(name);
2101         COMPARE_NODE_FIELD(indirection);
2102         COMPARE_NODE_FIELD(val);
2103         COMPARE_LOCATION_FIELD(location);
2104
2105         return true;
2106 }
2107
2108 static bool
2109 _equalTypeName(const TypeName *a, const TypeName *b)
2110 {
2111         COMPARE_NODE_FIELD(names);
2112         COMPARE_SCALAR_FIELD(typeOid);
2113         COMPARE_SCALAR_FIELD(setof);
2114         COMPARE_SCALAR_FIELD(pct_type);
2115         COMPARE_NODE_FIELD(typmods);
2116         COMPARE_SCALAR_FIELD(typemod);
2117         COMPARE_NODE_FIELD(arrayBounds);
2118         COMPARE_LOCATION_FIELD(location);
2119
2120         return true;
2121 }
2122
2123 static bool
2124 _equalTypeCast(const TypeCast *a, const TypeCast *b)
2125 {
2126         COMPARE_NODE_FIELD(arg);
2127         COMPARE_NODE_FIELD(typeName);
2128         COMPARE_LOCATION_FIELD(location);
2129
2130         return true;
2131 }
2132
2133 static bool
2134 _equalCollateClause(const CollateClause *a, const CollateClause *b)
2135 {
2136         COMPARE_NODE_FIELD(arg);
2137         COMPARE_NODE_FIELD(collname);
2138         COMPARE_LOCATION_FIELD(location);
2139
2140         return true;
2141 }
2142
2143 static bool
2144 _equalSortBy(const SortBy *a, const SortBy *b)
2145 {
2146         COMPARE_NODE_FIELD(node);
2147         COMPARE_SCALAR_FIELD(sortby_dir);
2148         COMPARE_SCALAR_FIELD(sortby_nulls);
2149         COMPARE_NODE_FIELD(useOp);
2150         COMPARE_LOCATION_FIELD(location);
2151
2152         return true;
2153 }
2154
2155 static bool
2156 _equalWindowDef(const WindowDef *a, const WindowDef *b)
2157 {
2158         COMPARE_STRING_FIELD(name);
2159         COMPARE_STRING_FIELD(refname);
2160         COMPARE_NODE_FIELD(partitionClause);
2161         COMPARE_NODE_FIELD(orderClause);
2162         COMPARE_SCALAR_FIELD(frameOptions);
2163         COMPARE_NODE_FIELD(startOffset);
2164         COMPARE_NODE_FIELD(endOffset);
2165         COMPARE_LOCATION_FIELD(location);
2166
2167         return true;
2168 }
2169
2170 static bool
2171 _equalRangeSubselect(const RangeSubselect *a, const RangeSubselect *b)
2172 {
2173         COMPARE_SCALAR_FIELD(lateral);
2174         COMPARE_NODE_FIELD(subquery);
2175         COMPARE_NODE_FIELD(alias);
2176
2177         return true;
2178 }
2179
2180 static bool
2181 _equalRangeFunction(const RangeFunction *a, const RangeFunction *b)
2182 {
2183         COMPARE_SCALAR_FIELD(lateral);
2184         COMPARE_NODE_FIELD(funccallnode);
2185         COMPARE_NODE_FIELD(alias);
2186         COMPARE_NODE_FIELD(coldeflist);
2187
2188         return true;
2189 }
2190
2191 static bool
2192 _equalIndexElem(const IndexElem *a, const IndexElem *b)
2193 {
2194         COMPARE_STRING_FIELD(name);
2195         COMPARE_NODE_FIELD(expr);
2196         COMPARE_STRING_FIELD(indexcolname);
2197         COMPARE_NODE_FIELD(collation);
2198         COMPARE_NODE_FIELD(opclass);
2199         COMPARE_SCALAR_FIELD(ordering);
2200         COMPARE_SCALAR_FIELD(nulls_ordering);
2201
2202         return true;
2203 }
2204
2205 static bool
2206 _equalColumnDef(const ColumnDef *a, const ColumnDef *b)
2207 {
2208         COMPARE_STRING_FIELD(colname);
2209         COMPARE_NODE_FIELD(typeName);
2210         COMPARE_SCALAR_FIELD(inhcount);
2211         COMPARE_SCALAR_FIELD(is_local);
2212         COMPARE_SCALAR_FIELD(is_not_null);
2213         COMPARE_SCALAR_FIELD(is_from_type);
2214         COMPARE_SCALAR_FIELD(storage);
2215         COMPARE_NODE_FIELD(raw_default);
2216         COMPARE_NODE_FIELD(cooked_default);
2217         COMPARE_NODE_FIELD(collClause);
2218         COMPARE_SCALAR_FIELD(collOid);
2219         COMPARE_NODE_FIELD(constraints);
2220         COMPARE_NODE_FIELD(fdwoptions);
2221
2222         return true;
2223 }
2224
2225 static bool
2226 _equalConstraint(const Constraint *a, const Constraint *b)
2227 {
2228         COMPARE_SCALAR_FIELD(contype);
2229         COMPARE_STRING_FIELD(conname);
2230         COMPARE_SCALAR_FIELD(deferrable);
2231         COMPARE_SCALAR_FIELD(initdeferred);
2232         COMPARE_LOCATION_FIELD(location);
2233         COMPARE_SCALAR_FIELD(is_no_inherit);
2234         COMPARE_NODE_FIELD(raw_expr);
2235         COMPARE_STRING_FIELD(cooked_expr);
2236         COMPARE_NODE_FIELD(keys);
2237         COMPARE_NODE_FIELD(exclusions);
2238         COMPARE_NODE_FIELD(options);
2239         COMPARE_STRING_FIELD(indexname);
2240         COMPARE_STRING_FIELD(indexspace);
2241         COMPARE_STRING_FIELD(access_method);
2242         COMPARE_NODE_FIELD(where_clause);
2243         COMPARE_NODE_FIELD(pktable);
2244         COMPARE_NODE_FIELD(fk_attrs);
2245         COMPARE_NODE_FIELD(pk_attrs);
2246         COMPARE_SCALAR_FIELD(fk_matchtype);
2247         COMPARE_SCALAR_FIELD(fk_upd_action);
2248         COMPARE_SCALAR_FIELD(fk_del_action);
2249         COMPARE_NODE_FIELD(old_conpfeqop);
2250         COMPARE_SCALAR_FIELD(skip_validation);
2251         COMPARE_SCALAR_FIELD(initially_valid);
2252
2253         return true;
2254 }
2255
2256 static bool
2257 _equalDefElem(const DefElem *a, const DefElem *b)
2258 {
2259         COMPARE_STRING_FIELD(defnamespace);
2260         COMPARE_STRING_FIELD(defname);
2261         COMPARE_NODE_FIELD(arg);
2262         COMPARE_SCALAR_FIELD(defaction);
2263
2264         return true;
2265 }
2266
2267 static bool
2268 _equalLockingClause(const LockingClause *a, const LockingClause *b)
2269 {
2270         COMPARE_NODE_FIELD(lockedRels);
2271         COMPARE_SCALAR_FIELD(forUpdate);
2272         COMPARE_SCALAR_FIELD(noWait);
2273
2274         return true;
2275 }
2276
2277 static bool
2278 _equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b)
2279 {
2280         COMPARE_SCALAR_FIELD(rtekind);
2281         COMPARE_SCALAR_FIELD(relid);
2282         COMPARE_SCALAR_FIELD(relkind);
2283         COMPARE_NODE_FIELD(subquery);
2284         COMPARE_SCALAR_FIELD(security_barrier);
2285         COMPARE_SCALAR_FIELD(jointype);
2286         COMPARE_NODE_FIELD(joinaliasvars);
2287         COMPARE_NODE_FIELD(funcexpr);
2288         COMPARE_NODE_FIELD(funccoltypes);
2289         COMPARE_NODE_FIELD(funccoltypmods);
2290         COMPARE_NODE_FIELD(funccolcollations);
2291         COMPARE_NODE_FIELD(values_lists);
2292         COMPARE_NODE_FIELD(values_collations);
2293         COMPARE_STRING_FIELD(ctename);
2294         COMPARE_SCALAR_FIELD(ctelevelsup);
2295         COMPARE_SCALAR_FIELD(self_reference);
2296         COMPARE_NODE_FIELD(ctecoltypes);
2297         COMPARE_NODE_FIELD(ctecoltypmods);
2298         COMPARE_NODE_FIELD(ctecolcollations);
2299         COMPARE_NODE_FIELD(alias);
2300         COMPARE_NODE_FIELD(eref);
2301         COMPARE_SCALAR_FIELD(lateral);
2302         COMPARE_SCALAR_FIELD(inh);
2303         COMPARE_SCALAR_FIELD(inFromCl);
2304         COMPARE_SCALAR_FIELD(requiredPerms);
2305         COMPARE_SCALAR_FIELD(checkAsUser);
2306         COMPARE_BITMAPSET_FIELD(selectedCols);
2307         COMPARE_BITMAPSET_FIELD(modifiedCols);
2308
2309         return true;
2310 }
2311
2312 static bool
2313 _equalSortGroupClause(const SortGroupClause *a, const SortGroupClause *b)
2314 {
2315         COMPARE_SCALAR_FIELD(tleSortGroupRef);
2316         COMPARE_SCALAR_FIELD(eqop);
2317         COMPARE_SCALAR_FIELD(sortop);
2318         COMPARE_SCALAR_FIELD(nulls_first);
2319         COMPARE_SCALAR_FIELD(hashable);
2320
2321         return true;
2322 }
2323
2324 static bool
2325 _equalWindowClause(const WindowClause *a, const WindowClause *b)
2326 {
2327         COMPARE_STRING_FIELD(name);
2328         COMPARE_STRING_FIELD(refname);
2329         COMPARE_NODE_FIELD(partitionClause);
2330         COMPARE_NODE_FIELD(orderClause);
2331         COMPARE_SCALAR_FIELD(frameOptions);
2332         COMPARE_NODE_FIELD(startOffset);
2333         COMPARE_NODE_FIELD(endOffset);
2334         COMPARE_SCALAR_FIELD(winref);
2335         COMPARE_SCALAR_FIELD(copiedOrder);
2336
2337         return true;
2338 }
2339
2340 static bool
2341 _equalRowMarkClause(const RowMarkClause *a, const RowMarkClause *b)
2342 {
2343         COMPARE_SCALAR_FIELD(rti);
2344         COMPARE_SCALAR_FIELD(forUpdate);
2345         COMPARE_SCALAR_FIELD(noWait);
2346         COMPARE_SCALAR_FIELD(pushedDown);
2347
2348         return true;
2349 }
2350
2351 static bool
2352 _equalWithClause(const WithClause *a, const WithClause *b)
2353 {
2354         COMPARE_NODE_FIELD(ctes);
2355         COMPARE_SCALAR_FIELD(recursive);
2356         COMPARE_LOCATION_FIELD(location);
2357
2358         return true;
2359 }
2360
2361 static bool
2362 _equalCommonTableExpr(const CommonTableExpr *a, const CommonTableExpr *b)
2363 {
2364         COMPARE_STRING_FIELD(ctename);
2365         COMPARE_NODE_FIELD(aliascolnames);
2366         COMPARE_NODE_FIELD(ctequery);
2367         COMPARE_LOCATION_FIELD(location);
2368         COMPARE_SCALAR_FIELD(cterecursive);
2369         COMPARE_SCALAR_FIELD(cterefcount);
2370         COMPARE_NODE_FIELD(ctecolnames);
2371         COMPARE_NODE_FIELD(ctecoltypes);
2372         COMPARE_NODE_FIELD(ctecoltypmods);
2373         COMPARE_NODE_FIELD(ctecolcollations);
2374
2375         return true;
2376 }
2377
2378 static bool
2379 _equalXmlSerialize(const XmlSerialize *a, const XmlSerialize *b)
2380 {
2381         COMPARE_SCALAR_FIELD(xmloption);
2382         COMPARE_NODE_FIELD(expr);
2383         COMPARE_NODE_FIELD(typeName);
2384         COMPARE_LOCATION_FIELD(location);
2385
2386         return true;
2387 }
2388
2389 /*
2390  * Stuff from pg_list.h
2391  */
2392
2393 static bool
2394 _equalList(const List *a, const List *b)
2395 {
2396         const ListCell *item_a;
2397         const ListCell *item_b;
2398
2399         /*
2400          * Try to reject by simple scalar checks before grovelling through all the
2401          * list elements...
2402          */
2403         COMPARE_SCALAR_FIELD(type);
2404         COMPARE_SCALAR_FIELD(length);
2405
2406         /*
2407          * We place the switch outside the loop for the sake of efficiency; this
2408          * may not be worth doing...
2409          */
2410         switch (a->type)
2411         {
2412                 case T_List:
2413                         forboth(item_a, a, item_b, b)
2414                         {
2415                                 if (!equal(lfirst(item_a), lfirst(item_b)))
2416                                         return false;
2417                         }
2418                         break;
2419                 case T_IntList:
2420                         forboth(item_a, a, item_b, b)
2421                         {
2422                                 if (lfirst_int(item_a) != lfirst_int(item_b))
2423                                         return false;
2424                         }
2425                         break;
2426                 case T_OidList:
2427                         forboth(item_a, a, item_b, b)
2428                         {
2429                                 if (lfirst_oid(item_a) != lfirst_oid(item_b))
2430                                         return false;
2431                         }
2432                         break;
2433                 default:
2434                         elog(ERROR, "unrecognized list node type: %d",
2435                                  (int) a->type);
2436                         return false;           /* keep compiler quiet */
2437         }
2438
2439         /*
2440          * If we got here, we should have run out of elements of both lists
2441          */
2442         Assert(item_a == NULL);
2443         Assert(item_b == NULL);
2444
2445         return true;
2446 }
2447
2448 /*
2449  * Stuff from value.h
2450  */
2451
2452 static bool
2453 _equalValue(const Value *a, const Value *b)
2454 {
2455         COMPARE_SCALAR_FIELD(type);
2456
2457         switch (a->type)
2458         {
2459                 case T_Integer:
2460                         COMPARE_SCALAR_FIELD(val.ival);
2461                         break;
2462                 case T_Float:
2463                 case T_String:
2464                 case T_BitString:
2465                         COMPARE_STRING_FIELD(val.str);
2466                         break;
2467                 case T_Null:
2468                         /* nothing to do */
2469                         break;
2470                 default:
2471                         elog(ERROR, "unrecognized node type: %d", (int) a->type);
2472                         break;
2473         }
2474
2475         return true;
2476 }
2477
2478 /*
2479  * equal
2480  *        returns whether two nodes are equal
2481  */
2482 bool
2483 equal(const void *a, const void *b)
2484 {
2485         bool            retval;
2486
2487         if (a == b)
2488                 return true;
2489
2490         /*
2491          * note that a!=b, so only one of them can be NULL
2492          */
2493         if (a == NULL || b == NULL)
2494                 return false;
2495
2496         /*
2497          * are they the same type of nodes?
2498          */
2499         if (nodeTag(a) != nodeTag(b))
2500                 return false;
2501
2502         switch (nodeTag(a))
2503         {
2504                         /*
2505                          * PRIMITIVE NODES
2506                          */
2507                 case T_Alias:
2508                         retval = _equalAlias(a, b);
2509                         break;
2510                 case T_RangeVar:
2511                         retval = _equalRangeVar(a, b);
2512                         break;
2513                 case T_IntoClause:
2514                         retval = _equalIntoClause(a, b);
2515                         break;
2516                 case T_Var:
2517                         retval = _equalVar(a, b);
2518                         break;
2519                 case T_Const:
2520                         retval = _equalConst(a, b);
2521                         break;
2522                 case T_Param:
2523                         retval = _equalParam(a, b);
2524                         break;
2525                 case T_Aggref:
2526                         retval = _equalAggref(a, b);
2527                         break;
2528                 case T_WindowFunc:
2529                         retval = _equalWindowFunc(a, b);
2530                         break;
2531                 case T_ArrayRef:
2532                         retval = _equalArrayRef(a, b);
2533                         break;
2534                 case T_FuncExpr:
2535                         retval = _equalFuncExpr(a, b);
2536                         break;
2537                 case T_NamedArgExpr:
2538                         retval = _equalNamedArgExpr(a, b);
2539                         break;
2540                 case T_OpExpr:
2541                         retval = _equalOpExpr(a, b);
2542                         break;
2543                 case T_DistinctExpr:
2544                         retval = _equalDistinctExpr(a, b);
2545                         break;
2546                 case T_NullIfExpr:
2547                         retval = _equalNullIfExpr(a, b);
2548                         break;
2549                 case T_ScalarArrayOpExpr:
2550                         retval = _equalScalarArrayOpExpr(a, b);
2551                         break;
2552                 case T_BoolExpr:
2553                         retval = _equalBoolExpr(a, b);
2554                         break;
2555                 case T_SubLink:
2556                         retval = _equalSubLink(a, b);
2557                         break;
2558                 case T_SubPlan:
2559                         retval = _equalSubPlan(a, b);
2560                         break;
2561                 case T_AlternativeSubPlan:
2562                         retval = _equalAlternativeSubPlan(a, b);
2563                         break;
2564                 case T_FieldSelect:
2565                         retval = _equalFieldSelect(a, b);
2566                         break;
2567                 case T_FieldStore:
2568                         retval = _equalFieldStore(a, b);
2569                         break;
2570                 case T_RelabelType:
2571                         retval = _equalRelabelType(a, b);
2572                         break;
2573                 case T_CoerceViaIO:
2574                         retval = _equalCoerceViaIO(a, b);
2575                         break;
2576                 case T_ArrayCoerceExpr:
2577                         retval = _equalArrayCoerceExpr(a, b);
2578                         break;
2579                 case T_ConvertRowtypeExpr:
2580                         retval = _equalConvertRowtypeExpr(a, b);
2581                         break;
2582                 case T_CollateExpr:
2583                         retval = _equalCollateExpr(a, b);
2584                         break;
2585                 case T_CaseExpr:
2586                         retval = _equalCaseExpr(a, b);
2587                         break;
2588                 case T_CaseWhen:
2589                         retval = _equalCaseWhen(a, b);
2590                         break;
2591                 case T_CaseTestExpr:
2592                         retval = _equalCaseTestExpr(a, b);
2593                         break;
2594                 case T_ArrayExpr:
2595                         retval = _equalArrayExpr(a, b);
2596                         break;
2597                 case T_RowExpr:
2598                         retval = _equalRowExpr(a, b);
2599                         break;
2600                 case T_RowCompareExpr:
2601                         retval = _equalRowCompareExpr(a, b);
2602                         break;
2603                 case T_CoalesceExpr:
2604                         retval = _equalCoalesceExpr(a, b);
2605                         break;
2606                 case T_MinMaxExpr:
2607                         retval = _equalMinMaxExpr(a, b);
2608                         break;
2609                 case T_XmlExpr:
2610                         retval = _equalXmlExpr(a, b);
2611                         break;
2612                 case T_NullTest:
2613                         retval = _equalNullTest(a, b);
2614                         break;
2615                 case T_BooleanTest:
2616                         retval = _equalBooleanTest(a, b);
2617                         break;
2618                 case T_CoerceToDomain:
2619                         retval = _equalCoerceToDomain(a, b);
2620                         break;
2621                 case T_CoerceToDomainValue:
2622                         retval = _equalCoerceToDomainValue(a, b);
2623                         break;
2624                 case T_SetToDefault:
2625                         retval = _equalSetToDefault(a, b);
2626                         break;
2627                 case T_CurrentOfExpr:
2628                         retval = _equalCurrentOfExpr(a, b);
2629                         break;
2630                 case T_TargetEntry:
2631                         retval = _equalTargetEntry(a, b);
2632                         break;
2633                 case T_RangeTblRef:
2634                         retval = _equalRangeTblRef(a, b);
2635                         break;
2636                 case T_FromExpr:
2637                         retval = _equalFromExpr(a, b);
2638                         break;
2639                 case T_JoinExpr:
2640                         retval = _equalJoinExpr(a, b);
2641                         break;
2642
2643                         /*
2644                          * RELATION NODES
2645                          */
2646                 case T_PathKey:
2647                         retval = _equalPathKey(a, b);
2648                         break;
2649                 case T_RestrictInfo:
2650                         retval = _equalRestrictInfo(a, b);
2651                         break;
2652                 case T_PlaceHolderVar:
2653                         retval = _equalPlaceHolderVar(a, b);
2654                         break;
2655                 case T_SpecialJoinInfo:
2656                         retval = _equalSpecialJoinInfo(a, b);
2657                         break;
2658                 case T_LateralJoinInfo:
2659                         retval = _equalLateralJoinInfo(a, b);
2660                         break;
2661                 case T_AppendRelInfo:
2662                         retval = _equalAppendRelInfo(a, b);
2663                         break;
2664                 case T_PlaceHolderInfo:
2665                         retval = _equalPlaceHolderInfo(a, b);
2666                         break;
2667
2668                 case T_List:
2669                 case T_IntList:
2670                 case T_OidList:
2671                         retval = _equalList(a, b);
2672                         break;
2673
2674                 case T_Integer:
2675                 case T_Float:
2676                 case T_String:
2677                 case T_BitString:
2678                 case T_Null:
2679                         retval = _equalValue(a, b);
2680                         break;
2681
2682                         /*
2683                          * PARSE NODES
2684                          */
2685                 case T_Query:
2686                         retval = _equalQuery(a, b);
2687                         break;
2688                 case T_InsertStmt:
2689                         retval = _equalInsertStmt(a, b);
2690                         break;
2691                 case T_DeleteStmt:
2692                         retval = _equalDeleteStmt(a, b);
2693                         break;
2694                 case T_UpdateStmt:
2695                         retval = _equalUpdateStmt(a, b);
2696                         break;
2697                 case T_SelectStmt:
2698                         retval = _equalSelectStmt(a, b);
2699                         break;
2700                 case T_SetOperationStmt:
2701                         retval = _equalSetOperationStmt(a, b);
2702                         break;
2703                 case T_AlterTableStmt:
2704                         retval = _equalAlterTableStmt(a, b);
2705                         break;
2706                 case T_AlterTableCmd:
2707                         retval = _equalAlterTableCmd(a, b);
2708                         break;
2709                 case T_AlterDomainStmt:
2710                         retval = _equalAlterDomainStmt(a, b);
2711                         break;
2712                 case T_GrantStmt:
2713                         retval = _equalGrantStmt(a, b);
2714                         break;
2715                 case T_GrantRoleStmt:
2716                         retval = _equalGrantRoleStmt(a, b);
2717                         break;
2718                 case T_AlterDefaultPrivilegesStmt:
2719                         retval = _equalAlterDefaultPrivilegesStmt(a, b);
2720                         break;
2721                 case T_DeclareCursorStmt:
2722                         retval = _equalDeclareCursorStmt(a, b);
2723                         break;
2724                 case T_ClosePortalStmt:
2725                         retval = _equalClosePortalStmt(a, b);
2726                         break;
2727                 case T_ClusterStmt:
2728                         retval = _equalClusterStmt(a, b);
2729                         break;
2730                 case T_CopyStmt:
2731                         retval = _equalCopyStmt(a, b);
2732                         break;
2733                 case T_CreateStmt:
2734                         retval = _equalCreateStmt(a, b);
2735                         break;
2736                 case T_TableLikeClause:
2737                         retval = _equalTableLikeClause(a, b);
2738                         break;
2739                 case T_DefineStmt:
2740                         retval = _equalDefineStmt(a, b);
2741                         break;
2742                 case T_DropStmt:
2743                         retval = _equalDropStmt(a, b);
2744                         break;
2745                 case T_TruncateStmt:
2746                         retval = _equalTruncateStmt(a, b);
2747                         break;
2748                 case T_CommentStmt:
2749                         retval = _equalCommentStmt(a, b);
2750                         break;
2751                 case T_SecLabelStmt:
2752                         retval = _equalSecLabelStmt(a, b);
2753                         break;
2754                 case T_FetchStmt:
2755                         retval = _equalFetchStmt(a, b);
2756                         break;
2757                 case T_IndexStmt:
2758                         retval = _equalIndexStmt(a, b);
2759                         break;
2760                 case T_CreateFunctionStmt:
2761                         retval = _equalCreateFunctionStmt(a, b);
2762                         break;
2763                 case T_FunctionParameter:
2764                         retval = _equalFunctionParameter(a, b);
2765                         break;
2766                 case T_AlterFunctionStmt:
2767                         retval = _equalAlterFunctionStmt(a, b);
2768                         break;
2769                 case T_DoStmt:
2770                         retval = _equalDoStmt(a, b);
2771                         break;
2772                 case T_RenameStmt:
2773                         retval = _equalRenameStmt(a, b);
2774                         break;
2775                 case T_AlterObjectSchemaStmt:
2776                         retval = _equalAlterObjectSchemaStmt(a, b);
2777                         break;
2778                 case T_AlterOwnerStmt:
2779                         retval = _equalAlterOwnerStmt(a, b);
2780                         break;
2781                 case T_RuleStmt:
2782                         retval = _equalRuleStmt(a, b);
2783                         break;
2784                 case T_NotifyStmt:
2785                         retval = _equalNotifyStmt(a, b);
2786                         break;
2787                 case T_ListenStmt:
2788                         retval = _equalListenStmt(a, b);
2789                         break;
2790                 case T_UnlistenStmt:
2791                         retval = _equalUnlistenStmt(a, b);
2792                         break;
2793                 case T_TransactionStmt:
2794                         retval = _equalTransactionStmt(a, b);
2795                         break;
2796                 case T_CompositeTypeStmt:
2797                         retval = _equalCompositeTypeStmt(a, b);
2798                         break;
2799                 case T_CreateEnumStmt:
2800                         retval = _equalCreateEnumStmt(a, b);
2801                         break;
2802                 case T_CreateRangeStmt:
2803                         retval = _equalCreateRangeStmt(a, b);
2804                         break;
2805                 case T_AlterEnumStmt:
2806                         retval = _equalAlterEnumStmt(a, b);
2807                         break;
2808                 case T_ViewStmt:
2809                         retval = _equalViewStmt(a, b);
2810                         break;
2811                 case T_LoadStmt:
2812                         retval = _equalLoadStmt(a, b);
2813                         break;
2814                 case T_CreateDomainStmt:
2815                         retval = _equalCreateDomainStmt(a, b);
2816                         break;
2817                 case T_CreateOpClassStmt:
2818                         retval = _equalCreateOpClassStmt(a, b);
2819                         break;
2820                 case T_CreateOpClassItem:
2821                         retval = _equalCreateOpClassItem(a, b);
2822                         break;
2823                 case T_CreateOpFamilyStmt:
2824                         retval = _equalCreateOpFamilyStmt(a, b);
2825                         break;
2826                 case T_AlterOpFamilyStmt:
2827                         retval = _equalAlterOpFamilyStmt(a, b);
2828                         break;
2829                 case T_CreatedbStmt:
2830                         retval = _equalCreatedbStmt(a, b);
2831                         break;
2832                 case T_AlterDatabaseStmt:
2833                         retval = _equalAlterDatabaseStmt(a, b);
2834                         break;
2835                 case T_AlterDatabaseSetStmt:
2836                         retval = _equalAlterDatabaseSetStmt(a, b);
2837                         break;
2838                 case T_DropdbStmt:
2839                         retval = _equalDropdbStmt(a, b);
2840                         break;
2841                 case T_VacuumStmt:
2842                         retval = _equalVacuumStmt(a, b);
2843                         break;
2844                 case T_ExplainStmt:
2845                         retval = _equalExplainStmt(a, b);
2846                         break;
2847                 case T_CreateTableAsStmt:
2848                         retval = _equalCreateTableAsStmt(a, b);
2849                         break;
2850                 case T_CreateSeqStmt:
2851                         retval = _equalCreateSeqStmt(a, b);
2852                         break;
2853                 case T_AlterSeqStmt:
2854                         retval = _equalAlterSeqStmt(a, b);
2855                         break;
2856                 case T_VariableSetStmt:
2857                         retval = _equalVariableSetStmt(a, b);
2858                         break;
2859                 case T_VariableShowStmt:
2860                         retval = _equalVariableShowStmt(a, b);
2861                         break;
2862                 case T_DiscardStmt:
2863                         retval = _equalDiscardStmt(a, b);
2864                         break;
2865                 case T_CreateTableSpaceStmt:
2866                         retval = _equalCreateTableSpaceStmt(a, b);
2867                         break;
2868                 case T_DropTableSpaceStmt:
2869                         retval = _equalDropTableSpaceStmt(a, b);
2870                         break;
2871                 case T_AlterTableSpaceOptionsStmt:
2872                         retval = _equalAlterTableSpaceOptionsStmt(a, b);
2873                         break;
2874                 case T_CreateExtensionStmt:
2875                         retval = _equalCreateExtensionStmt(a, b);
2876                         break;
2877                 case T_AlterExtensionStmt:
2878                         retval = _equalAlterExtensionStmt(a, b);
2879                         break;
2880                 case T_AlterExtensionContentsStmt:
2881                         retval = _equalAlterExtensionContentsStmt(a, b);
2882                         break;
2883                 case T_CreateFdwStmt:
2884                         retval = _equalCreateFdwStmt(a, b);
2885                         break;
2886                 case T_AlterFdwStmt:
2887                         retval = _equalAlterFdwStmt(a, b);
2888                         break;
2889                 case T_CreateForeignServerStmt:
2890                         retval = _equalCreateForeignServerStmt(a, b);
2891                         break;
2892                 case T_AlterForeignServerStmt:
2893                         retval = _equalAlterForeignServerStmt(a, b);
2894                         break;
2895                 case T_CreateUserMappingStmt:
2896                         retval = _equalCreateUserMappingStmt(a, b);
2897                         break;
2898                 case T_AlterUserMappingStmt:
2899                         retval = _equalAlterUserMappingStmt(a, b);
2900                         break;
2901                 case T_DropUserMappingStmt:
2902                         retval = _equalDropUserMappingStmt(a, b);
2903                         break;
2904                 case T_CreateForeignTableStmt:
2905                         retval = _equalCreateForeignTableStmt(a, b);
2906                         break;
2907                 case T_CreateTrigStmt:
2908                         retval = _equalCreateTrigStmt(a, b);
2909                         break;
2910                 case T_CreateEventTrigStmt:
2911                         retval = _equalCreateEventTrigStmt(a, b);
2912                         break;
2913                 case T_AlterEventTrigStmt:
2914                         retval = _equalAlterEventTrigStmt(a, b);
2915                         break;
2916                 case T_CreatePLangStmt:
2917                         retval = _equalCreatePLangStmt(a, b);
2918                         break;
2919                 case T_CreateRoleStmt:
2920                         retval = _equalCreateRoleStmt(a, b);
2921                         break;
2922                 case T_AlterRoleStmt:
2923                         retval = _equalAlterRoleStmt(a, b);
2924                         break;
2925                 case T_AlterRoleSetStmt:
2926                         retval = _equalAlterRoleSetStmt(a, b);
2927                         break;
2928                 case T_DropRoleStmt:
2929                         retval = _equalDropRoleStmt(a, b);
2930                         break;
2931                 case T_LockStmt:
2932                         retval = _equalLockStmt(a, b);
2933                         break;
2934                 case T_ConstraintsSetStmt:
2935                         retval = _equalConstraintsSetStmt(a, b);
2936                         break;
2937                 case T_ReindexStmt:
2938                         retval = _equalReindexStmt(a, b);
2939                         break;
2940                 case T_CheckPointStmt:
2941                         retval = true;
2942                         break;
2943                 case T_CreateSchemaStmt:
2944                         retval = _equalCreateSchemaStmt(a, b);
2945                         break;
2946                 case T_CreateConversionStmt:
2947                         retval = _equalCreateConversionStmt(a, b);
2948                         break;
2949                 case T_CreateCastStmt:
2950                         retval = _equalCreateCastStmt(a, b);
2951                         break;
2952                 case T_PrepareStmt:
2953                         retval = _equalPrepareStmt(a, b);
2954                         break;
2955                 case T_ExecuteStmt:
2956                         retval = _equalExecuteStmt(a, b);
2957                         break;
2958                 case T_DeallocateStmt:
2959                         retval = _equalDeallocateStmt(a, b);
2960                         break;
2961                 case T_DropOwnedStmt:
2962                         retval = _equalDropOwnedStmt(a, b);
2963                         break;
2964                 case T_ReassignOwnedStmt:
2965                         retval = _equalReassignOwnedStmt(a, b);
2966                         break;
2967                 case T_AlterTSDictionaryStmt:
2968                         retval = _equalAlterTSDictionaryStmt(a, b);
2969                         break;
2970                 case T_AlterTSConfigurationStmt:
2971                         retval = _equalAlterTSConfigurationStmt(a, b);
2972                         break;
2973
2974                 case T_A_Expr:
2975                         retval = _equalAExpr(a, b);
2976                         break;
2977                 case T_ColumnRef:
2978                         retval = _equalColumnRef(a, b);
2979                         break;
2980                 case T_ParamRef:
2981                         retval = _equalParamRef(a, b);
2982                         break;
2983                 case T_A_Const:
2984                         retval = _equalAConst(a, b);
2985                         break;
2986                 case T_FuncCall:
2987                         retval = _equalFuncCall(a, b);
2988                         break;
2989                 case T_A_Star:
2990                         retval = _equalAStar(a, b);
2991                         break;
2992                 case T_A_Indices:
2993                         retval = _equalAIndices(a, b);
2994                         break;
2995                 case T_A_Indirection:
2996                         retval = _equalA_Indirection(a, b);
2997                         break;
2998                 case T_A_ArrayExpr:
2999                         retval = _equalA_ArrayExpr(a, b);
3000                         break;
3001                 case T_ResTarget:
3002                         retval = _equalResTarget(a, b);
3003                         break;
3004                 case T_TypeCast:
3005                         retval = _equalTypeCast(a, b);
3006                         break;
3007                 case T_CollateClause:
3008                         retval = _equalCollateClause(a, b);
3009                         break;
3010                 case T_SortBy:
3011                         retval = _equalSortBy(a, b);
3012                         break;
3013                 case T_WindowDef:
3014                         retval = _equalWindowDef(a, b);
3015                         break;
3016                 case T_RangeSubselect:
3017                         retval = _equalRangeSubselect(a, b);
3018                         break;
3019                 case T_RangeFunction:
3020                         retval = _equalRangeFunction(a, b);
3021                         break;
3022                 case T_TypeName:
3023                         retval = _equalTypeName(a, b);
3024                         break;
3025                 case T_IndexElem:
3026                         retval = _equalIndexElem(a, b);
3027                         break;
3028                 case T_ColumnDef:
3029                         retval = _equalColumnDef(a, b);
3030                         break;
3031                 case T_Constraint:
3032                         retval = _equalConstraint(a, b);
3033                         break;
3034                 case T_DefElem:
3035                         retval = _equalDefElem(a, b);
3036                         break;
3037                 case T_LockingClause:
3038                         retval = _equalLockingClause(a, b);
3039                         break;
3040                 case T_RangeTblEntry:
3041                         retval = _equalRangeTblEntry(a, b);
3042                         break;
3043                 case T_SortGroupClause:
3044                         retval = _equalSortGroupClause(a, b);
3045                         break;
3046                 case T_WindowClause:
3047                         retval = _equalWindowClause(a, b);
3048                         break;
3049                 case T_RowMarkClause:
3050                         retval = _equalRowMarkClause(a, b);
3051                         break;
3052                 case T_WithClause:
3053                         retval = _equalWithClause(a, b);
3054                         break;
3055                 case T_CommonTableExpr:
3056                         retval = _equalCommonTableExpr(a, b);
3057                         break;
3058                 case T_PrivGrantee:
3059                         retval = _equalPrivGrantee(a, b);
3060                         break;
3061                 case T_FuncWithArgs:
3062                         retval = _equalFuncWithArgs(a, b);
3063                         break;
3064                 case T_AccessPriv:
3065                         retval = _equalAccessPriv(a, b);
3066                         break;
3067                 case T_XmlSerialize:
3068                         retval = _equalXmlSerialize(a, b);
3069                         break;
3070
3071                 default:
3072                         elog(ERROR, "unrecognized node type: %d",
3073                                  (int) nodeTag(a));
3074                         retval = false;         /* keep compiler quiet */
3075                         break;
3076         }
3077
3078         return retval;
3079 }