]> granicus.if.org Git - postgresql/blob - src/backend/nodes/equalfuncs.c
Recast "ONLY" column CHECK constraints as NO INHERIT
[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 _equalAppendRelInfo(const AppendRelInfo *a, const AppendRelInfo *b)
867 {
868         COMPARE_SCALAR_FIELD(parent_relid);
869         COMPARE_SCALAR_FIELD(child_relid);
870         COMPARE_SCALAR_FIELD(parent_reltype);
871         COMPARE_SCALAR_FIELD(child_reltype);
872         COMPARE_NODE_FIELD(translated_vars);
873         COMPARE_SCALAR_FIELD(parent_reloid);
874
875         return true;
876 }
877
878 static bool
879 _equalPlaceHolderInfo(const PlaceHolderInfo *a, const PlaceHolderInfo *b)
880 {
881         COMPARE_SCALAR_FIELD(phid);
882         COMPARE_NODE_FIELD(ph_var);
883         COMPARE_BITMAPSET_FIELD(ph_eval_at);
884         COMPARE_BITMAPSET_FIELD(ph_needed);
885         COMPARE_BITMAPSET_FIELD(ph_may_need);
886         COMPARE_SCALAR_FIELD(ph_width);
887
888         return true;
889 }
890
891
892 /*
893  * Stuff from parsenodes.h
894  */
895
896 static bool
897 _equalQuery(const Query *a, const Query *b)
898 {
899         COMPARE_SCALAR_FIELD(commandType);
900         COMPARE_SCALAR_FIELD(querySource);
901         /* we intentionally ignore queryId, since it might not be set */
902         COMPARE_SCALAR_FIELD(canSetTag);
903         COMPARE_NODE_FIELD(utilityStmt);
904         COMPARE_SCALAR_FIELD(resultRelation);
905         COMPARE_SCALAR_FIELD(hasAggs);
906         COMPARE_SCALAR_FIELD(hasWindowFuncs);
907         COMPARE_SCALAR_FIELD(hasSubLinks);
908         COMPARE_SCALAR_FIELD(hasDistinctOn);
909         COMPARE_SCALAR_FIELD(hasRecursive);
910         COMPARE_SCALAR_FIELD(hasModifyingCTE);
911         COMPARE_SCALAR_FIELD(hasForUpdate);
912         COMPARE_NODE_FIELD(cteList);
913         COMPARE_NODE_FIELD(rtable);
914         COMPARE_NODE_FIELD(jointree);
915         COMPARE_NODE_FIELD(targetList);
916         COMPARE_NODE_FIELD(returningList);
917         COMPARE_NODE_FIELD(groupClause);
918         COMPARE_NODE_FIELD(havingQual);
919         COMPARE_NODE_FIELD(windowClause);
920         COMPARE_NODE_FIELD(distinctClause);
921         COMPARE_NODE_FIELD(sortClause);
922         COMPARE_NODE_FIELD(limitOffset);
923         COMPARE_NODE_FIELD(limitCount);
924         COMPARE_NODE_FIELD(rowMarks);
925         COMPARE_NODE_FIELD(setOperations);
926         COMPARE_NODE_FIELD(constraintDeps);
927
928         return true;
929 }
930
931 static bool
932 _equalInsertStmt(const InsertStmt *a, const InsertStmt *b)
933 {
934         COMPARE_NODE_FIELD(relation);
935         COMPARE_NODE_FIELD(cols);
936         COMPARE_NODE_FIELD(selectStmt);
937         COMPARE_NODE_FIELD(returningList);
938         COMPARE_NODE_FIELD(withClause);
939
940         return true;
941 }
942
943 static bool
944 _equalDeleteStmt(const DeleteStmt *a, const DeleteStmt *b)
945 {
946         COMPARE_NODE_FIELD(relation);
947         COMPARE_NODE_FIELD(usingClause);
948         COMPARE_NODE_FIELD(whereClause);
949         COMPARE_NODE_FIELD(returningList);
950         COMPARE_NODE_FIELD(withClause);
951
952         return true;
953 }
954
955 static bool
956 _equalUpdateStmt(const UpdateStmt *a, const UpdateStmt *b)
957 {
958         COMPARE_NODE_FIELD(relation);
959         COMPARE_NODE_FIELD(targetList);
960         COMPARE_NODE_FIELD(whereClause);
961         COMPARE_NODE_FIELD(fromClause);
962         COMPARE_NODE_FIELD(returningList);
963         COMPARE_NODE_FIELD(withClause);
964
965         return true;
966 }
967
968 static bool
969 _equalSelectStmt(const SelectStmt *a, const SelectStmt *b)
970 {
971         COMPARE_NODE_FIELD(distinctClause);
972         COMPARE_NODE_FIELD(intoClause);
973         COMPARE_NODE_FIELD(targetList);
974         COMPARE_NODE_FIELD(fromClause);
975         COMPARE_NODE_FIELD(whereClause);
976         COMPARE_NODE_FIELD(groupClause);
977         COMPARE_NODE_FIELD(havingClause);
978         COMPARE_NODE_FIELD(windowClause);
979         COMPARE_NODE_FIELD(withClause);
980         COMPARE_NODE_FIELD(valuesLists);
981         COMPARE_NODE_FIELD(sortClause);
982         COMPARE_NODE_FIELD(limitOffset);
983         COMPARE_NODE_FIELD(limitCount);
984         COMPARE_NODE_FIELD(lockingClause);
985         COMPARE_SCALAR_FIELD(op);
986         COMPARE_SCALAR_FIELD(all);
987         COMPARE_NODE_FIELD(larg);
988         COMPARE_NODE_FIELD(rarg);
989
990         return true;
991 }
992
993 static bool
994 _equalSetOperationStmt(const SetOperationStmt *a, const SetOperationStmt *b)
995 {
996         COMPARE_SCALAR_FIELD(op);
997         COMPARE_SCALAR_FIELD(all);
998         COMPARE_NODE_FIELD(larg);
999         COMPARE_NODE_FIELD(rarg);
1000         COMPARE_NODE_FIELD(colTypes);
1001         COMPARE_NODE_FIELD(colTypmods);
1002         COMPARE_NODE_FIELD(colCollations);
1003         COMPARE_NODE_FIELD(groupClauses);
1004
1005         return true;
1006 }
1007
1008 static bool
1009 _equalAlterTableStmt(const AlterTableStmt *a, const AlterTableStmt *b)
1010 {
1011         COMPARE_NODE_FIELD(relation);
1012         COMPARE_NODE_FIELD(cmds);
1013         COMPARE_SCALAR_FIELD(relkind);
1014         COMPARE_SCALAR_FIELD(missing_ok);
1015
1016         return true;
1017 }
1018
1019 static bool
1020 _equalAlterTableCmd(const AlterTableCmd *a, const AlterTableCmd *b)
1021 {
1022         COMPARE_SCALAR_FIELD(subtype);
1023         COMPARE_STRING_FIELD(name);
1024         COMPARE_NODE_FIELD(def);
1025         COMPARE_SCALAR_FIELD(behavior);
1026         COMPARE_SCALAR_FIELD(missing_ok);
1027
1028         return true;
1029 }
1030
1031 static bool
1032 _equalAlterDomainStmt(const AlterDomainStmt *a, const AlterDomainStmt *b)
1033 {
1034         COMPARE_SCALAR_FIELD(subtype);
1035         COMPARE_NODE_FIELD(typeName);
1036         COMPARE_STRING_FIELD(name);
1037         COMPARE_NODE_FIELD(def);
1038         COMPARE_SCALAR_FIELD(behavior);
1039         COMPARE_SCALAR_FIELD(missing_ok);
1040
1041         return true;
1042 }
1043
1044 static bool
1045 _equalGrantStmt(const GrantStmt *a, const GrantStmt *b)
1046 {
1047         COMPARE_SCALAR_FIELD(is_grant);
1048         COMPARE_SCALAR_FIELD(targtype);
1049         COMPARE_SCALAR_FIELD(objtype);
1050         COMPARE_NODE_FIELD(objects);
1051         COMPARE_NODE_FIELD(privileges);
1052         COMPARE_NODE_FIELD(grantees);
1053         COMPARE_SCALAR_FIELD(grant_option);
1054         COMPARE_SCALAR_FIELD(behavior);
1055
1056         return true;
1057 }
1058
1059 static bool
1060 _equalPrivGrantee(const PrivGrantee *a, const PrivGrantee *b)
1061 {
1062         COMPARE_STRING_FIELD(rolname);
1063
1064         return true;
1065 }
1066
1067 static bool
1068 _equalFuncWithArgs(const FuncWithArgs *a, const FuncWithArgs *b)
1069 {
1070         COMPARE_NODE_FIELD(funcname);
1071         COMPARE_NODE_FIELD(funcargs);
1072
1073         return true;
1074 }
1075
1076 static bool
1077 _equalAccessPriv(const AccessPriv *a, const AccessPriv *b)
1078 {
1079         COMPARE_STRING_FIELD(priv_name);
1080         COMPARE_NODE_FIELD(cols);
1081
1082         return true;
1083 }
1084
1085 static bool
1086 _equalGrantRoleStmt(const GrantRoleStmt *a, const GrantRoleStmt *b)
1087 {
1088         COMPARE_NODE_FIELD(granted_roles);
1089         COMPARE_NODE_FIELD(grantee_roles);
1090         COMPARE_SCALAR_FIELD(is_grant);
1091         COMPARE_SCALAR_FIELD(admin_opt);
1092         COMPARE_STRING_FIELD(grantor);
1093         COMPARE_SCALAR_FIELD(behavior);
1094
1095         return true;
1096 }
1097
1098 static bool
1099 _equalAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *a, const AlterDefaultPrivilegesStmt *b)
1100 {
1101         COMPARE_NODE_FIELD(options);
1102         COMPARE_NODE_FIELD(action);
1103
1104         return true;
1105 }
1106
1107 static bool
1108 _equalDeclareCursorStmt(const DeclareCursorStmt *a, const DeclareCursorStmt *b)
1109 {
1110         COMPARE_STRING_FIELD(portalname);
1111         COMPARE_SCALAR_FIELD(options);
1112         COMPARE_NODE_FIELD(query);
1113
1114         return true;
1115 }
1116
1117 static bool
1118 _equalClosePortalStmt(const ClosePortalStmt *a, const ClosePortalStmt *b)
1119 {
1120         COMPARE_STRING_FIELD(portalname);
1121
1122         return true;
1123 }
1124
1125 static bool
1126 _equalClusterStmt(const ClusterStmt *a, const ClusterStmt *b)
1127 {
1128         COMPARE_NODE_FIELD(relation);
1129         COMPARE_STRING_FIELD(indexname);
1130         COMPARE_SCALAR_FIELD(verbose);
1131
1132         return true;
1133 }
1134
1135 static bool
1136 _equalCopyStmt(const CopyStmt *a, const CopyStmt *b)
1137 {
1138         COMPARE_NODE_FIELD(relation);
1139         COMPARE_NODE_FIELD(query);
1140         COMPARE_NODE_FIELD(attlist);
1141         COMPARE_SCALAR_FIELD(is_from);
1142         COMPARE_STRING_FIELD(filename);
1143         COMPARE_NODE_FIELD(options);
1144
1145         return true;
1146 }
1147
1148 static bool
1149 _equalCreateStmt(const CreateStmt *a, const CreateStmt *b)
1150 {
1151         COMPARE_NODE_FIELD(relation);
1152         COMPARE_NODE_FIELD(tableElts);
1153         COMPARE_NODE_FIELD(inhRelations);
1154         COMPARE_NODE_FIELD(ofTypename);
1155         COMPARE_NODE_FIELD(constraints);
1156         COMPARE_NODE_FIELD(options);
1157         COMPARE_SCALAR_FIELD(oncommit);
1158         COMPARE_STRING_FIELD(tablespacename);
1159         COMPARE_SCALAR_FIELD(if_not_exists);
1160
1161         return true;
1162 }
1163
1164 static bool
1165 _equalTableLikeClause(const TableLikeClause *a, const TableLikeClause *b)
1166 {
1167         COMPARE_NODE_FIELD(relation);
1168         COMPARE_SCALAR_FIELD(options);
1169
1170         return true;
1171 }
1172
1173 static bool
1174 _equalDefineStmt(const DefineStmt *a, const DefineStmt *b)
1175 {
1176         COMPARE_SCALAR_FIELD(kind);
1177         COMPARE_SCALAR_FIELD(oldstyle);
1178         COMPARE_NODE_FIELD(defnames);
1179         COMPARE_NODE_FIELD(args);
1180         COMPARE_NODE_FIELD(definition);
1181
1182         return true;
1183 }
1184
1185 static bool
1186 _equalDropStmt(const DropStmt *a, const DropStmt *b)
1187 {
1188         COMPARE_NODE_FIELD(objects);
1189         COMPARE_NODE_FIELD(arguments);
1190         COMPARE_SCALAR_FIELD(removeType);
1191         COMPARE_SCALAR_FIELD(behavior);
1192         COMPARE_SCALAR_FIELD(missing_ok);
1193         COMPARE_SCALAR_FIELD(concurrent);
1194
1195         return true;
1196 }
1197
1198 static bool
1199 _equalTruncateStmt(const TruncateStmt *a, const TruncateStmt *b)
1200 {
1201         COMPARE_NODE_FIELD(relations);
1202         COMPARE_SCALAR_FIELD(restart_seqs);
1203         COMPARE_SCALAR_FIELD(behavior);
1204
1205         return true;
1206 }
1207
1208 static bool
1209 _equalCommentStmt(const CommentStmt *a, const CommentStmt *b)
1210 {
1211         COMPARE_SCALAR_FIELD(objtype);
1212         COMPARE_NODE_FIELD(objname);
1213         COMPARE_NODE_FIELD(objargs);
1214         COMPARE_STRING_FIELD(comment);
1215
1216         return true;
1217 }
1218
1219 static bool
1220 _equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b)
1221 {
1222         COMPARE_SCALAR_FIELD(objtype);
1223         COMPARE_NODE_FIELD(objname);
1224         COMPARE_NODE_FIELD(objargs);
1225         COMPARE_STRING_FIELD(provider);
1226         COMPARE_STRING_FIELD(label);
1227
1228         return true;
1229 }
1230
1231 static bool
1232 _equalFetchStmt(const FetchStmt *a, const FetchStmt *b)
1233 {
1234         COMPARE_SCALAR_FIELD(direction);
1235         COMPARE_SCALAR_FIELD(howMany);
1236         COMPARE_STRING_FIELD(portalname);
1237         COMPARE_SCALAR_FIELD(ismove);
1238
1239         return true;
1240 }
1241
1242 static bool
1243 _equalIndexStmt(const IndexStmt *a, const IndexStmt *b)
1244 {
1245         COMPARE_STRING_FIELD(idxname);
1246         COMPARE_NODE_FIELD(relation);
1247         COMPARE_STRING_FIELD(accessMethod);
1248         COMPARE_STRING_FIELD(tableSpace);
1249         COMPARE_NODE_FIELD(indexParams);
1250         COMPARE_NODE_FIELD(options);
1251         COMPARE_NODE_FIELD(whereClause);
1252         COMPARE_NODE_FIELD(excludeOpNames);
1253         COMPARE_SCALAR_FIELD(indexOid);
1254         COMPARE_SCALAR_FIELD(oldNode);
1255         COMPARE_SCALAR_FIELD(unique);
1256         COMPARE_SCALAR_FIELD(primary);
1257         COMPARE_SCALAR_FIELD(isconstraint);
1258         COMPARE_SCALAR_FIELD(deferrable);
1259         COMPARE_SCALAR_FIELD(initdeferred);
1260         COMPARE_SCALAR_FIELD(concurrent);
1261
1262         return true;
1263 }
1264
1265 static bool
1266 _equalCreateFunctionStmt(const CreateFunctionStmt *a, const CreateFunctionStmt *b)
1267 {
1268         COMPARE_SCALAR_FIELD(replace);
1269         COMPARE_NODE_FIELD(funcname);
1270         COMPARE_NODE_FIELD(parameters);
1271         COMPARE_NODE_FIELD(returnType);
1272         COMPARE_NODE_FIELD(options);
1273         COMPARE_NODE_FIELD(withClause);
1274
1275         return true;
1276 }
1277
1278 static bool
1279 _equalFunctionParameter(const FunctionParameter *a, const FunctionParameter *b)
1280 {
1281         COMPARE_STRING_FIELD(name);
1282         COMPARE_NODE_FIELD(argType);
1283         COMPARE_SCALAR_FIELD(mode);
1284         COMPARE_NODE_FIELD(defexpr);
1285
1286         return true;
1287 }
1288
1289 static bool
1290 _equalAlterFunctionStmt(const AlterFunctionStmt *a, const AlterFunctionStmt *b)
1291 {
1292         COMPARE_NODE_FIELD(func);
1293         COMPARE_NODE_FIELD(actions);
1294
1295         return true;
1296 }
1297
1298 static bool
1299 _equalDoStmt(const DoStmt *a, const DoStmt *b)
1300 {
1301         COMPARE_NODE_FIELD(args);
1302
1303         return true;
1304 }
1305
1306 static bool
1307 _equalRenameStmt(const RenameStmt *a, const RenameStmt *b)
1308 {
1309         COMPARE_SCALAR_FIELD(renameType);
1310         COMPARE_SCALAR_FIELD(relationType);
1311         COMPARE_NODE_FIELD(relation);
1312         COMPARE_NODE_FIELD(object);
1313         COMPARE_NODE_FIELD(objarg);
1314         COMPARE_STRING_FIELD(subname);
1315         COMPARE_STRING_FIELD(newname);
1316         COMPARE_SCALAR_FIELD(behavior);
1317         COMPARE_SCALAR_FIELD(missing_ok);
1318
1319         return true;
1320 }
1321
1322 static bool
1323 _equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt *a, const AlterObjectSchemaStmt *b)
1324 {
1325         COMPARE_SCALAR_FIELD(objectType);
1326         COMPARE_NODE_FIELD(relation);
1327         COMPARE_NODE_FIELD(object);
1328         COMPARE_NODE_FIELD(objarg);
1329         COMPARE_STRING_FIELD(addname);
1330         COMPARE_STRING_FIELD(newschema);
1331         COMPARE_SCALAR_FIELD(missing_ok);
1332
1333         return true;
1334 }
1335
1336 static bool
1337 _equalAlterOwnerStmt(const AlterOwnerStmt *a, const AlterOwnerStmt *b)
1338 {
1339         COMPARE_SCALAR_FIELD(objectType);
1340         COMPARE_NODE_FIELD(relation);
1341         COMPARE_NODE_FIELD(object);
1342         COMPARE_NODE_FIELD(objarg);
1343         COMPARE_STRING_FIELD(addname);
1344         COMPARE_STRING_FIELD(newowner);
1345
1346         return true;
1347 }
1348
1349 static bool
1350 _equalRuleStmt(const RuleStmt *a, const RuleStmt *b)
1351 {
1352         COMPARE_NODE_FIELD(relation);
1353         COMPARE_STRING_FIELD(rulename);
1354         COMPARE_NODE_FIELD(whereClause);
1355         COMPARE_SCALAR_FIELD(event);
1356         COMPARE_SCALAR_FIELD(instead);
1357         COMPARE_NODE_FIELD(actions);
1358         COMPARE_SCALAR_FIELD(replace);
1359
1360         return true;
1361 }
1362
1363 static bool
1364 _equalNotifyStmt(const NotifyStmt *a, const NotifyStmt *b)
1365 {
1366         COMPARE_STRING_FIELD(conditionname);
1367         COMPARE_STRING_FIELD(payload);
1368
1369         return true;
1370 }
1371
1372 static bool
1373 _equalListenStmt(const ListenStmt *a, const ListenStmt *b)
1374 {
1375         COMPARE_STRING_FIELD(conditionname);
1376
1377         return true;
1378 }
1379
1380 static bool
1381 _equalUnlistenStmt(const UnlistenStmt *a, const UnlistenStmt *b)
1382 {
1383         COMPARE_STRING_FIELD(conditionname);
1384
1385         return true;
1386 }
1387
1388 static bool
1389 _equalTransactionStmt(const TransactionStmt *a, const TransactionStmt *b)
1390 {
1391         COMPARE_SCALAR_FIELD(kind);
1392         COMPARE_NODE_FIELD(options);
1393         COMPARE_STRING_FIELD(gid);
1394
1395         return true;
1396 }
1397
1398 static bool
1399 _equalCompositeTypeStmt(const CompositeTypeStmt *a, const CompositeTypeStmt *b)
1400 {
1401         COMPARE_NODE_FIELD(typevar);
1402         COMPARE_NODE_FIELD(coldeflist);
1403
1404         return true;
1405 }
1406
1407 static bool
1408 _equalCreateEnumStmt(const CreateEnumStmt *a, const CreateEnumStmt *b)
1409 {
1410         COMPARE_NODE_FIELD(typeName);
1411         COMPARE_NODE_FIELD(vals);
1412
1413         return true;
1414 }
1415
1416 static bool
1417 _equalCreateRangeStmt(const CreateRangeStmt *a, const CreateRangeStmt *b)
1418 {
1419         COMPARE_NODE_FIELD(typeName);
1420         COMPARE_NODE_FIELD(params);
1421
1422         return true;
1423 }
1424
1425 static bool
1426 _equalAlterEnumStmt(const AlterEnumStmt *a, const AlterEnumStmt *b)
1427 {
1428         COMPARE_NODE_FIELD(typeName);
1429         COMPARE_STRING_FIELD(newVal);
1430         COMPARE_STRING_FIELD(newValNeighbor);
1431         COMPARE_SCALAR_FIELD(newValIsAfter);
1432
1433         return true;
1434 }
1435
1436 static bool
1437 _equalViewStmt(const ViewStmt *a, const ViewStmt *b)
1438 {
1439         COMPARE_NODE_FIELD(view);
1440         COMPARE_NODE_FIELD(aliases);
1441         COMPARE_NODE_FIELD(query);
1442         COMPARE_SCALAR_FIELD(replace);
1443         COMPARE_NODE_FIELD(options);
1444
1445         return true;
1446 }
1447
1448 static bool
1449 _equalLoadStmt(const LoadStmt *a, const LoadStmt *b)
1450 {
1451         COMPARE_STRING_FIELD(filename);
1452
1453         return true;
1454 }
1455
1456 static bool
1457 _equalCreateDomainStmt(const CreateDomainStmt *a, const CreateDomainStmt *b)
1458 {
1459         COMPARE_NODE_FIELD(domainname);
1460         COMPARE_NODE_FIELD(typeName);
1461         COMPARE_NODE_FIELD(collClause);
1462         COMPARE_NODE_FIELD(constraints);
1463
1464         return true;
1465 }
1466
1467 static bool
1468 _equalCreateOpClassStmt(const CreateOpClassStmt *a, const CreateOpClassStmt *b)
1469 {
1470         COMPARE_NODE_FIELD(opclassname);
1471         COMPARE_NODE_FIELD(opfamilyname);
1472         COMPARE_STRING_FIELD(amname);
1473         COMPARE_NODE_FIELD(datatype);
1474         COMPARE_NODE_FIELD(items);
1475         COMPARE_SCALAR_FIELD(isDefault);
1476
1477         return true;
1478 }
1479
1480 static bool
1481 _equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b)
1482 {
1483         COMPARE_SCALAR_FIELD(itemtype);
1484         COMPARE_NODE_FIELD(name);
1485         COMPARE_NODE_FIELD(args);
1486         COMPARE_SCALAR_FIELD(number);
1487         COMPARE_NODE_FIELD(order_family);
1488         COMPARE_NODE_FIELD(class_args);
1489         COMPARE_NODE_FIELD(storedtype);
1490
1491         return true;
1492 }
1493
1494 static bool
1495 _equalCreateOpFamilyStmt(const CreateOpFamilyStmt *a, const CreateOpFamilyStmt *b)
1496 {
1497         COMPARE_NODE_FIELD(opfamilyname);
1498         COMPARE_STRING_FIELD(amname);
1499
1500         return true;
1501 }
1502
1503 static bool
1504 _equalAlterOpFamilyStmt(const AlterOpFamilyStmt *a, const AlterOpFamilyStmt *b)
1505 {
1506         COMPARE_NODE_FIELD(opfamilyname);
1507         COMPARE_STRING_FIELD(amname);
1508         COMPARE_SCALAR_FIELD(isDrop);
1509         COMPARE_NODE_FIELD(items);
1510
1511         return true;
1512 }
1513
1514 static bool
1515 _equalCreatedbStmt(const CreatedbStmt *a, const CreatedbStmt *b)
1516 {
1517         COMPARE_STRING_FIELD(dbname);
1518         COMPARE_NODE_FIELD(options);
1519
1520         return true;
1521 }
1522
1523 static bool
1524 _equalAlterDatabaseStmt(const AlterDatabaseStmt *a, const AlterDatabaseStmt *b)
1525 {
1526         COMPARE_STRING_FIELD(dbname);
1527         COMPARE_NODE_FIELD(options);
1528
1529         return true;
1530 }
1531
1532 static bool
1533 _equalAlterDatabaseSetStmt(const AlterDatabaseSetStmt *a, const AlterDatabaseSetStmt *b)
1534 {
1535         COMPARE_STRING_FIELD(dbname);
1536         COMPARE_NODE_FIELD(setstmt);
1537
1538         return true;
1539 }
1540
1541 static bool
1542 _equalDropdbStmt(const DropdbStmt *a, const DropdbStmt *b)
1543 {
1544         COMPARE_STRING_FIELD(dbname);
1545         COMPARE_SCALAR_FIELD(missing_ok);
1546
1547         return true;
1548 }
1549
1550 static bool
1551 _equalVacuumStmt(const VacuumStmt *a, const VacuumStmt *b)
1552 {
1553         COMPARE_SCALAR_FIELD(options);
1554         COMPARE_SCALAR_FIELD(freeze_min_age);
1555         COMPARE_SCALAR_FIELD(freeze_table_age);
1556         COMPARE_NODE_FIELD(relation);
1557         COMPARE_NODE_FIELD(va_cols);
1558
1559         return true;
1560 }
1561
1562 static bool
1563 _equalExplainStmt(const ExplainStmt *a, const ExplainStmt *b)
1564 {
1565         COMPARE_NODE_FIELD(query);
1566         COMPARE_NODE_FIELD(options);
1567
1568         return true;
1569 }
1570
1571 static bool
1572 _equalCreateTableAsStmt(const CreateTableAsStmt *a, const CreateTableAsStmt *b)
1573 {
1574         COMPARE_NODE_FIELD(query);
1575         COMPARE_NODE_FIELD(into);
1576         COMPARE_SCALAR_FIELD(is_select_into);
1577
1578         return true;
1579 }
1580
1581 static bool
1582 _equalCreateSeqStmt(const CreateSeqStmt *a, const CreateSeqStmt *b)
1583 {
1584         COMPARE_NODE_FIELD(sequence);
1585         COMPARE_NODE_FIELD(options);
1586         COMPARE_SCALAR_FIELD(ownerId);
1587
1588         return true;
1589 }
1590
1591 static bool
1592 _equalAlterSeqStmt(const AlterSeqStmt *a, const AlterSeqStmt *b)
1593 {
1594         COMPARE_NODE_FIELD(sequence);
1595         COMPARE_NODE_FIELD(options);
1596         COMPARE_SCALAR_FIELD(missing_ok);
1597
1598         return true;
1599 }
1600
1601 static bool
1602 _equalVariableSetStmt(const VariableSetStmt *a, const VariableSetStmt *b)
1603 {
1604         COMPARE_SCALAR_FIELD(kind);
1605         COMPARE_STRING_FIELD(name);
1606         COMPARE_NODE_FIELD(args);
1607         COMPARE_SCALAR_FIELD(is_local);
1608
1609         return true;
1610 }
1611
1612 static bool
1613 _equalVariableShowStmt(const VariableShowStmt *a, const VariableShowStmt *b)
1614 {
1615         COMPARE_STRING_FIELD(name);
1616
1617         return true;
1618 }
1619
1620 static bool
1621 _equalDiscardStmt(const DiscardStmt *a, const DiscardStmt *b)
1622 {
1623         COMPARE_SCALAR_FIELD(target);
1624
1625         return true;
1626 }
1627
1628 static bool
1629 _equalCreateTableSpaceStmt(const CreateTableSpaceStmt *a, const CreateTableSpaceStmt *b)
1630 {
1631         COMPARE_STRING_FIELD(tablespacename);
1632         COMPARE_STRING_FIELD(owner);
1633         COMPARE_STRING_FIELD(location);
1634
1635         return true;
1636 }
1637
1638 static bool
1639 _equalDropTableSpaceStmt(const DropTableSpaceStmt *a, const DropTableSpaceStmt *b)
1640 {
1641         COMPARE_STRING_FIELD(tablespacename);
1642         COMPARE_SCALAR_FIELD(missing_ok);
1643
1644         return true;
1645 }
1646
1647 static bool
1648 _equalAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *a,
1649                                                                  const AlterTableSpaceOptionsStmt *b)
1650 {
1651         COMPARE_STRING_FIELD(tablespacename);
1652         COMPARE_NODE_FIELD(options);
1653         COMPARE_SCALAR_FIELD(isReset);
1654
1655         return true;
1656 }
1657
1658 static bool
1659 _equalCreateExtensionStmt(const CreateExtensionStmt *a, const CreateExtensionStmt *b)
1660 {
1661         COMPARE_STRING_FIELD(extname);
1662         COMPARE_SCALAR_FIELD(if_not_exists);
1663         COMPARE_NODE_FIELD(options);
1664
1665         return true;
1666 }
1667
1668 static bool
1669 _equalAlterExtensionStmt(const AlterExtensionStmt *a, const AlterExtensionStmt *b)
1670 {
1671         COMPARE_STRING_FIELD(extname);
1672         COMPARE_NODE_FIELD(options);
1673
1674         return true;
1675 }
1676
1677 static bool
1678 _equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const AlterExtensionContentsStmt *b)
1679 {
1680         COMPARE_STRING_FIELD(extname);
1681         COMPARE_SCALAR_FIELD(action);
1682         COMPARE_SCALAR_FIELD(objtype);
1683         COMPARE_NODE_FIELD(objname);
1684         COMPARE_NODE_FIELD(objargs);
1685
1686         return true;
1687 }
1688
1689 static bool
1690 _equalCreateFdwStmt(const CreateFdwStmt *a, const CreateFdwStmt *b)
1691 {
1692         COMPARE_STRING_FIELD(fdwname);
1693         COMPARE_NODE_FIELD(func_options);
1694         COMPARE_NODE_FIELD(options);
1695
1696         return true;
1697 }
1698
1699 static bool
1700 _equalAlterFdwStmt(const AlterFdwStmt *a, const AlterFdwStmt *b)
1701 {
1702         COMPARE_STRING_FIELD(fdwname);
1703         COMPARE_NODE_FIELD(func_options);
1704         COMPARE_NODE_FIELD(options);
1705
1706         return true;
1707 }
1708
1709 static bool
1710 _equalCreateForeignServerStmt(const CreateForeignServerStmt *a, const CreateForeignServerStmt *b)
1711 {
1712         COMPARE_STRING_FIELD(servername);
1713         COMPARE_STRING_FIELD(servertype);
1714         COMPARE_STRING_FIELD(version);
1715         COMPARE_STRING_FIELD(fdwname);
1716         COMPARE_NODE_FIELD(options);
1717
1718         return true;
1719 }
1720
1721 static bool
1722 _equalAlterForeignServerStmt(const AlterForeignServerStmt *a, const AlterForeignServerStmt *b)
1723 {
1724         COMPARE_STRING_FIELD(servername);
1725         COMPARE_STRING_FIELD(version);
1726         COMPARE_NODE_FIELD(options);
1727         COMPARE_SCALAR_FIELD(has_version);
1728
1729         return true;
1730 }
1731
1732 static bool
1733 _equalCreateUserMappingStmt(const CreateUserMappingStmt *a, const CreateUserMappingStmt *b)
1734 {
1735         COMPARE_STRING_FIELD(username);
1736         COMPARE_STRING_FIELD(servername);
1737         COMPARE_NODE_FIELD(options);
1738
1739         return true;
1740 }
1741
1742 static bool
1743 _equalAlterUserMappingStmt(const AlterUserMappingStmt *a, const AlterUserMappingStmt *b)
1744 {
1745         COMPARE_STRING_FIELD(username);
1746         COMPARE_STRING_FIELD(servername);
1747         COMPARE_NODE_FIELD(options);
1748
1749         return true;
1750 }
1751
1752 static bool
1753 _equalDropUserMappingStmt(const DropUserMappingStmt *a, const DropUserMappingStmt *b)
1754 {
1755         COMPARE_STRING_FIELD(username);
1756         COMPARE_STRING_FIELD(servername);
1757         COMPARE_SCALAR_FIELD(missing_ok);
1758
1759         return true;
1760 }
1761
1762 static bool
1763 _equalCreateForeignTableStmt(const CreateForeignTableStmt *a, const CreateForeignTableStmt *b)
1764 {
1765         if (!_equalCreateStmt(&a->base, &b->base))
1766                 return false;
1767
1768         COMPARE_STRING_FIELD(servername);
1769         COMPARE_NODE_FIELD(options);
1770
1771         return true;
1772 }
1773
1774 static bool
1775 _equalCreateTrigStmt(const CreateTrigStmt *a, const CreateTrigStmt *b)
1776 {
1777         COMPARE_STRING_FIELD(trigname);
1778         COMPARE_NODE_FIELD(relation);
1779         COMPARE_NODE_FIELD(funcname);
1780         COMPARE_NODE_FIELD(args);
1781         COMPARE_SCALAR_FIELD(row);
1782         COMPARE_SCALAR_FIELD(timing);
1783         COMPARE_SCALAR_FIELD(events);
1784         COMPARE_NODE_FIELD(columns);
1785         COMPARE_NODE_FIELD(whenClause);
1786         COMPARE_SCALAR_FIELD(isconstraint);
1787         COMPARE_SCALAR_FIELD(deferrable);
1788         COMPARE_SCALAR_FIELD(initdeferred);
1789         COMPARE_NODE_FIELD(constrrel);
1790
1791         return true;
1792 }
1793
1794 static bool
1795 _equalCreatePLangStmt(const CreatePLangStmt *a, const CreatePLangStmt *b)
1796 {
1797         COMPARE_SCALAR_FIELD(replace);
1798         COMPARE_STRING_FIELD(plname);
1799         COMPARE_NODE_FIELD(plhandler);
1800         COMPARE_NODE_FIELD(plinline);
1801         COMPARE_NODE_FIELD(plvalidator);
1802         COMPARE_SCALAR_FIELD(pltrusted);
1803
1804         return true;
1805 }
1806
1807 static bool
1808 _equalCreateRoleStmt(const CreateRoleStmt *a, const CreateRoleStmt *b)
1809 {
1810         COMPARE_SCALAR_FIELD(stmt_type);
1811         COMPARE_STRING_FIELD(role);
1812         COMPARE_NODE_FIELD(options);
1813
1814         return true;
1815 }
1816
1817 static bool
1818 _equalAlterRoleStmt(const AlterRoleStmt *a, const AlterRoleStmt *b)
1819 {
1820         COMPARE_STRING_FIELD(role);
1821         COMPARE_NODE_FIELD(options);
1822         COMPARE_SCALAR_FIELD(action);
1823
1824         return true;
1825 }
1826
1827 static bool
1828 _equalAlterRoleSetStmt(const AlterRoleSetStmt *a, const AlterRoleSetStmt *b)
1829 {
1830         COMPARE_STRING_FIELD(role);
1831         COMPARE_STRING_FIELD(database);
1832         COMPARE_NODE_FIELD(setstmt);
1833
1834         return true;
1835 }
1836
1837 static bool
1838 _equalDropRoleStmt(const DropRoleStmt *a, const DropRoleStmt *b)
1839 {
1840         COMPARE_NODE_FIELD(roles);
1841         COMPARE_SCALAR_FIELD(missing_ok);
1842
1843         return true;
1844 }
1845
1846 static bool
1847 _equalLockStmt(const LockStmt *a, const LockStmt *b)
1848 {
1849         COMPARE_NODE_FIELD(relations);
1850         COMPARE_SCALAR_FIELD(mode);
1851         COMPARE_SCALAR_FIELD(nowait);
1852
1853         return true;
1854 }
1855
1856 static bool
1857 _equalConstraintsSetStmt(const ConstraintsSetStmt *a, const ConstraintsSetStmt *b)
1858 {
1859         COMPARE_NODE_FIELD(constraints);
1860         COMPARE_SCALAR_FIELD(deferred);
1861
1862         return true;
1863 }
1864
1865 static bool
1866 _equalReindexStmt(const ReindexStmt *a, const ReindexStmt *b)
1867 {
1868         COMPARE_SCALAR_FIELD(kind);
1869         COMPARE_NODE_FIELD(relation);
1870         COMPARE_STRING_FIELD(name);
1871         COMPARE_SCALAR_FIELD(do_system);
1872         COMPARE_SCALAR_FIELD(do_user);
1873
1874         return true;
1875 }
1876
1877 static bool
1878 _equalCreateSchemaStmt(const CreateSchemaStmt *a, const CreateSchemaStmt *b)
1879 {
1880         COMPARE_STRING_FIELD(schemaname);
1881         COMPARE_STRING_FIELD(authid);
1882         COMPARE_NODE_FIELD(schemaElts);
1883
1884         return true;
1885 }
1886
1887 static bool
1888 _equalCreateConversionStmt(const CreateConversionStmt *a, const CreateConversionStmt *b)
1889 {
1890         COMPARE_NODE_FIELD(conversion_name);
1891         COMPARE_STRING_FIELD(for_encoding_name);
1892         COMPARE_STRING_FIELD(to_encoding_name);
1893         COMPARE_NODE_FIELD(func_name);
1894         COMPARE_SCALAR_FIELD(def);
1895
1896         return true;
1897 }
1898
1899 static bool
1900 _equalCreateCastStmt(const CreateCastStmt *a, const CreateCastStmt *b)
1901 {
1902         COMPARE_NODE_FIELD(sourcetype);
1903         COMPARE_NODE_FIELD(targettype);
1904         COMPARE_NODE_FIELD(func);
1905         COMPARE_SCALAR_FIELD(context);
1906         COMPARE_SCALAR_FIELD(inout);
1907
1908         return true;
1909 }
1910
1911 static bool
1912 _equalPrepareStmt(const PrepareStmt *a, const PrepareStmt *b)
1913 {
1914         COMPARE_STRING_FIELD(name);
1915         COMPARE_NODE_FIELD(argtypes);
1916         COMPARE_NODE_FIELD(query);
1917
1918         return true;
1919 }
1920
1921 static bool
1922 _equalExecuteStmt(const ExecuteStmt *a, const ExecuteStmt *b)
1923 {
1924         COMPARE_STRING_FIELD(name);
1925         COMPARE_NODE_FIELD(params);
1926
1927         return true;
1928 }
1929
1930 static bool
1931 _equalDeallocateStmt(const DeallocateStmt *a, const DeallocateStmt *b)
1932 {
1933         COMPARE_STRING_FIELD(name);
1934
1935         return true;
1936 }
1937
1938 static bool
1939 _equalDropOwnedStmt(const DropOwnedStmt *a, const DropOwnedStmt *b)
1940 {
1941         COMPARE_NODE_FIELD(roles);
1942         COMPARE_SCALAR_FIELD(behavior);
1943
1944         return true;
1945 }
1946
1947 static bool
1948 _equalReassignOwnedStmt(const ReassignOwnedStmt *a, const ReassignOwnedStmt *b)
1949 {
1950         COMPARE_NODE_FIELD(roles);
1951         COMPARE_STRING_FIELD(newrole);
1952
1953         return true;
1954 }
1955
1956 static bool
1957 _equalAlterTSDictionaryStmt(const AlterTSDictionaryStmt *a, const AlterTSDictionaryStmt *b)
1958 {
1959         COMPARE_NODE_FIELD(dictname);
1960         COMPARE_NODE_FIELD(options);
1961
1962         return true;
1963 }
1964
1965 static bool
1966 _equalAlterTSConfigurationStmt(const AlterTSConfigurationStmt *a,
1967                                                            const AlterTSConfigurationStmt *b)
1968 {
1969         COMPARE_NODE_FIELD(cfgname);
1970         COMPARE_NODE_FIELD(tokentype);
1971         COMPARE_NODE_FIELD(dicts);
1972         COMPARE_SCALAR_FIELD(override);
1973         COMPARE_SCALAR_FIELD(replace);
1974         COMPARE_SCALAR_FIELD(missing_ok);
1975
1976         return true;
1977 }
1978
1979 static bool
1980 _equalAExpr(const A_Expr *a, const A_Expr *b)
1981 {
1982         COMPARE_SCALAR_FIELD(kind);
1983         COMPARE_NODE_FIELD(name);
1984         COMPARE_NODE_FIELD(lexpr);
1985         COMPARE_NODE_FIELD(rexpr);
1986         COMPARE_LOCATION_FIELD(location);
1987
1988         return true;
1989 }
1990
1991 static bool
1992 _equalColumnRef(const ColumnRef *a, const ColumnRef *b)
1993 {
1994         COMPARE_NODE_FIELD(fields);
1995         COMPARE_LOCATION_FIELD(location);
1996
1997         return true;
1998 }
1999
2000 static bool
2001 _equalParamRef(const ParamRef *a, const ParamRef *b)
2002 {
2003         COMPARE_SCALAR_FIELD(number);
2004         COMPARE_LOCATION_FIELD(location);
2005
2006         return true;
2007 }
2008
2009 static bool
2010 _equalAConst(const A_Const *a, const A_Const *b)
2011 {
2012         if (!equal(&a->val, &b->val))           /* hack for in-line Value field */
2013                 return false;
2014         COMPARE_LOCATION_FIELD(location);
2015
2016         return true;
2017 }
2018
2019 static bool
2020 _equalFuncCall(const FuncCall *a, const FuncCall *b)
2021 {
2022         COMPARE_NODE_FIELD(funcname);
2023         COMPARE_NODE_FIELD(args);
2024         COMPARE_NODE_FIELD(agg_order);
2025         COMPARE_SCALAR_FIELD(agg_star);
2026         COMPARE_SCALAR_FIELD(agg_distinct);
2027         COMPARE_SCALAR_FIELD(func_variadic);
2028         COMPARE_NODE_FIELD(over);
2029         COMPARE_LOCATION_FIELD(location);
2030
2031         return true;
2032 }
2033
2034 static bool
2035 _equalAStar(const A_Star *a, const A_Star *b)
2036 {
2037         return true;
2038 }
2039
2040 static bool
2041 _equalAIndices(const A_Indices *a, const A_Indices *b)
2042 {
2043         COMPARE_NODE_FIELD(lidx);
2044         COMPARE_NODE_FIELD(uidx);
2045
2046         return true;
2047 }
2048
2049 static bool
2050 _equalA_Indirection(const A_Indirection *a, const A_Indirection *b)
2051 {
2052         COMPARE_NODE_FIELD(arg);
2053         COMPARE_NODE_FIELD(indirection);
2054
2055         return true;
2056 }
2057
2058 static bool
2059 _equalA_ArrayExpr(const A_ArrayExpr *a, const A_ArrayExpr *b)
2060 {
2061         COMPARE_NODE_FIELD(elements);
2062         COMPARE_LOCATION_FIELD(location);
2063
2064         return true;
2065 }
2066
2067 static bool
2068 _equalResTarget(const ResTarget *a, const ResTarget *b)
2069 {
2070         COMPARE_STRING_FIELD(name);
2071         COMPARE_NODE_FIELD(indirection);
2072         COMPARE_NODE_FIELD(val);
2073         COMPARE_LOCATION_FIELD(location);
2074
2075         return true;
2076 }
2077
2078 static bool
2079 _equalTypeName(const TypeName *a, const TypeName *b)
2080 {
2081         COMPARE_NODE_FIELD(names);
2082         COMPARE_SCALAR_FIELD(typeOid);
2083         COMPARE_SCALAR_FIELD(setof);
2084         COMPARE_SCALAR_FIELD(pct_type);
2085         COMPARE_NODE_FIELD(typmods);
2086         COMPARE_SCALAR_FIELD(typemod);
2087         COMPARE_NODE_FIELD(arrayBounds);
2088         COMPARE_LOCATION_FIELD(location);
2089
2090         return true;
2091 }
2092
2093 static bool
2094 _equalTypeCast(const TypeCast *a, const TypeCast *b)
2095 {
2096         COMPARE_NODE_FIELD(arg);
2097         COMPARE_NODE_FIELD(typeName);
2098         COMPARE_LOCATION_FIELD(location);
2099
2100         return true;
2101 }
2102
2103 static bool
2104 _equalCollateClause(const CollateClause *a, const CollateClause *b)
2105 {
2106         COMPARE_NODE_FIELD(arg);
2107         COMPARE_NODE_FIELD(collname);
2108         COMPARE_LOCATION_FIELD(location);
2109
2110         return true;
2111 }
2112
2113 static bool
2114 _equalSortBy(const SortBy *a, const SortBy *b)
2115 {
2116         COMPARE_NODE_FIELD(node);
2117         COMPARE_SCALAR_FIELD(sortby_dir);
2118         COMPARE_SCALAR_FIELD(sortby_nulls);
2119         COMPARE_NODE_FIELD(useOp);
2120         COMPARE_LOCATION_FIELD(location);
2121
2122         return true;
2123 }
2124
2125 static bool
2126 _equalWindowDef(const WindowDef *a, const WindowDef *b)
2127 {
2128         COMPARE_STRING_FIELD(name);
2129         COMPARE_STRING_FIELD(refname);
2130         COMPARE_NODE_FIELD(partitionClause);
2131         COMPARE_NODE_FIELD(orderClause);
2132         COMPARE_SCALAR_FIELD(frameOptions);
2133         COMPARE_NODE_FIELD(startOffset);
2134         COMPARE_NODE_FIELD(endOffset);
2135         COMPARE_LOCATION_FIELD(location);
2136
2137         return true;
2138 }
2139
2140 static bool
2141 _equalRangeSubselect(const RangeSubselect *a, const RangeSubselect *b)
2142 {
2143         COMPARE_NODE_FIELD(subquery);
2144         COMPARE_NODE_FIELD(alias);
2145
2146         return true;
2147 }
2148
2149 static bool
2150 _equalRangeFunction(const RangeFunction *a, const RangeFunction *b)
2151 {
2152         COMPARE_NODE_FIELD(funccallnode);
2153         COMPARE_NODE_FIELD(alias);
2154         COMPARE_NODE_FIELD(coldeflist);
2155
2156         return true;
2157 }
2158
2159 static bool
2160 _equalIndexElem(const IndexElem *a, const IndexElem *b)
2161 {
2162         COMPARE_STRING_FIELD(name);
2163         COMPARE_NODE_FIELD(expr);
2164         COMPARE_STRING_FIELD(indexcolname);
2165         COMPARE_NODE_FIELD(collation);
2166         COMPARE_NODE_FIELD(opclass);
2167         COMPARE_SCALAR_FIELD(ordering);
2168         COMPARE_SCALAR_FIELD(nulls_ordering);
2169
2170         return true;
2171 }
2172
2173 static bool
2174 _equalColumnDef(const ColumnDef *a, const ColumnDef *b)
2175 {
2176         COMPARE_STRING_FIELD(colname);
2177         COMPARE_NODE_FIELD(typeName);
2178         COMPARE_SCALAR_FIELD(inhcount);
2179         COMPARE_SCALAR_FIELD(is_local);
2180         COMPARE_SCALAR_FIELD(is_not_null);
2181         COMPARE_SCALAR_FIELD(is_from_type);
2182         COMPARE_SCALAR_FIELD(storage);
2183         COMPARE_NODE_FIELD(raw_default);
2184         COMPARE_NODE_FIELD(cooked_default);
2185         COMPARE_NODE_FIELD(collClause);
2186         COMPARE_SCALAR_FIELD(collOid);
2187         COMPARE_NODE_FIELD(constraints);
2188         COMPARE_NODE_FIELD(fdwoptions);
2189
2190         return true;
2191 }
2192
2193 static bool
2194 _equalConstraint(const Constraint *a, const Constraint *b)
2195 {
2196         COMPARE_SCALAR_FIELD(contype);
2197         COMPARE_STRING_FIELD(conname);
2198         COMPARE_SCALAR_FIELD(deferrable);
2199         COMPARE_SCALAR_FIELD(initdeferred);
2200         COMPARE_LOCATION_FIELD(location);
2201         COMPARE_SCALAR_FIELD(is_no_inherit);
2202         COMPARE_NODE_FIELD(raw_expr);
2203         COMPARE_STRING_FIELD(cooked_expr);
2204         COMPARE_NODE_FIELD(keys);
2205         COMPARE_NODE_FIELD(exclusions);
2206         COMPARE_NODE_FIELD(options);
2207         COMPARE_STRING_FIELD(indexname);
2208         COMPARE_STRING_FIELD(indexspace);
2209         COMPARE_STRING_FIELD(access_method);
2210         COMPARE_NODE_FIELD(where_clause);
2211         COMPARE_NODE_FIELD(pktable);
2212         COMPARE_NODE_FIELD(fk_attrs);
2213         COMPARE_NODE_FIELD(pk_attrs);
2214         COMPARE_SCALAR_FIELD(fk_matchtype);
2215         COMPARE_SCALAR_FIELD(fk_upd_action);
2216         COMPARE_SCALAR_FIELD(fk_del_action);
2217         COMPARE_NODE_FIELD(old_conpfeqop);
2218         COMPARE_SCALAR_FIELD(skip_validation);
2219         COMPARE_SCALAR_FIELD(initially_valid);
2220
2221         return true;
2222 }
2223
2224 static bool
2225 _equalDefElem(const DefElem *a, const DefElem *b)
2226 {
2227         COMPARE_STRING_FIELD(defnamespace);
2228         COMPARE_STRING_FIELD(defname);
2229         COMPARE_NODE_FIELD(arg);
2230         COMPARE_SCALAR_FIELD(defaction);
2231
2232         return true;
2233 }
2234
2235 static bool
2236 _equalLockingClause(const LockingClause *a, const LockingClause *b)
2237 {
2238         COMPARE_NODE_FIELD(lockedRels);
2239         COMPARE_SCALAR_FIELD(forUpdate);
2240         COMPARE_SCALAR_FIELD(noWait);
2241
2242         return true;
2243 }
2244
2245 static bool
2246 _equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b)
2247 {
2248         COMPARE_SCALAR_FIELD(rtekind);
2249         COMPARE_SCALAR_FIELD(relid);
2250         COMPARE_SCALAR_FIELD(relkind);
2251         COMPARE_NODE_FIELD(subquery);
2252         COMPARE_SCALAR_FIELD(security_barrier);
2253         COMPARE_SCALAR_FIELD(jointype);
2254         COMPARE_NODE_FIELD(joinaliasvars);
2255         COMPARE_NODE_FIELD(funcexpr);
2256         COMPARE_NODE_FIELD(funccoltypes);
2257         COMPARE_NODE_FIELD(funccoltypmods);
2258         COMPARE_NODE_FIELD(funccolcollations);
2259         COMPARE_NODE_FIELD(values_lists);
2260         COMPARE_NODE_FIELD(values_collations);
2261         COMPARE_STRING_FIELD(ctename);
2262         COMPARE_SCALAR_FIELD(ctelevelsup);
2263         COMPARE_SCALAR_FIELD(self_reference);
2264         COMPARE_NODE_FIELD(ctecoltypes);
2265         COMPARE_NODE_FIELD(ctecoltypmods);
2266         COMPARE_NODE_FIELD(ctecolcollations);
2267         COMPARE_NODE_FIELD(alias);
2268         COMPARE_NODE_FIELD(eref);
2269         COMPARE_SCALAR_FIELD(inh);
2270         COMPARE_SCALAR_FIELD(inFromCl);
2271         COMPARE_SCALAR_FIELD(requiredPerms);
2272         COMPARE_SCALAR_FIELD(checkAsUser);
2273         COMPARE_BITMAPSET_FIELD(selectedCols);
2274         COMPARE_BITMAPSET_FIELD(modifiedCols);
2275
2276         return true;
2277 }
2278
2279 static bool
2280 _equalSortGroupClause(const SortGroupClause *a, const SortGroupClause *b)
2281 {
2282         COMPARE_SCALAR_FIELD(tleSortGroupRef);
2283         COMPARE_SCALAR_FIELD(eqop);
2284         COMPARE_SCALAR_FIELD(sortop);
2285         COMPARE_SCALAR_FIELD(nulls_first);
2286         COMPARE_SCALAR_FIELD(hashable);
2287
2288         return true;
2289 }
2290
2291 static bool
2292 _equalWindowClause(const WindowClause *a, const WindowClause *b)
2293 {
2294         COMPARE_STRING_FIELD(name);
2295         COMPARE_STRING_FIELD(refname);
2296         COMPARE_NODE_FIELD(partitionClause);
2297         COMPARE_NODE_FIELD(orderClause);
2298         COMPARE_SCALAR_FIELD(frameOptions);
2299         COMPARE_NODE_FIELD(startOffset);
2300         COMPARE_NODE_FIELD(endOffset);
2301         COMPARE_SCALAR_FIELD(winref);
2302         COMPARE_SCALAR_FIELD(copiedOrder);
2303
2304         return true;
2305 }
2306
2307 static bool
2308 _equalRowMarkClause(const RowMarkClause *a, const RowMarkClause *b)
2309 {
2310         COMPARE_SCALAR_FIELD(rti);
2311         COMPARE_SCALAR_FIELD(forUpdate);
2312         COMPARE_SCALAR_FIELD(noWait);
2313         COMPARE_SCALAR_FIELD(pushedDown);
2314
2315         return true;
2316 }
2317
2318 static bool
2319 _equalWithClause(const WithClause *a, const WithClause *b)
2320 {
2321         COMPARE_NODE_FIELD(ctes);
2322         COMPARE_SCALAR_FIELD(recursive);
2323         COMPARE_LOCATION_FIELD(location);
2324
2325         return true;
2326 }
2327
2328 static bool
2329 _equalCommonTableExpr(const CommonTableExpr *a, const CommonTableExpr *b)
2330 {
2331         COMPARE_STRING_FIELD(ctename);
2332         COMPARE_NODE_FIELD(aliascolnames);
2333         COMPARE_NODE_FIELD(ctequery);
2334         COMPARE_LOCATION_FIELD(location);
2335         COMPARE_SCALAR_FIELD(cterecursive);
2336         COMPARE_SCALAR_FIELD(cterefcount);
2337         COMPARE_NODE_FIELD(ctecolnames);
2338         COMPARE_NODE_FIELD(ctecoltypes);
2339         COMPARE_NODE_FIELD(ctecoltypmods);
2340         COMPARE_NODE_FIELD(ctecolcollations);
2341
2342         return true;
2343 }
2344
2345 static bool
2346 _equalXmlSerialize(const XmlSerialize *a, const XmlSerialize *b)
2347 {
2348         COMPARE_SCALAR_FIELD(xmloption);
2349         COMPARE_NODE_FIELD(expr);
2350         COMPARE_NODE_FIELD(typeName);
2351         COMPARE_LOCATION_FIELD(location);
2352
2353         return true;
2354 }
2355
2356 /*
2357  * Stuff from pg_list.h
2358  */
2359
2360 static bool
2361 _equalList(const List *a, const List *b)
2362 {
2363         const ListCell   *item_a;
2364         const ListCell   *item_b;
2365
2366         /*
2367          * Try to reject by simple scalar checks before grovelling through all the
2368          * list elements...
2369          */
2370         COMPARE_SCALAR_FIELD(type);
2371         COMPARE_SCALAR_FIELD(length);
2372
2373         /*
2374          * We place the switch outside the loop for the sake of efficiency; this
2375          * may not be worth doing...
2376          */
2377         switch (a->type)
2378         {
2379                 case T_List:
2380                         forboth(item_a, a, item_b, b)
2381                         {
2382                                 if (!equal(lfirst(item_a), lfirst(item_b)))
2383                                         return false;
2384                         }
2385                         break;
2386                 case T_IntList:
2387                         forboth(item_a, a, item_b, b)
2388                         {
2389                                 if (lfirst_int(item_a) != lfirst_int(item_b))
2390                                         return false;
2391                         }
2392                         break;
2393                 case T_OidList:
2394                         forboth(item_a, a, item_b, b)
2395                         {
2396                                 if (lfirst_oid(item_a) != lfirst_oid(item_b))
2397                                         return false;
2398                         }
2399                         break;
2400                 default:
2401                         elog(ERROR, "unrecognized list node type: %d",
2402                                  (int) a->type);
2403                         return false;           /* keep compiler quiet */
2404         }
2405
2406         /*
2407          * If we got here, we should have run out of elements of both lists
2408          */
2409         Assert(item_a == NULL);
2410         Assert(item_b == NULL);
2411
2412         return true;
2413 }
2414
2415 /*
2416  * Stuff from value.h
2417  */
2418
2419 static bool
2420 _equalValue(const Value *a, const Value *b)
2421 {
2422         COMPARE_SCALAR_FIELD(type);
2423
2424         switch (a->type)
2425         {
2426                 case T_Integer:
2427                         COMPARE_SCALAR_FIELD(val.ival);
2428                         break;
2429                 case T_Float:
2430                 case T_String:
2431                 case T_BitString:
2432                         COMPARE_STRING_FIELD(val.str);
2433                         break;
2434                 case T_Null:
2435                         /* nothing to do */
2436                         break;
2437                 default:
2438                         elog(ERROR, "unrecognized node type: %d", (int) a->type);
2439                         break;
2440         }
2441
2442         return true;
2443 }
2444
2445 /*
2446  * equal
2447  *        returns whether two nodes are equal
2448  */
2449 bool
2450 equal(const void *a, const void *b)
2451 {
2452         bool            retval;
2453
2454         if (a == b)
2455                 return true;
2456
2457         /*
2458          * note that a!=b, so only one of them can be NULL
2459          */
2460         if (a == NULL || b == NULL)
2461                 return false;
2462
2463         /*
2464          * are they the same type of nodes?
2465          */
2466         if (nodeTag(a) != nodeTag(b))
2467                 return false;
2468
2469         switch (nodeTag(a))
2470         {
2471                         /*
2472                          * PRIMITIVE NODES
2473                          */
2474                 case T_Alias:
2475                         retval = _equalAlias(a, b);
2476                         break;
2477                 case T_RangeVar:
2478                         retval = _equalRangeVar(a, b);
2479                         break;
2480                 case T_IntoClause:
2481                         retval = _equalIntoClause(a, b);
2482                         break;
2483                 case T_Var:
2484                         retval = _equalVar(a, b);
2485                         break;
2486                 case T_Const:
2487                         retval = _equalConst(a, b);
2488                         break;
2489                 case T_Param:
2490                         retval = _equalParam(a, b);
2491                         break;
2492                 case T_Aggref:
2493                         retval = _equalAggref(a, b);
2494                         break;
2495                 case T_WindowFunc:
2496                         retval = _equalWindowFunc(a, b);
2497                         break;
2498                 case T_ArrayRef:
2499                         retval = _equalArrayRef(a, b);
2500                         break;
2501                 case T_FuncExpr:
2502                         retval = _equalFuncExpr(a, b);
2503                         break;
2504                 case T_NamedArgExpr:
2505                         retval = _equalNamedArgExpr(a, b);
2506                         break;
2507                 case T_OpExpr:
2508                         retval = _equalOpExpr(a, b);
2509                         break;
2510                 case T_DistinctExpr:
2511                         retval = _equalDistinctExpr(a, b);
2512                         break;
2513                 case T_NullIfExpr:
2514                         retval = _equalNullIfExpr(a, b);
2515                         break;
2516                 case T_ScalarArrayOpExpr:
2517                         retval = _equalScalarArrayOpExpr(a, b);
2518                         break;
2519                 case T_BoolExpr:
2520                         retval = _equalBoolExpr(a, b);
2521                         break;
2522                 case T_SubLink:
2523                         retval = _equalSubLink(a, b);
2524                         break;
2525                 case T_SubPlan:
2526                         retval = _equalSubPlan(a, b);
2527                         break;
2528                 case T_AlternativeSubPlan:
2529                         retval = _equalAlternativeSubPlan(a, b);
2530                         break;
2531                 case T_FieldSelect:
2532                         retval = _equalFieldSelect(a, b);
2533                         break;
2534                 case T_FieldStore:
2535                         retval = _equalFieldStore(a, b);
2536                         break;
2537                 case T_RelabelType:
2538                         retval = _equalRelabelType(a, b);
2539                         break;
2540                 case T_CoerceViaIO:
2541                         retval = _equalCoerceViaIO(a, b);
2542                         break;
2543                 case T_ArrayCoerceExpr:
2544                         retval = _equalArrayCoerceExpr(a, b);
2545                         break;
2546                 case T_ConvertRowtypeExpr:
2547                         retval = _equalConvertRowtypeExpr(a, b);
2548                         break;
2549                 case T_CollateExpr:
2550                         retval = _equalCollateExpr(a, b);
2551                         break;
2552                 case T_CaseExpr:
2553                         retval = _equalCaseExpr(a, b);
2554                         break;
2555                 case T_CaseWhen:
2556                         retval = _equalCaseWhen(a, b);
2557                         break;
2558                 case T_CaseTestExpr:
2559                         retval = _equalCaseTestExpr(a, b);
2560                         break;
2561                 case T_ArrayExpr:
2562                         retval = _equalArrayExpr(a, b);
2563                         break;
2564                 case T_RowExpr:
2565                         retval = _equalRowExpr(a, b);
2566                         break;
2567                 case T_RowCompareExpr:
2568                         retval = _equalRowCompareExpr(a, b);
2569                         break;
2570                 case T_CoalesceExpr:
2571                         retval = _equalCoalesceExpr(a, b);
2572                         break;
2573                 case T_MinMaxExpr:
2574                         retval = _equalMinMaxExpr(a, b);
2575                         break;
2576                 case T_XmlExpr:
2577                         retval = _equalXmlExpr(a, b);
2578                         break;
2579                 case T_NullTest:
2580                         retval = _equalNullTest(a, b);
2581                         break;
2582                 case T_BooleanTest:
2583                         retval = _equalBooleanTest(a, b);
2584                         break;
2585                 case T_CoerceToDomain:
2586                         retval = _equalCoerceToDomain(a, b);
2587                         break;
2588                 case T_CoerceToDomainValue:
2589                         retval = _equalCoerceToDomainValue(a, b);
2590                         break;
2591                 case T_SetToDefault:
2592                         retval = _equalSetToDefault(a, b);
2593                         break;
2594                 case T_CurrentOfExpr:
2595                         retval = _equalCurrentOfExpr(a, b);
2596                         break;
2597                 case T_TargetEntry:
2598                         retval = _equalTargetEntry(a, b);
2599                         break;
2600                 case T_RangeTblRef:
2601                         retval = _equalRangeTblRef(a, b);
2602                         break;
2603                 case T_FromExpr:
2604                         retval = _equalFromExpr(a, b);
2605                         break;
2606                 case T_JoinExpr:
2607                         retval = _equalJoinExpr(a, b);
2608                         break;
2609
2610                         /*
2611                          * RELATION NODES
2612                          */
2613                 case T_PathKey:
2614                         retval = _equalPathKey(a, b);
2615                         break;
2616                 case T_RestrictInfo:
2617                         retval = _equalRestrictInfo(a, b);
2618                         break;
2619                 case T_PlaceHolderVar:
2620                         retval = _equalPlaceHolderVar(a, b);
2621                         break;
2622                 case T_SpecialJoinInfo:
2623                         retval = _equalSpecialJoinInfo(a, b);
2624                         break;
2625                 case T_AppendRelInfo:
2626                         retval = _equalAppendRelInfo(a, b);
2627                         break;
2628                 case T_PlaceHolderInfo:
2629                         retval = _equalPlaceHolderInfo(a, b);
2630                         break;
2631
2632                 case T_List:
2633                 case T_IntList:
2634                 case T_OidList:
2635                         retval = _equalList(a, b);
2636                         break;
2637
2638                 case T_Integer:
2639                 case T_Float:
2640                 case T_String:
2641                 case T_BitString:
2642                 case T_Null:
2643                         retval = _equalValue(a, b);
2644                         break;
2645
2646                         /*
2647                          * PARSE NODES
2648                          */
2649                 case T_Query:
2650                         retval = _equalQuery(a, b);
2651                         break;
2652                 case T_InsertStmt:
2653                         retval = _equalInsertStmt(a, b);
2654                         break;
2655                 case T_DeleteStmt:
2656                         retval = _equalDeleteStmt(a, b);
2657                         break;
2658                 case T_UpdateStmt:
2659                         retval = _equalUpdateStmt(a, b);
2660                         break;
2661                 case T_SelectStmt:
2662                         retval = _equalSelectStmt(a, b);
2663                         break;
2664                 case T_SetOperationStmt:
2665                         retval = _equalSetOperationStmt(a, b);
2666                         break;
2667                 case T_AlterTableStmt:
2668                         retval = _equalAlterTableStmt(a, b);
2669                         break;
2670                 case T_AlterTableCmd:
2671                         retval = _equalAlterTableCmd(a, b);
2672                         break;
2673                 case T_AlterDomainStmt:
2674                         retval = _equalAlterDomainStmt(a, b);
2675                         break;
2676                 case T_GrantStmt:
2677                         retval = _equalGrantStmt(a, b);
2678                         break;
2679                 case T_GrantRoleStmt:
2680                         retval = _equalGrantRoleStmt(a, b);
2681                         break;
2682                 case T_AlterDefaultPrivilegesStmt:
2683                         retval = _equalAlterDefaultPrivilegesStmt(a, b);
2684                         break;
2685                 case T_DeclareCursorStmt:
2686                         retval = _equalDeclareCursorStmt(a, b);
2687                         break;
2688                 case T_ClosePortalStmt:
2689                         retval = _equalClosePortalStmt(a, b);
2690                         break;
2691                 case T_ClusterStmt:
2692                         retval = _equalClusterStmt(a, b);
2693                         break;
2694                 case T_CopyStmt:
2695                         retval = _equalCopyStmt(a, b);
2696                         break;
2697                 case T_CreateStmt:
2698                         retval = _equalCreateStmt(a, b);
2699                         break;
2700                 case T_TableLikeClause:
2701                         retval = _equalTableLikeClause(a, b);
2702                         break;
2703                 case T_DefineStmt:
2704                         retval = _equalDefineStmt(a, b);
2705                         break;
2706                 case T_DropStmt:
2707                         retval = _equalDropStmt(a, b);
2708                         break;
2709                 case T_TruncateStmt:
2710                         retval = _equalTruncateStmt(a, b);
2711                         break;
2712                 case T_CommentStmt:
2713                         retval = _equalCommentStmt(a, b);
2714                         break;
2715                 case T_SecLabelStmt:
2716                         retval = _equalSecLabelStmt(a, b);
2717                         break;
2718                 case T_FetchStmt:
2719                         retval = _equalFetchStmt(a, b);
2720                         break;
2721                 case T_IndexStmt:
2722                         retval = _equalIndexStmt(a, b);
2723                         break;
2724                 case T_CreateFunctionStmt:
2725                         retval = _equalCreateFunctionStmt(a, b);
2726                         break;
2727                 case T_FunctionParameter:
2728                         retval = _equalFunctionParameter(a, b);
2729                         break;
2730                 case T_AlterFunctionStmt:
2731                         retval = _equalAlterFunctionStmt(a, b);
2732                         break;
2733                 case T_DoStmt:
2734                         retval = _equalDoStmt(a, b);
2735                         break;
2736                 case T_RenameStmt:
2737                         retval = _equalRenameStmt(a, b);
2738                         break;
2739                 case T_AlterObjectSchemaStmt:
2740                         retval = _equalAlterObjectSchemaStmt(a, b);
2741                         break;
2742                 case T_AlterOwnerStmt:
2743                         retval = _equalAlterOwnerStmt(a, b);
2744                         break;
2745                 case T_RuleStmt:
2746                         retval = _equalRuleStmt(a, b);
2747                         break;
2748                 case T_NotifyStmt:
2749                         retval = _equalNotifyStmt(a, b);
2750                         break;
2751                 case T_ListenStmt:
2752                         retval = _equalListenStmt(a, b);
2753                         break;
2754                 case T_UnlistenStmt:
2755                         retval = _equalUnlistenStmt(a, b);
2756                         break;
2757                 case T_TransactionStmt:
2758                         retval = _equalTransactionStmt(a, b);
2759                         break;
2760                 case T_CompositeTypeStmt:
2761                         retval = _equalCompositeTypeStmt(a, b);
2762                         break;
2763                 case T_CreateEnumStmt:
2764                         retval = _equalCreateEnumStmt(a, b);
2765                         break;
2766                 case T_CreateRangeStmt:
2767                         retval = _equalCreateRangeStmt(a, b);
2768                         break;
2769                 case T_AlterEnumStmt:
2770                         retval = _equalAlterEnumStmt(a, b);
2771                         break;
2772                 case T_ViewStmt:
2773                         retval = _equalViewStmt(a, b);
2774                         break;
2775                 case T_LoadStmt:
2776                         retval = _equalLoadStmt(a, b);
2777                         break;
2778                 case T_CreateDomainStmt:
2779                         retval = _equalCreateDomainStmt(a, b);
2780                         break;
2781                 case T_CreateOpClassStmt:
2782                         retval = _equalCreateOpClassStmt(a, b);
2783                         break;
2784                 case T_CreateOpClassItem:
2785                         retval = _equalCreateOpClassItem(a, b);
2786                         break;
2787                 case T_CreateOpFamilyStmt:
2788                         retval = _equalCreateOpFamilyStmt(a, b);
2789                         break;
2790                 case T_AlterOpFamilyStmt:
2791                         retval = _equalAlterOpFamilyStmt(a, b);
2792                         break;
2793                 case T_CreatedbStmt:
2794                         retval = _equalCreatedbStmt(a, b);
2795                         break;
2796                 case T_AlterDatabaseStmt:
2797                         retval = _equalAlterDatabaseStmt(a, b);
2798                         break;
2799                 case T_AlterDatabaseSetStmt:
2800                         retval = _equalAlterDatabaseSetStmt(a, b);
2801                         break;
2802                 case T_DropdbStmt:
2803                         retval = _equalDropdbStmt(a, b);
2804                         break;
2805                 case T_VacuumStmt:
2806                         retval = _equalVacuumStmt(a, b);
2807                         break;
2808                 case T_ExplainStmt:
2809                         retval = _equalExplainStmt(a, b);
2810                         break;
2811                 case T_CreateTableAsStmt:
2812                         retval = _equalCreateTableAsStmt(a, b);
2813                         break;
2814                 case T_CreateSeqStmt:
2815                         retval = _equalCreateSeqStmt(a, b);
2816                         break;
2817                 case T_AlterSeqStmt:
2818                         retval = _equalAlterSeqStmt(a, b);
2819                         break;
2820                 case T_VariableSetStmt:
2821                         retval = _equalVariableSetStmt(a, b);
2822                         break;
2823                 case T_VariableShowStmt:
2824                         retval = _equalVariableShowStmt(a, b);
2825                         break;
2826                 case T_DiscardStmt:
2827                         retval = _equalDiscardStmt(a, b);
2828                         break;
2829                 case T_CreateTableSpaceStmt:
2830                         retval = _equalCreateTableSpaceStmt(a, b);
2831                         break;
2832                 case T_DropTableSpaceStmt:
2833                         retval = _equalDropTableSpaceStmt(a, b);
2834                         break;
2835                 case T_AlterTableSpaceOptionsStmt:
2836                         retval = _equalAlterTableSpaceOptionsStmt(a, b);
2837                         break;
2838                 case T_CreateExtensionStmt:
2839                         retval = _equalCreateExtensionStmt(a, b);
2840                         break;
2841                 case T_AlterExtensionStmt:
2842                         retval = _equalAlterExtensionStmt(a, b);
2843                         break;
2844                 case T_AlterExtensionContentsStmt:
2845                         retval = _equalAlterExtensionContentsStmt(a, b);
2846                         break;
2847                 case T_CreateFdwStmt:
2848                         retval = _equalCreateFdwStmt(a, b);
2849                         break;
2850                 case T_AlterFdwStmt:
2851                         retval = _equalAlterFdwStmt(a, b);
2852                         break;
2853                 case T_CreateForeignServerStmt:
2854                         retval = _equalCreateForeignServerStmt(a, b);
2855                         break;
2856                 case T_AlterForeignServerStmt:
2857                         retval = _equalAlterForeignServerStmt(a, b);
2858                         break;
2859                 case T_CreateUserMappingStmt:
2860                         retval = _equalCreateUserMappingStmt(a, b);
2861                         break;
2862                 case T_AlterUserMappingStmt:
2863                         retval = _equalAlterUserMappingStmt(a, b);
2864                         break;
2865                 case T_DropUserMappingStmt:
2866                         retval = _equalDropUserMappingStmt(a, b);
2867                         break;
2868                 case T_CreateForeignTableStmt:
2869                         retval = _equalCreateForeignTableStmt(a, b);
2870                         break;
2871                 case T_CreateTrigStmt:
2872                         retval = _equalCreateTrigStmt(a, b);
2873                         break;
2874                 case T_CreatePLangStmt:
2875                         retval = _equalCreatePLangStmt(a, b);
2876                         break;
2877                 case T_CreateRoleStmt:
2878                         retval = _equalCreateRoleStmt(a, b);
2879                         break;
2880                 case T_AlterRoleStmt:
2881                         retval = _equalAlterRoleStmt(a, b);
2882                         break;
2883                 case T_AlterRoleSetStmt:
2884                         retval = _equalAlterRoleSetStmt(a, b);
2885                         break;
2886                 case T_DropRoleStmt:
2887                         retval = _equalDropRoleStmt(a, b);
2888                         break;
2889                 case T_LockStmt:
2890                         retval = _equalLockStmt(a, b);
2891                         break;
2892                 case T_ConstraintsSetStmt:
2893                         retval = _equalConstraintsSetStmt(a, b);
2894                         break;
2895                 case T_ReindexStmt:
2896                         retval = _equalReindexStmt(a, b);
2897                         break;
2898                 case T_CheckPointStmt:
2899                         retval = true;
2900                         break;
2901                 case T_CreateSchemaStmt:
2902                         retval = _equalCreateSchemaStmt(a, b);
2903                         break;
2904                 case T_CreateConversionStmt:
2905                         retval = _equalCreateConversionStmt(a, b);
2906                         break;
2907                 case T_CreateCastStmt:
2908                         retval = _equalCreateCastStmt(a, b);
2909                         break;
2910                 case T_PrepareStmt:
2911                         retval = _equalPrepareStmt(a, b);
2912                         break;
2913                 case T_ExecuteStmt:
2914                         retval = _equalExecuteStmt(a, b);
2915                         break;
2916                 case T_DeallocateStmt:
2917                         retval = _equalDeallocateStmt(a, b);
2918                         break;
2919                 case T_DropOwnedStmt:
2920                         retval = _equalDropOwnedStmt(a, b);
2921                         break;
2922                 case T_ReassignOwnedStmt:
2923                         retval = _equalReassignOwnedStmt(a, b);
2924                         break;
2925                 case T_AlterTSDictionaryStmt:
2926                         retval = _equalAlterTSDictionaryStmt(a, b);
2927                         break;
2928                 case T_AlterTSConfigurationStmt:
2929                         retval = _equalAlterTSConfigurationStmt(a, b);
2930                         break;
2931
2932                 case T_A_Expr:
2933                         retval = _equalAExpr(a, b);
2934                         break;
2935                 case T_ColumnRef:
2936                         retval = _equalColumnRef(a, b);
2937                         break;
2938                 case T_ParamRef:
2939                         retval = _equalParamRef(a, b);
2940                         break;
2941                 case T_A_Const:
2942                         retval = _equalAConst(a, b);
2943                         break;
2944                 case T_FuncCall:
2945                         retval = _equalFuncCall(a, b);
2946                         break;
2947                 case T_A_Star:
2948                         retval = _equalAStar(a, b);
2949                         break;
2950                 case T_A_Indices:
2951                         retval = _equalAIndices(a, b);
2952                         break;
2953                 case T_A_Indirection:
2954                         retval = _equalA_Indirection(a, b);
2955                         break;
2956                 case T_A_ArrayExpr:
2957                         retval = _equalA_ArrayExpr(a, b);
2958                         break;
2959                 case T_ResTarget:
2960                         retval = _equalResTarget(a, b);
2961                         break;
2962                 case T_TypeCast:
2963                         retval = _equalTypeCast(a, b);
2964                         break;
2965                 case T_CollateClause:
2966                         retval = _equalCollateClause(a, b);
2967                         break;
2968                 case T_SortBy:
2969                         retval = _equalSortBy(a, b);
2970                         break;
2971                 case T_WindowDef:
2972                         retval = _equalWindowDef(a, b);
2973                         break;
2974                 case T_RangeSubselect:
2975                         retval = _equalRangeSubselect(a, b);
2976                         break;
2977                 case T_RangeFunction:
2978                         retval = _equalRangeFunction(a, b);
2979                         break;
2980                 case T_TypeName:
2981                         retval = _equalTypeName(a, b);
2982                         break;
2983                 case T_IndexElem:
2984                         retval = _equalIndexElem(a, b);
2985                         break;
2986                 case T_ColumnDef:
2987                         retval = _equalColumnDef(a, b);
2988                         break;
2989                 case T_Constraint:
2990                         retval = _equalConstraint(a, b);
2991                         break;
2992                 case T_DefElem:
2993                         retval = _equalDefElem(a, b);
2994                         break;
2995                 case T_LockingClause:
2996                         retval = _equalLockingClause(a, b);
2997                         break;
2998                 case T_RangeTblEntry:
2999                         retval = _equalRangeTblEntry(a, b);
3000                         break;
3001                 case T_SortGroupClause:
3002                         retval = _equalSortGroupClause(a, b);
3003                         break;
3004                 case T_WindowClause:
3005                         retval = _equalWindowClause(a, b);
3006                         break;
3007                 case T_RowMarkClause:
3008                         retval = _equalRowMarkClause(a, b);
3009                         break;
3010                 case T_WithClause:
3011                         retval = _equalWithClause(a, b);
3012                         break;
3013                 case T_CommonTableExpr:
3014                         retval = _equalCommonTableExpr(a, b);
3015                         break;
3016                 case T_PrivGrantee:
3017                         retval = _equalPrivGrantee(a, b);
3018                         break;
3019                 case T_FuncWithArgs:
3020                         retval = _equalFuncWithArgs(a, b);
3021                         break;
3022                 case T_AccessPriv:
3023                         retval = _equalAccessPriv(a, b);
3024                         break;
3025                 case T_XmlSerialize:
3026                         retval = _equalXmlSerialize(a, b);
3027                         break;
3028
3029                 default:
3030                         elog(ERROR, "unrecognized node type: %d",
3031                                  (int) nodeTag(a));
3032                         retval = false;         /* keep compiler quiet */
3033                         break;
3034         }
3035
3036         return retval;
3037 }