Add support for user-defined I/O conversion casts.
[PostgreSQL.git] / src / backend / nodes / equalfuncs.c
blobed902734f9ffab272f5c211f3017fd7a1fc87664
1 /*-------------------------------------------------------------------------
3 * equalfuncs.c
4 * Equality functions to compare node trees.
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.
13 * Currently, in fact, equal() doesn't know how to compare Plan trees
14 * either. This might need to be fixed someday.
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.
21 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
22 * Portions Copyright (c) 1994, Regents of the University of California
24 * IDENTIFICATION
25 * $PostgreSQL$
27 *-------------------------------------------------------------------------
30 #include "postgres.h"
32 #include "nodes/relation.h"
33 #include "utils/datum.h"
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'.
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)
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)
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)
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)
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))
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)
82 /* Compare a parse location field (this is a no-op, per note above) */
83 #define COMPARE_LOCATION_FIELD(fldname) \
84 ((void) 0)
88 * Stuff from primnodes.h
91 static bool
92 _equalAlias(Alias *a, Alias *b)
94 COMPARE_STRING_FIELD(aliasname);
95 COMPARE_NODE_FIELD(colnames);
97 return true;
100 static bool
101 _equalRangeVar(RangeVar *a, RangeVar *b)
103 COMPARE_STRING_FIELD(catalogname);
104 COMPARE_STRING_FIELD(schemaname);
105 COMPARE_STRING_FIELD(relname);
106 COMPARE_SCALAR_FIELD(inhOpt);
107 COMPARE_SCALAR_FIELD(istemp);
108 COMPARE_NODE_FIELD(alias);
109 COMPARE_LOCATION_FIELD(location);
111 return true;
114 static bool
115 _equalIntoClause(IntoClause *a, IntoClause *b)
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);
123 return true;
127 * We don't need an _equalExpr because Expr is an abstract supertype which
128 * should never actually get instantiated. Also, since it has no common
129 * fields except NodeTag, there's no need for a helper routine to factor
130 * out comparing the common fields...
133 static bool
134 _equalVar(Var *a, Var *b)
136 COMPARE_SCALAR_FIELD(varno);
137 COMPARE_SCALAR_FIELD(varattno);
138 COMPARE_SCALAR_FIELD(vartype);
139 COMPARE_SCALAR_FIELD(vartypmod);
140 COMPARE_SCALAR_FIELD(varlevelsup);
141 COMPARE_SCALAR_FIELD(varnoold);
142 COMPARE_SCALAR_FIELD(varoattno);
143 COMPARE_LOCATION_FIELD(location);
145 return true;
148 static bool
149 _equalConst(Const *a, Const *b)
151 COMPARE_SCALAR_FIELD(consttype);
152 COMPARE_SCALAR_FIELD(consttypmod);
153 COMPARE_SCALAR_FIELD(constlen);
154 COMPARE_SCALAR_FIELD(constisnull);
155 COMPARE_SCALAR_FIELD(constbyval);
156 COMPARE_LOCATION_FIELD(location);
159 * We treat all NULL constants of the same type as equal. Someday this
160 * might need to change? But datumIsEqual doesn't work on nulls, so...
162 if (a->constisnull)
163 return true;
164 return datumIsEqual(a->constvalue, b->constvalue,
165 a->constbyval, a->constlen);
168 static bool
169 _equalParam(Param *a, Param *b)
171 COMPARE_SCALAR_FIELD(paramkind);
172 COMPARE_SCALAR_FIELD(paramid);
173 COMPARE_SCALAR_FIELD(paramtype);
174 COMPARE_SCALAR_FIELD(paramtypmod);
175 COMPARE_LOCATION_FIELD(location);
177 return true;
180 static bool
181 _equalAggref(Aggref *a, Aggref *b)
183 COMPARE_SCALAR_FIELD(aggfnoid);
184 COMPARE_SCALAR_FIELD(aggtype);
185 COMPARE_NODE_FIELD(args);
186 COMPARE_SCALAR_FIELD(agglevelsup);
187 COMPARE_SCALAR_FIELD(aggstar);
188 COMPARE_SCALAR_FIELD(aggdistinct);
189 COMPARE_LOCATION_FIELD(location);
191 return true;
194 static bool
195 _equalArrayRef(ArrayRef *a, ArrayRef *b)
197 COMPARE_SCALAR_FIELD(refarraytype);
198 COMPARE_SCALAR_FIELD(refelemtype);
199 COMPARE_SCALAR_FIELD(reftypmod);
200 COMPARE_NODE_FIELD(refupperindexpr);
201 COMPARE_NODE_FIELD(reflowerindexpr);
202 COMPARE_NODE_FIELD(refexpr);
203 COMPARE_NODE_FIELD(refassgnexpr);
205 return true;
208 static bool
209 _equalFuncExpr(FuncExpr *a, FuncExpr *b)
211 COMPARE_SCALAR_FIELD(funcid);
212 COMPARE_SCALAR_FIELD(funcresulttype);
213 COMPARE_SCALAR_FIELD(funcretset);
216 * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
217 * that are equal() to both explicit and implicit coercions.
219 if (a->funcformat != b->funcformat &&
220 a->funcformat != COERCE_DONTCARE &&
221 b->funcformat != COERCE_DONTCARE)
222 return false;
224 COMPARE_NODE_FIELD(args);
225 COMPARE_LOCATION_FIELD(location);
227 return true;
230 static bool
231 _equalOpExpr(OpExpr *a, OpExpr *b)
233 COMPARE_SCALAR_FIELD(opno);
236 * Special-case opfuncid: it is allowable for it to differ if one node
237 * contains zero and the other doesn't. This just means that the one node
238 * isn't as far along in the parse/plan pipeline and hasn't had the
239 * opfuncid cache filled yet.
241 if (a->opfuncid != b->opfuncid &&
242 a->opfuncid != 0 &&
243 b->opfuncid != 0)
244 return false;
246 COMPARE_SCALAR_FIELD(opresulttype);
247 COMPARE_SCALAR_FIELD(opretset);
248 COMPARE_NODE_FIELD(args);
249 COMPARE_LOCATION_FIELD(location);
251 return true;
254 static bool
255 _equalDistinctExpr(DistinctExpr *a, DistinctExpr *b)
257 COMPARE_SCALAR_FIELD(opno);
260 * Special-case opfuncid: it is allowable for it to differ if one node
261 * contains zero and the other doesn't. This just means that the one node
262 * isn't as far along in the parse/plan pipeline and hasn't had the
263 * opfuncid cache filled yet.
265 if (a->opfuncid != b->opfuncid &&
266 a->opfuncid != 0 &&
267 b->opfuncid != 0)
268 return false;
270 COMPARE_SCALAR_FIELD(opresulttype);
271 COMPARE_SCALAR_FIELD(opretset);
272 COMPARE_NODE_FIELD(args);
273 COMPARE_LOCATION_FIELD(location);
275 return true;
278 static bool
279 _equalScalarArrayOpExpr(ScalarArrayOpExpr *a, ScalarArrayOpExpr *b)
281 COMPARE_SCALAR_FIELD(opno);
284 * Special-case opfuncid: it is allowable for it to differ if one node
285 * contains zero and the other doesn't. This just means that the one node
286 * isn't as far along in the parse/plan pipeline and hasn't had the
287 * opfuncid cache filled yet.
289 if (a->opfuncid != b->opfuncid &&
290 a->opfuncid != 0 &&
291 b->opfuncid != 0)
292 return false;
294 COMPARE_SCALAR_FIELD(useOr);
295 COMPARE_NODE_FIELD(args);
296 COMPARE_LOCATION_FIELD(location);
298 return true;
301 static bool
302 _equalBoolExpr(BoolExpr *a, BoolExpr *b)
304 COMPARE_SCALAR_FIELD(boolop);
305 COMPARE_NODE_FIELD(args);
306 COMPARE_LOCATION_FIELD(location);
308 return true;
311 static bool
312 _equalSubLink(SubLink *a, SubLink *b)
314 COMPARE_SCALAR_FIELD(subLinkType);
315 COMPARE_NODE_FIELD(testexpr);
316 COMPARE_NODE_FIELD(operName);
317 COMPARE_NODE_FIELD(subselect);
318 COMPARE_LOCATION_FIELD(location);
320 return true;
323 static bool
324 _equalSubPlan(SubPlan *a, SubPlan *b)
326 COMPARE_SCALAR_FIELD(subLinkType);
327 COMPARE_NODE_FIELD(testexpr);
328 COMPARE_NODE_FIELD(paramIds);
329 COMPARE_SCALAR_FIELD(plan_id);
330 COMPARE_SCALAR_FIELD(firstColType);
331 COMPARE_SCALAR_FIELD(useHashTable);
332 COMPARE_SCALAR_FIELD(unknownEqFalse);
333 COMPARE_NODE_FIELD(setParam);
334 COMPARE_NODE_FIELD(parParam);
335 COMPARE_NODE_FIELD(args);
336 COMPARE_SCALAR_FIELD(startup_cost);
337 COMPARE_SCALAR_FIELD(per_call_cost);
339 return true;
342 static bool
343 _equalAlternativeSubPlan(AlternativeSubPlan *a, AlternativeSubPlan *b)
345 COMPARE_NODE_FIELD(subplans);
347 return true;
350 static bool
351 _equalFieldSelect(FieldSelect *a, FieldSelect *b)
353 COMPARE_NODE_FIELD(arg);
354 COMPARE_SCALAR_FIELD(fieldnum);
355 COMPARE_SCALAR_FIELD(resulttype);
356 COMPARE_SCALAR_FIELD(resulttypmod);
358 return true;
361 static bool
362 _equalFieldStore(FieldStore *a, FieldStore *b)
364 COMPARE_NODE_FIELD(arg);
365 COMPARE_NODE_FIELD(newvals);
366 COMPARE_NODE_FIELD(fieldnums);
367 COMPARE_SCALAR_FIELD(resulttype);
369 return true;
372 static bool
373 _equalRelabelType(RelabelType *a, RelabelType *b)
375 COMPARE_NODE_FIELD(arg);
376 COMPARE_SCALAR_FIELD(resulttype);
377 COMPARE_SCALAR_FIELD(resulttypmod);
380 * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
381 * that are equal() to both explicit and implicit coercions.
383 if (a->relabelformat != b->relabelformat &&
384 a->relabelformat != COERCE_DONTCARE &&
385 b->relabelformat != COERCE_DONTCARE)
386 return false;
388 COMPARE_LOCATION_FIELD(location);
390 return true;
393 static bool
394 _equalCoerceViaIO(CoerceViaIO *a, CoerceViaIO *b)
396 COMPARE_NODE_FIELD(arg);
397 COMPARE_SCALAR_FIELD(resulttype);
400 * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
401 * that are equal() to both explicit and implicit coercions.
403 if (a->coerceformat != b->coerceformat &&
404 a->coerceformat != COERCE_DONTCARE &&
405 b->coerceformat != COERCE_DONTCARE)
406 return false;
408 COMPARE_LOCATION_FIELD(location);
410 return true;
413 static bool
414 _equalArrayCoerceExpr(ArrayCoerceExpr *a, ArrayCoerceExpr *b)
416 COMPARE_NODE_FIELD(arg);
417 COMPARE_SCALAR_FIELD(elemfuncid);
418 COMPARE_SCALAR_FIELD(resulttype);
419 COMPARE_SCALAR_FIELD(resulttypmod);
420 COMPARE_SCALAR_FIELD(isExplicit);
423 * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
424 * that are equal() to both explicit and implicit coercions.
426 if (a->coerceformat != b->coerceformat &&
427 a->coerceformat != COERCE_DONTCARE &&
428 b->coerceformat != COERCE_DONTCARE)
429 return false;
431 COMPARE_LOCATION_FIELD(location);
433 return true;
436 static bool
437 _equalConvertRowtypeExpr(ConvertRowtypeExpr *a, ConvertRowtypeExpr *b)
439 COMPARE_NODE_FIELD(arg);
440 COMPARE_SCALAR_FIELD(resulttype);
443 * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
444 * that are equal() to both explicit and implicit coercions.
446 if (a->convertformat != b->convertformat &&
447 a->convertformat != COERCE_DONTCARE &&
448 b->convertformat != COERCE_DONTCARE)
449 return false;
451 COMPARE_LOCATION_FIELD(location);
453 return true;
456 static bool
457 _equalCaseExpr(CaseExpr *a, CaseExpr *b)
459 COMPARE_SCALAR_FIELD(casetype);
460 COMPARE_NODE_FIELD(arg);
461 COMPARE_NODE_FIELD(args);
462 COMPARE_NODE_FIELD(defresult);
463 COMPARE_LOCATION_FIELD(location);
465 return true;
468 static bool
469 _equalCaseWhen(CaseWhen *a, CaseWhen *b)
471 COMPARE_NODE_FIELD(expr);
472 COMPARE_NODE_FIELD(result);
473 COMPARE_LOCATION_FIELD(location);
475 return true;
478 static bool
479 _equalCaseTestExpr(CaseTestExpr *a, CaseTestExpr *b)
481 COMPARE_SCALAR_FIELD(typeId);
482 COMPARE_SCALAR_FIELD(typeMod);
484 return true;
487 static bool
488 _equalArrayExpr(ArrayExpr *a, ArrayExpr *b)
490 COMPARE_SCALAR_FIELD(array_typeid);
491 COMPARE_SCALAR_FIELD(element_typeid);
492 COMPARE_NODE_FIELD(elements);
493 COMPARE_SCALAR_FIELD(multidims);
494 COMPARE_LOCATION_FIELD(location);
496 return true;
499 static bool
500 _equalRowExpr(RowExpr *a, RowExpr *b)
502 COMPARE_NODE_FIELD(args);
503 COMPARE_SCALAR_FIELD(row_typeid);
506 * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
507 * that are equal() to both explicit and implicit coercions.
509 if (a->row_format != b->row_format &&
510 a->row_format != COERCE_DONTCARE &&
511 b->row_format != COERCE_DONTCARE)
512 return false;
514 COMPARE_NODE_FIELD(colnames);
515 COMPARE_LOCATION_FIELD(location);
517 return true;
520 static bool
521 _equalRowCompareExpr(RowCompareExpr *a, RowCompareExpr *b)
523 COMPARE_SCALAR_FIELD(rctype);
524 COMPARE_NODE_FIELD(opnos);
525 COMPARE_NODE_FIELD(opfamilies);
526 COMPARE_NODE_FIELD(largs);
527 COMPARE_NODE_FIELD(rargs);
529 return true;
532 static bool
533 _equalCoalesceExpr(CoalesceExpr *a, CoalesceExpr *b)
535 COMPARE_SCALAR_FIELD(coalescetype);
536 COMPARE_NODE_FIELD(args);
537 COMPARE_LOCATION_FIELD(location);
539 return true;
542 static bool
543 _equalMinMaxExpr(MinMaxExpr *a, MinMaxExpr *b)
545 COMPARE_SCALAR_FIELD(minmaxtype);
546 COMPARE_SCALAR_FIELD(op);
547 COMPARE_NODE_FIELD(args);
548 COMPARE_LOCATION_FIELD(location);
550 return true;
553 static bool
554 _equalXmlExpr(XmlExpr *a, XmlExpr *b)
556 COMPARE_SCALAR_FIELD(op);
557 COMPARE_STRING_FIELD(name);
558 COMPARE_NODE_FIELD(named_args);
559 COMPARE_NODE_FIELD(arg_names);
560 COMPARE_NODE_FIELD(args);
561 COMPARE_SCALAR_FIELD(xmloption);
562 COMPARE_SCALAR_FIELD(type);
563 COMPARE_SCALAR_FIELD(typmod);
564 COMPARE_LOCATION_FIELD(location);
566 return true;
569 static bool
570 _equalNullIfExpr(NullIfExpr *a, NullIfExpr *b)
572 COMPARE_SCALAR_FIELD(opno);
575 * Special-case opfuncid: it is allowable for it to differ if one node
576 * contains zero and the other doesn't. This just means that the one node
577 * isn't as far along in the parse/plan pipeline and hasn't had the
578 * opfuncid cache filled yet.
580 if (a->opfuncid != b->opfuncid &&
581 a->opfuncid != 0 &&
582 b->opfuncid != 0)
583 return false;
585 COMPARE_SCALAR_FIELD(opresulttype);
586 COMPARE_SCALAR_FIELD(opretset);
587 COMPARE_NODE_FIELD(args);
588 COMPARE_LOCATION_FIELD(location);
590 return true;
593 static bool
594 _equalNullTest(NullTest *a, NullTest *b)
596 COMPARE_NODE_FIELD(arg);
597 COMPARE_SCALAR_FIELD(nulltesttype);
599 return true;
602 static bool
603 _equalBooleanTest(BooleanTest *a, BooleanTest *b)
605 COMPARE_NODE_FIELD(arg);
606 COMPARE_SCALAR_FIELD(booltesttype);
608 return true;
611 static bool
612 _equalCoerceToDomain(CoerceToDomain *a, CoerceToDomain *b)
614 COMPARE_NODE_FIELD(arg);
615 COMPARE_SCALAR_FIELD(resulttype);
616 COMPARE_SCALAR_FIELD(resulttypmod);
619 * Special-case COERCE_DONTCARE, so that planner can build coercion nodes
620 * that are equal() to both explicit and implicit coercions.
622 if (a->coercionformat != b->coercionformat &&
623 a->coercionformat != COERCE_DONTCARE &&
624 b->coercionformat != COERCE_DONTCARE)
625 return false;
627 COMPARE_LOCATION_FIELD(location);
629 return true;
632 static bool
633 _equalCoerceToDomainValue(CoerceToDomainValue *a, CoerceToDomainValue *b)
635 COMPARE_SCALAR_FIELD(typeId);
636 COMPARE_SCALAR_FIELD(typeMod);
637 COMPARE_LOCATION_FIELD(location);
639 return true;
642 static bool
643 _equalSetToDefault(SetToDefault *a, SetToDefault *b)
645 COMPARE_SCALAR_FIELD(typeId);
646 COMPARE_SCALAR_FIELD(typeMod);
647 COMPARE_LOCATION_FIELD(location);
649 return true;
652 static bool
653 _equalCurrentOfExpr(CurrentOfExpr *a, CurrentOfExpr *b)
655 COMPARE_SCALAR_FIELD(cvarno);
656 COMPARE_STRING_FIELD(cursor_name);
657 COMPARE_SCALAR_FIELD(cursor_param);
659 return true;
662 static bool
663 _equalTargetEntry(TargetEntry *a, TargetEntry *b)
665 COMPARE_NODE_FIELD(expr);
666 COMPARE_SCALAR_FIELD(resno);
667 COMPARE_STRING_FIELD(resname);
668 COMPARE_SCALAR_FIELD(ressortgroupref);
669 COMPARE_SCALAR_FIELD(resorigtbl);
670 COMPARE_SCALAR_FIELD(resorigcol);
671 COMPARE_SCALAR_FIELD(resjunk);
673 return true;
676 static bool
677 _equalRangeTblRef(RangeTblRef *a, RangeTblRef *b)
679 COMPARE_SCALAR_FIELD(rtindex);
681 return true;
684 static bool
685 _equalJoinExpr(JoinExpr *a, JoinExpr *b)
687 COMPARE_SCALAR_FIELD(jointype);
688 COMPARE_SCALAR_FIELD(isNatural);
689 COMPARE_NODE_FIELD(larg);
690 COMPARE_NODE_FIELD(rarg);
691 COMPARE_NODE_FIELD(using);
692 COMPARE_NODE_FIELD(quals);
693 COMPARE_NODE_FIELD(alias);
694 COMPARE_SCALAR_FIELD(rtindex);
696 return true;
699 static bool
700 _equalFromExpr(FromExpr *a, FromExpr *b)
702 COMPARE_NODE_FIELD(fromlist);
703 COMPARE_NODE_FIELD(quals);
705 return true;
710 * Stuff from relation.h
713 static bool
714 _equalPathKey(PathKey *a, PathKey *b)
717 * This is normally used on non-canonicalized PathKeys, so must chase up
718 * to the topmost merged EquivalenceClass and see if those are the same
719 * (by pointer equality).
721 EquivalenceClass *a_eclass;
722 EquivalenceClass *b_eclass;
724 a_eclass = a->pk_eclass;
725 while (a_eclass->ec_merged)
726 a_eclass = a_eclass->ec_merged;
727 b_eclass = b->pk_eclass;
728 while (b_eclass->ec_merged)
729 b_eclass = b_eclass->ec_merged;
730 if (a_eclass != b_eclass)
731 return false;
732 COMPARE_SCALAR_FIELD(pk_opfamily);
733 COMPARE_SCALAR_FIELD(pk_strategy);
734 COMPARE_SCALAR_FIELD(pk_nulls_first);
736 return true;
739 static bool
740 _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
742 COMPARE_NODE_FIELD(clause);
743 COMPARE_SCALAR_FIELD(is_pushed_down);
744 COMPARE_SCALAR_FIELD(outerjoin_delayed);
745 COMPARE_BITMAPSET_FIELD(required_relids);
748 * We ignore all the remaining fields, since they may not be set yet, and
749 * should be derivable from the clause anyway.
752 return true;
755 static bool
756 _equalFlattenedSubLink(FlattenedSubLink *a, FlattenedSubLink *b)
758 COMPARE_SCALAR_FIELD(jointype);
759 COMPARE_BITMAPSET_FIELD(lefthand);
760 COMPARE_BITMAPSET_FIELD(righthand);
761 COMPARE_NODE_FIELD(quals);
763 return true;
766 static bool
767 _equalPlaceHolderVar(PlaceHolderVar *a, PlaceHolderVar *b)
770 * We intentionally do not compare phexpr. Two PlaceHolderVars with the
771 * same ID and levelsup should be considered equal even if the contained
772 * expressions have managed to mutate to different states. One way in
773 * which that can happen is that initplan sublinks would get replaced by
774 * differently-numbered Params when sublink folding is done. (The end
775 * result of such a situation would be some unreferenced initplans, which
776 * is annoying but not really a problem.)
778 * COMPARE_NODE_FIELD(phexpr);
780 COMPARE_BITMAPSET_FIELD(phrels);
781 COMPARE_SCALAR_FIELD(phid);
782 COMPARE_SCALAR_FIELD(phlevelsup);
784 return true;
787 static bool
788 _equalSpecialJoinInfo(SpecialJoinInfo *a, SpecialJoinInfo *b)
790 COMPARE_BITMAPSET_FIELD(min_lefthand);
791 COMPARE_BITMAPSET_FIELD(min_righthand);
792 COMPARE_BITMAPSET_FIELD(syn_lefthand);
793 COMPARE_BITMAPSET_FIELD(syn_righthand);
794 COMPARE_SCALAR_FIELD(jointype);
795 COMPARE_SCALAR_FIELD(lhs_strict);
796 COMPARE_SCALAR_FIELD(delay_upper_joins);
797 COMPARE_NODE_FIELD(join_quals);
799 return true;
802 static bool
803 _equalAppendRelInfo(AppendRelInfo *a, AppendRelInfo *b)
805 COMPARE_SCALAR_FIELD(parent_relid);
806 COMPARE_SCALAR_FIELD(child_relid);
807 COMPARE_SCALAR_FIELD(parent_reltype);
808 COMPARE_SCALAR_FIELD(child_reltype);
809 COMPARE_NODE_FIELD(col_mappings);
810 COMPARE_NODE_FIELD(translated_vars);
811 COMPARE_SCALAR_FIELD(parent_reloid);
813 return true;
816 static bool
817 _equalPlaceHolderInfo(PlaceHolderInfo *a, PlaceHolderInfo *b)
819 COMPARE_SCALAR_FIELD(phid);
820 COMPARE_NODE_FIELD(ph_var);
821 COMPARE_BITMAPSET_FIELD(ph_eval_at);
822 COMPARE_BITMAPSET_FIELD(ph_needed);
823 COMPARE_SCALAR_FIELD(ph_width);
825 return true;
830 * Stuff from parsenodes.h
833 static bool
834 _equalQuery(Query *a, Query *b)
836 COMPARE_SCALAR_FIELD(commandType);
837 COMPARE_SCALAR_FIELD(querySource);
838 COMPARE_SCALAR_FIELD(canSetTag);
839 COMPARE_NODE_FIELD(utilityStmt);
840 COMPARE_SCALAR_FIELD(resultRelation);
841 COMPARE_NODE_FIELD(intoClause);
842 COMPARE_SCALAR_FIELD(hasAggs);
843 COMPARE_SCALAR_FIELD(hasSubLinks);
844 COMPARE_SCALAR_FIELD(hasDistinctOn);
845 COMPARE_SCALAR_FIELD(hasRecursive);
846 COMPARE_NODE_FIELD(cteList);
847 COMPARE_NODE_FIELD(rtable);
848 COMPARE_NODE_FIELD(jointree);
849 COMPARE_NODE_FIELD(targetList);
850 COMPARE_NODE_FIELD(returningList);
851 COMPARE_NODE_FIELD(groupClause);
852 COMPARE_NODE_FIELD(havingQual);
853 COMPARE_NODE_FIELD(distinctClause);
854 COMPARE_NODE_FIELD(sortClause);
855 COMPARE_NODE_FIELD(limitOffset);
856 COMPARE_NODE_FIELD(limitCount);
857 COMPARE_NODE_FIELD(rowMarks);
858 COMPARE_NODE_FIELD(setOperations);
860 return true;
863 static bool
864 _equalInsertStmt(InsertStmt *a, InsertStmt *b)
866 COMPARE_NODE_FIELD(relation);
867 COMPARE_NODE_FIELD(cols);
868 COMPARE_NODE_FIELD(selectStmt);
869 COMPARE_NODE_FIELD(returningList);
871 return true;
874 static bool
875 _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
877 COMPARE_NODE_FIELD(relation);
878 COMPARE_NODE_FIELD(usingClause);
879 COMPARE_NODE_FIELD(whereClause);
880 COMPARE_NODE_FIELD(returningList);
882 return true;
885 static bool
886 _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
888 COMPARE_NODE_FIELD(relation);
889 COMPARE_NODE_FIELD(targetList);
890 COMPARE_NODE_FIELD(whereClause);
891 COMPARE_NODE_FIELD(fromClause);
892 COMPARE_NODE_FIELD(returningList);
894 return true;
897 static bool
898 _equalSelectStmt(SelectStmt *a, SelectStmt *b)
900 COMPARE_NODE_FIELD(distinctClause);
901 COMPARE_NODE_FIELD(intoClause);
902 COMPARE_NODE_FIELD(targetList);
903 COMPARE_NODE_FIELD(fromClause);
904 COMPARE_NODE_FIELD(whereClause);
905 COMPARE_NODE_FIELD(groupClause);
906 COMPARE_NODE_FIELD(havingClause);
907 COMPARE_NODE_FIELD(withClause);
908 COMPARE_NODE_FIELD(valuesLists);
909 COMPARE_NODE_FIELD(sortClause);
910 COMPARE_NODE_FIELD(limitOffset);
911 COMPARE_NODE_FIELD(limitCount);
912 COMPARE_NODE_FIELD(lockingClause);
913 COMPARE_SCALAR_FIELD(op);
914 COMPARE_SCALAR_FIELD(all);
915 COMPARE_NODE_FIELD(larg);
916 COMPARE_NODE_FIELD(rarg);
918 return true;
921 static bool
922 _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b)
924 COMPARE_SCALAR_FIELD(op);
925 COMPARE_SCALAR_FIELD(all);
926 COMPARE_NODE_FIELD(larg);
927 COMPARE_NODE_FIELD(rarg);
928 COMPARE_NODE_FIELD(colTypes);
929 COMPARE_NODE_FIELD(colTypmods);
930 COMPARE_NODE_FIELD(groupClauses);
932 return true;
935 static bool
936 _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
938 COMPARE_NODE_FIELD(relation);
939 COMPARE_NODE_FIELD(cmds);
940 COMPARE_SCALAR_FIELD(relkind);
942 return true;
945 static bool
946 _equalAlterTableCmd(AlterTableCmd *a, AlterTableCmd *b)
948 COMPARE_SCALAR_FIELD(subtype);
949 COMPARE_STRING_FIELD(name);
950 COMPARE_NODE_FIELD(def);
951 COMPARE_NODE_FIELD(transform);
952 COMPARE_SCALAR_FIELD(behavior);
954 return true;
957 static bool
958 _equalAlterDomainStmt(AlterDomainStmt *a, AlterDomainStmt *b)
960 COMPARE_SCALAR_FIELD(subtype);
961 COMPARE_NODE_FIELD(typename);
962 COMPARE_STRING_FIELD(name);
963 COMPARE_NODE_FIELD(def);
964 COMPARE_SCALAR_FIELD(behavior);
966 return true;
969 static bool
970 _equalGrantStmt(GrantStmt *a, GrantStmt *b)
972 COMPARE_SCALAR_FIELD(is_grant);
973 COMPARE_SCALAR_FIELD(objtype);
974 COMPARE_NODE_FIELD(objects);
975 COMPARE_NODE_FIELD(privileges);
976 COMPARE_NODE_FIELD(grantees);
977 COMPARE_SCALAR_FIELD(grant_option);
978 COMPARE_SCALAR_FIELD(behavior);
980 return true;
983 static bool
984 _equalPrivGrantee(PrivGrantee *a, PrivGrantee *b)
986 COMPARE_STRING_FIELD(rolname);
988 return true;
991 static bool
992 _equalFuncWithArgs(FuncWithArgs *a, FuncWithArgs *b)
994 COMPARE_NODE_FIELD(funcname);
995 COMPARE_NODE_FIELD(funcargs);
997 return true;
1000 static bool
1001 _equalGrantRoleStmt(GrantRoleStmt *a, GrantRoleStmt *b)
1003 COMPARE_NODE_FIELD(granted_roles);
1004 COMPARE_NODE_FIELD(grantee_roles);
1005 COMPARE_SCALAR_FIELD(is_grant);
1006 COMPARE_SCALAR_FIELD(admin_opt);
1007 COMPARE_STRING_FIELD(grantor);
1008 COMPARE_SCALAR_FIELD(behavior);
1010 return true;
1013 static bool
1014 _equalDeclareCursorStmt(DeclareCursorStmt *a, DeclareCursorStmt *b)
1016 COMPARE_STRING_FIELD(portalname);
1017 COMPARE_SCALAR_FIELD(options);
1018 COMPARE_NODE_FIELD(query);
1020 return true;
1023 static bool
1024 _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
1026 COMPARE_STRING_FIELD(portalname);
1028 return true;
1031 static bool
1032 _equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
1034 COMPARE_NODE_FIELD(relation);
1035 COMPARE_STRING_FIELD(indexname);
1037 return true;
1040 static bool
1041 _equalCopyStmt(CopyStmt *a, CopyStmt *b)
1043 COMPARE_NODE_FIELD(relation);
1044 COMPARE_NODE_FIELD(query);
1045 COMPARE_NODE_FIELD(attlist);
1046 COMPARE_SCALAR_FIELD(is_from);
1047 COMPARE_STRING_FIELD(filename);
1048 COMPARE_NODE_FIELD(options);
1050 return true;
1053 static bool
1054 _equalCreateStmt(CreateStmt *a, CreateStmt *b)
1056 COMPARE_NODE_FIELD(relation);
1057 COMPARE_NODE_FIELD(tableElts);
1058 COMPARE_NODE_FIELD(inhRelations);
1059 COMPARE_NODE_FIELD(constraints);
1060 COMPARE_NODE_FIELD(options);
1061 COMPARE_SCALAR_FIELD(oncommit);
1062 COMPARE_STRING_FIELD(tablespacename);
1064 return true;
1067 static bool
1068 _equalInhRelation(InhRelation *a, InhRelation *b)
1070 COMPARE_NODE_FIELD(relation);
1071 COMPARE_NODE_FIELD(options);
1073 return true;
1076 static bool
1077 _equalDefineStmt(DefineStmt *a, DefineStmt *b)
1079 COMPARE_SCALAR_FIELD(kind);
1080 COMPARE_SCALAR_FIELD(oldstyle);
1081 COMPARE_NODE_FIELD(defnames);
1082 COMPARE_NODE_FIELD(args);
1083 COMPARE_NODE_FIELD(definition);
1085 return true;
1088 static bool
1089 _equalDropStmt(DropStmt *a, DropStmt *b)
1091 COMPARE_NODE_FIELD(objects);
1092 COMPARE_SCALAR_FIELD(removeType);
1093 COMPARE_SCALAR_FIELD(behavior);
1094 COMPARE_SCALAR_FIELD(missing_ok);
1096 return true;
1099 static bool
1100 _equalTruncateStmt(TruncateStmt *a, TruncateStmt *b)
1102 COMPARE_NODE_FIELD(relations);
1103 COMPARE_SCALAR_FIELD(restart_seqs);
1104 COMPARE_SCALAR_FIELD(behavior);
1106 return true;
1109 static bool
1110 _equalCommentStmt(CommentStmt *a, CommentStmt *b)
1112 COMPARE_SCALAR_FIELD(objtype);
1113 COMPARE_NODE_FIELD(objname);
1114 COMPARE_NODE_FIELD(objargs);
1115 COMPARE_STRING_FIELD(comment);
1117 return true;
1120 static bool
1121 _equalFetchStmt(FetchStmt *a, FetchStmt *b)
1123 COMPARE_SCALAR_FIELD(direction);
1124 COMPARE_SCALAR_FIELD(howMany);
1125 COMPARE_STRING_FIELD(portalname);
1126 COMPARE_SCALAR_FIELD(ismove);
1128 return true;
1131 static bool
1132 _equalIndexStmt(IndexStmt *a, IndexStmt *b)
1134 COMPARE_STRING_FIELD(idxname);
1135 COMPARE_NODE_FIELD(relation);
1136 COMPARE_STRING_FIELD(accessMethod);
1137 COMPARE_STRING_FIELD(tableSpace);
1138 COMPARE_NODE_FIELD(indexParams);
1139 COMPARE_NODE_FIELD(options);
1140 COMPARE_NODE_FIELD(whereClause);
1141 COMPARE_SCALAR_FIELD(unique);
1142 COMPARE_SCALAR_FIELD(primary);
1143 COMPARE_SCALAR_FIELD(isconstraint);
1144 COMPARE_SCALAR_FIELD(concurrent);
1146 return true;
1149 static bool
1150 _equalCreateFunctionStmt(CreateFunctionStmt *a, CreateFunctionStmt *b)
1152 COMPARE_SCALAR_FIELD(replace);
1153 COMPARE_NODE_FIELD(funcname);
1154 COMPARE_NODE_FIELD(parameters);
1155 COMPARE_NODE_FIELD(returnType);
1156 COMPARE_NODE_FIELD(options);
1157 COMPARE_NODE_FIELD(withClause);
1159 return true;
1162 static bool
1163 _equalFunctionParameter(FunctionParameter *a, FunctionParameter *b)
1165 COMPARE_STRING_FIELD(name);
1166 COMPARE_NODE_FIELD(argType);
1167 COMPARE_SCALAR_FIELD(mode);
1169 return true;
1172 static bool
1173 _equalAlterFunctionStmt(AlterFunctionStmt *a, AlterFunctionStmt *b)
1175 COMPARE_NODE_FIELD(func);
1176 COMPARE_NODE_FIELD(actions);
1178 return true;
1181 static bool
1182 _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b)
1184 COMPARE_SCALAR_FIELD(kind);
1185 COMPARE_NODE_FIELD(name);
1186 COMPARE_NODE_FIELD(args);
1187 COMPARE_SCALAR_FIELD(behavior);
1188 COMPARE_SCALAR_FIELD(missing_ok);
1190 return true;
1193 static bool
1194 _equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b)
1196 COMPARE_NODE_FIELD(opclassname);
1197 COMPARE_STRING_FIELD(amname);
1198 COMPARE_SCALAR_FIELD(behavior);
1199 COMPARE_SCALAR_FIELD(missing_ok);
1201 return true;
1204 static bool
1205 _equalRemoveOpFamilyStmt(RemoveOpFamilyStmt *a, RemoveOpFamilyStmt *b)
1207 COMPARE_NODE_FIELD(opfamilyname);
1208 COMPARE_STRING_FIELD(amname);
1209 COMPARE_SCALAR_FIELD(behavior);
1210 COMPARE_SCALAR_FIELD(missing_ok);
1212 return true;
1215 static bool
1216 _equalRenameStmt(RenameStmt *a, RenameStmt *b)
1218 COMPARE_SCALAR_FIELD(renameType);
1219 COMPARE_NODE_FIELD(relation);
1220 COMPARE_NODE_FIELD(object);
1221 COMPARE_NODE_FIELD(objarg);
1222 COMPARE_STRING_FIELD(subname);
1223 COMPARE_STRING_FIELD(newname);
1225 return true;
1228 static bool
1229 _equalAlterObjectSchemaStmt(AlterObjectSchemaStmt *a, AlterObjectSchemaStmt *b)
1231 COMPARE_SCALAR_FIELD(objectType);
1232 COMPARE_NODE_FIELD(relation);
1233 COMPARE_NODE_FIELD(object);
1234 COMPARE_NODE_FIELD(objarg);
1235 COMPARE_STRING_FIELD(addname);
1236 COMPARE_STRING_FIELD(newschema);
1238 return true;
1241 static bool
1242 _equalAlterOwnerStmt(AlterOwnerStmt *a, AlterOwnerStmt *b)
1244 COMPARE_SCALAR_FIELD(objectType);
1245 COMPARE_NODE_FIELD(relation);
1246 COMPARE_NODE_FIELD(object);
1247 COMPARE_NODE_FIELD(objarg);
1248 COMPARE_STRING_FIELD(addname);
1249 COMPARE_STRING_FIELD(newowner);
1251 return true;
1254 static bool
1255 _equalRuleStmt(RuleStmt *a, RuleStmt *b)
1257 COMPARE_NODE_FIELD(relation);
1258 COMPARE_STRING_FIELD(rulename);
1259 COMPARE_NODE_FIELD(whereClause);
1260 COMPARE_SCALAR_FIELD(event);
1261 COMPARE_SCALAR_FIELD(instead);
1262 COMPARE_NODE_FIELD(actions);
1263 COMPARE_SCALAR_FIELD(replace);
1265 return true;
1268 static bool
1269 _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
1271 COMPARE_STRING_FIELD(conditionname);
1273 return true;
1276 static bool
1277 _equalListenStmt(ListenStmt *a, ListenStmt *b)
1279 COMPARE_STRING_FIELD(conditionname);
1281 return true;
1284 static bool
1285 _equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
1287 COMPARE_STRING_FIELD(conditionname);
1289 return true;
1292 static bool
1293 _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
1295 COMPARE_SCALAR_FIELD(kind);
1296 COMPARE_NODE_FIELD(options);
1297 COMPARE_STRING_FIELD(gid);
1299 return true;
1302 static bool
1303 _equalCompositeTypeStmt(CompositeTypeStmt *a, CompositeTypeStmt *b)
1305 COMPARE_NODE_FIELD(typevar);
1306 COMPARE_NODE_FIELD(coldeflist);
1308 return true;
1311 static bool
1312 _equalCreateEnumStmt(CreateEnumStmt *a, CreateEnumStmt *b)
1314 COMPARE_NODE_FIELD(typename);
1315 COMPARE_NODE_FIELD(vals);
1317 return true;
1320 static bool
1321 _equalViewStmt(ViewStmt *a, ViewStmt *b)
1323 COMPARE_NODE_FIELD(view);
1324 COMPARE_NODE_FIELD(aliases);
1325 COMPARE_NODE_FIELD(query);
1326 COMPARE_SCALAR_FIELD(replace);
1328 return true;
1331 static bool
1332 _equalLoadStmt(LoadStmt *a, LoadStmt *b)
1334 COMPARE_STRING_FIELD(filename);
1336 return true;
1339 static bool
1340 _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b)
1342 COMPARE_NODE_FIELD(domainname);
1343 COMPARE_NODE_FIELD(typename);
1344 COMPARE_NODE_FIELD(constraints);
1346 return true;
1349 static bool
1350 _equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b)
1352 COMPARE_NODE_FIELD(opclassname);
1353 COMPARE_NODE_FIELD(opfamilyname);
1354 COMPARE_STRING_FIELD(amname);
1355 COMPARE_NODE_FIELD(datatype);
1356 COMPARE_NODE_FIELD(items);
1357 COMPARE_SCALAR_FIELD(isDefault);
1359 return true;
1362 static bool
1363 _equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b)
1365 COMPARE_SCALAR_FIELD(itemtype);
1366 COMPARE_NODE_FIELD(name);
1367 COMPARE_NODE_FIELD(args);
1368 COMPARE_SCALAR_FIELD(number);
1369 COMPARE_NODE_FIELD(class_args);
1370 COMPARE_NODE_FIELD(storedtype);
1372 return true;
1375 static bool
1376 _equalCreateOpFamilyStmt(CreateOpFamilyStmt *a, CreateOpFamilyStmt *b)
1378 COMPARE_NODE_FIELD(opfamilyname);
1379 COMPARE_STRING_FIELD(amname);
1381 return true;
1384 static bool
1385 _equalAlterOpFamilyStmt(AlterOpFamilyStmt *a, AlterOpFamilyStmt *b)
1387 COMPARE_NODE_FIELD(opfamilyname);
1388 COMPARE_STRING_FIELD(amname);
1389 COMPARE_SCALAR_FIELD(isDrop);
1390 COMPARE_NODE_FIELD(items);
1392 return true;
1395 static bool
1396 _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
1398 COMPARE_STRING_FIELD(dbname);
1399 COMPARE_NODE_FIELD(options);
1401 return true;
1404 static bool
1405 _equalAlterDatabaseStmt(AlterDatabaseStmt *a, AlterDatabaseStmt *b)
1407 COMPARE_STRING_FIELD(dbname);
1408 COMPARE_NODE_FIELD(options);
1410 return true;
1413 static bool
1414 _equalAlterDatabaseSetStmt(AlterDatabaseSetStmt *a, AlterDatabaseSetStmt *b)
1416 COMPARE_STRING_FIELD(dbname);
1417 COMPARE_NODE_FIELD(setstmt);
1419 return true;
1422 static bool
1423 _equalDropdbStmt(DropdbStmt *a, DropdbStmt *b)
1425 COMPARE_STRING_FIELD(dbname);
1426 COMPARE_SCALAR_FIELD(missing_ok);
1428 return true;
1431 static bool
1432 _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
1434 COMPARE_SCALAR_FIELD(vacuum);
1435 COMPARE_SCALAR_FIELD(full);
1436 COMPARE_SCALAR_FIELD(analyze);
1437 COMPARE_SCALAR_FIELD(verbose);
1438 COMPARE_SCALAR_FIELD(freeze_min_age);
1439 COMPARE_NODE_FIELD(relation);
1440 COMPARE_NODE_FIELD(va_cols);
1442 return true;
1445 static bool
1446 _equalExplainStmt(ExplainStmt *a, ExplainStmt *b)
1448 COMPARE_NODE_FIELD(query);
1449 COMPARE_SCALAR_FIELD(verbose);
1450 COMPARE_SCALAR_FIELD(analyze);
1452 return true;
1455 static bool
1456 _equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b)
1458 COMPARE_NODE_FIELD(sequence);
1459 COMPARE_NODE_FIELD(options);
1461 return true;
1464 static bool
1465 _equalAlterSeqStmt(AlterSeqStmt *a, AlterSeqStmt *b)
1467 COMPARE_NODE_FIELD(sequence);
1468 COMPARE_NODE_FIELD(options);
1470 return true;
1473 static bool
1474 _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
1476 COMPARE_SCALAR_FIELD(kind);
1477 COMPARE_STRING_FIELD(name);
1478 COMPARE_NODE_FIELD(args);
1479 COMPARE_SCALAR_FIELD(is_local);
1481 return true;
1484 static bool
1485 _equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b)
1487 COMPARE_STRING_FIELD(name);
1489 return true;
1492 static bool
1493 _equalDiscardStmt(DiscardStmt *a, DiscardStmt *b)
1495 COMPARE_SCALAR_FIELD(target);
1497 return true;
1500 static bool
1501 _equalCreateTableSpaceStmt(CreateTableSpaceStmt *a, CreateTableSpaceStmt *b)
1503 COMPARE_STRING_FIELD(tablespacename);
1504 COMPARE_STRING_FIELD(owner);
1505 COMPARE_STRING_FIELD(location);
1507 return true;
1510 static bool
1511 _equalDropTableSpaceStmt(DropTableSpaceStmt *a, DropTableSpaceStmt *b)
1513 COMPARE_STRING_FIELD(tablespacename);
1514 COMPARE_SCALAR_FIELD(missing_ok);
1516 return true;
1519 static bool
1520 _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b)
1522 COMPARE_STRING_FIELD(trigname);
1523 COMPARE_NODE_FIELD(relation);
1524 COMPARE_NODE_FIELD(funcname);
1525 COMPARE_NODE_FIELD(args);
1526 COMPARE_SCALAR_FIELD(before);
1527 COMPARE_SCALAR_FIELD(row);
1528 if (strcmp(a->actions, b->actions) != 0) /* in-line string field */
1529 return false;
1530 COMPARE_SCALAR_FIELD(isconstraint);
1531 COMPARE_SCALAR_FIELD(deferrable);
1532 COMPARE_SCALAR_FIELD(initdeferred);
1533 COMPARE_NODE_FIELD(constrrel);
1535 return true;
1538 static bool
1539 _equalDropPropertyStmt(DropPropertyStmt *a, DropPropertyStmt *b)
1541 COMPARE_NODE_FIELD(relation);
1542 COMPARE_STRING_FIELD(property);
1543 COMPARE_SCALAR_FIELD(removeType);
1544 COMPARE_SCALAR_FIELD(behavior);
1545 COMPARE_SCALAR_FIELD(missing_ok);
1547 return true;
1550 static bool
1551 _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b)
1553 COMPARE_STRING_FIELD(plname);
1554 COMPARE_NODE_FIELD(plhandler);
1555 COMPARE_NODE_FIELD(plvalidator);
1556 COMPARE_SCALAR_FIELD(pltrusted);
1558 return true;
1561 static bool
1562 _equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b)
1564 COMPARE_STRING_FIELD(plname);
1565 COMPARE_SCALAR_FIELD(behavior);
1566 COMPARE_SCALAR_FIELD(missing_ok);
1568 return true;
1571 static bool
1572 _equalCreateRoleStmt(CreateRoleStmt *a, CreateRoleStmt *b)
1574 COMPARE_SCALAR_FIELD(stmt_type);
1575 COMPARE_STRING_FIELD(role);
1576 COMPARE_NODE_FIELD(options);
1578 return true;
1581 static bool
1582 _equalAlterRoleStmt(AlterRoleStmt *a, AlterRoleStmt *b)
1584 COMPARE_STRING_FIELD(role);
1585 COMPARE_NODE_FIELD(options);
1586 COMPARE_SCALAR_FIELD(action);
1588 return true;
1591 static bool
1592 _equalAlterRoleSetStmt(AlterRoleSetStmt *a, AlterRoleSetStmt *b)
1594 COMPARE_STRING_FIELD(role);
1595 COMPARE_NODE_FIELD(setstmt);
1597 return true;
1600 static bool
1601 _equalDropRoleStmt(DropRoleStmt *a, DropRoleStmt *b)
1603 COMPARE_NODE_FIELD(roles);
1604 COMPARE_SCALAR_FIELD(missing_ok);
1606 return true;
1609 static bool
1610 _equalLockStmt(LockStmt *a, LockStmt *b)
1612 COMPARE_NODE_FIELD(relations);
1613 COMPARE_SCALAR_FIELD(mode);
1614 COMPARE_SCALAR_FIELD(nowait);
1616 return true;
1619 static bool
1620 _equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b)
1622 COMPARE_NODE_FIELD(constraints);
1623 COMPARE_SCALAR_FIELD(deferred);
1625 return true;
1628 static bool
1629 _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
1631 COMPARE_SCALAR_FIELD(kind);
1632 COMPARE_NODE_FIELD(relation);
1633 COMPARE_STRING_FIELD(name);
1634 COMPARE_SCALAR_FIELD(do_system);
1635 COMPARE_SCALAR_FIELD(do_user);
1637 return true;
1640 static bool
1641 _equalCreateSchemaStmt(CreateSchemaStmt *a, CreateSchemaStmt *b)
1643 COMPARE_STRING_FIELD(schemaname);
1644 COMPARE_STRING_FIELD(authid);
1645 COMPARE_NODE_FIELD(schemaElts);
1647 return true;
1650 static bool
1651 _equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b)
1653 COMPARE_NODE_FIELD(conversion_name);
1654 COMPARE_STRING_FIELD(for_encoding_name);
1655 COMPARE_STRING_FIELD(to_encoding_name);
1656 COMPARE_NODE_FIELD(func_name);
1657 COMPARE_SCALAR_FIELD(def);
1659 return true;
1662 static bool
1663 _equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b)
1665 COMPARE_NODE_FIELD(sourcetype);
1666 COMPARE_NODE_FIELD(targettype);
1667 COMPARE_NODE_FIELD(func);
1668 COMPARE_SCALAR_FIELD(context);
1669 COMPARE_SCALAR_FIELD(inout);
1671 return true;
1674 static bool
1675 _equalDropCastStmt(DropCastStmt *a, DropCastStmt *b)
1677 COMPARE_NODE_FIELD(sourcetype);
1678 COMPARE_NODE_FIELD(targettype);
1679 COMPARE_SCALAR_FIELD(behavior);
1680 COMPARE_SCALAR_FIELD(missing_ok);
1682 return true;
1685 static bool
1686 _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b)
1688 COMPARE_STRING_FIELD(name);
1689 COMPARE_NODE_FIELD(argtypes);
1690 COMPARE_NODE_FIELD(query);
1692 return true;
1695 static bool
1696 _equalExecuteStmt(ExecuteStmt *a, ExecuteStmt *b)
1698 COMPARE_STRING_FIELD(name);
1699 COMPARE_NODE_FIELD(into);
1700 COMPARE_NODE_FIELD(params);
1702 return true;
1705 static bool
1706 _equalDeallocateStmt(DeallocateStmt *a, DeallocateStmt *b)
1708 COMPARE_STRING_FIELD(name);
1710 return true;
1713 static bool
1714 _equalDropOwnedStmt(DropOwnedStmt *a, DropOwnedStmt *b)
1716 COMPARE_NODE_FIELD(roles);
1717 COMPARE_SCALAR_FIELD(behavior);
1719 return true;
1722 static bool
1723 _equalReassignOwnedStmt(ReassignOwnedStmt *a, ReassignOwnedStmt *b)
1725 COMPARE_NODE_FIELD(roles);
1726 COMPARE_NODE_FIELD(newrole);
1728 return true;
1731 static bool
1732 _equalAlterTSDictionaryStmt(AlterTSDictionaryStmt *a, AlterTSDictionaryStmt *b)
1734 COMPARE_NODE_FIELD(dictname);
1735 COMPARE_NODE_FIELD(options);
1737 return true;
1740 static bool
1741 _equalAlterTSConfigurationStmt(AlterTSConfigurationStmt *a,
1742 AlterTSConfigurationStmt *b)
1744 COMPARE_NODE_FIELD(cfgname);
1745 COMPARE_NODE_FIELD(tokentype);
1746 COMPARE_NODE_FIELD(dicts);
1747 COMPARE_SCALAR_FIELD(override);
1748 COMPARE_SCALAR_FIELD(replace);
1749 COMPARE_SCALAR_FIELD(missing_ok);
1751 return true;
1754 static bool
1755 _equalAExpr(A_Expr *a, A_Expr *b)
1757 COMPARE_SCALAR_FIELD(kind);
1758 COMPARE_NODE_FIELD(name);
1759 COMPARE_NODE_FIELD(lexpr);
1760 COMPARE_NODE_FIELD(rexpr);
1761 COMPARE_LOCATION_FIELD(location);
1763 return true;
1766 static bool
1767 _equalColumnRef(ColumnRef *a, ColumnRef *b)
1769 COMPARE_NODE_FIELD(fields);
1770 COMPARE_LOCATION_FIELD(location);
1772 return true;
1775 static bool
1776 _equalParamRef(ParamRef *a, ParamRef *b)
1778 COMPARE_SCALAR_FIELD(number);
1779 COMPARE_LOCATION_FIELD(location);
1781 return true;
1784 static bool
1785 _equalAConst(A_Const *a, A_Const *b)
1787 if (!equal(&a->val, &b->val)) /* hack for in-line Value field */
1788 return false;
1789 COMPARE_LOCATION_FIELD(location);
1791 return true;
1794 static bool
1795 _equalFuncCall(FuncCall *a, FuncCall *b)
1797 COMPARE_NODE_FIELD(funcname);
1798 COMPARE_NODE_FIELD(args);
1799 COMPARE_SCALAR_FIELD(agg_star);
1800 COMPARE_SCALAR_FIELD(agg_distinct);
1801 COMPARE_SCALAR_FIELD(func_variadic);
1802 COMPARE_LOCATION_FIELD(location);
1804 return true;
1807 static bool
1808 _equalAStar(A_Star *a, A_Star *b)
1810 return true;
1813 static bool
1814 _equalAIndices(A_Indices *a, A_Indices *b)
1816 COMPARE_NODE_FIELD(lidx);
1817 COMPARE_NODE_FIELD(uidx);
1819 return true;
1822 static bool
1823 _equalA_Indirection(A_Indirection *a, A_Indirection *b)
1825 COMPARE_NODE_FIELD(arg);
1826 COMPARE_NODE_FIELD(indirection);
1828 return true;
1831 static bool
1832 _equalA_ArrayExpr(A_ArrayExpr *a, A_ArrayExpr *b)
1834 COMPARE_NODE_FIELD(elements);
1835 COMPARE_LOCATION_FIELD(location);
1837 return true;
1840 static bool
1841 _equalResTarget(ResTarget *a, ResTarget *b)
1843 COMPARE_STRING_FIELD(name);
1844 COMPARE_NODE_FIELD(indirection);
1845 COMPARE_NODE_FIELD(val);
1846 COMPARE_LOCATION_FIELD(location);
1848 return true;
1851 static bool
1852 _equalTypeName(TypeName *a, TypeName *b)
1854 COMPARE_NODE_FIELD(names);
1855 COMPARE_SCALAR_FIELD(typeid);
1856 COMPARE_SCALAR_FIELD(setof);
1857 COMPARE_SCALAR_FIELD(pct_type);
1858 COMPARE_NODE_FIELD(typmods);
1859 COMPARE_SCALAR_FIELD(typemod);
1860 COMPARE_NODE_FIELD(arrayBounds);
1861 COMPARE_LOCATION_FIELD(location);
1863 return true;
1866 static bool
1867 _equalTypeCast(TypeCast *a, TypeCast *b)
1869 COMPARE_NODE_FIELD(arg);
1870 COMPARE_NODE_FIELD(typename);
1871 COMPARE_LOCATION_FIELD(location);
1873 return true;
1876 static bool
1877 _equalSortBy(SortBy *a, SortBy *b)
1879 COMPARE_NODE_FIELD(node);
1880 COMPARE_SCALAR_FIELD(sortby_dir);
1881 COMPARE_SCALAR_FIELD(sortby_nulls);
1882 COMPARE_NODE_FIELD(useOp);
1883 COMPARE_LOCATION_FIELD(location);
1885 return true;
1888 static bool
1889 _equalRangeSubselect(RangeSubselect *a, RangeSubselect *b)
1891 COMPARE_NODE_FIELD(subquery);
1892 COMPARE_NODE_FIELD(alias);
1894 return true;
1897 static bool
1898 _equalRangeFunction(RangeFunction *a, RangeFunction *b)
1900 COMPARE_NODE_FIELD(funccallnode);
1901 COMPARE_NODE_FIELD(alias);
1902 COMPARE_NODE_FIELD(coldeflist);
1904 return true;
1907 static bool
1908 _equalIndexElem(IndexElem *a, IndexElem *b)
1910 COMPARE_STRING_FIELD(name);
1911 COMPARE_NODE_FIELD(expr);
1912 COMPARE_NODE_FIELD(opclass);
1913 COMPARE_SCALAR_FIELD(ordering);
1914 COMPARE_SCALAR_FIELD(nulls_ordering);
1916 return true;
1919 static bool
1920 _equalColumnDef(ColumnDef *a, ColumnDef *b)
1922 COMPARE_STRING_FIELD(colname);
1923 COMPARE_NODE_FIELD(typename);
1924 COMPARE_SCALAR_FIELD(inhcount);
1925 COMPARE_SCALAR_FIELD(is_local);
1926 COMPARE_SCALAR_FIELD(is_not_null);
1927 COMPARE_NODE_FIELD(raw_default);
1928 COMPARE_STRING_FIELD(cooked_default);
1929 COMPARE_NODE_FIELD(constraints);
1931 return true;
1934 static bool
1935 _equalConstraint(Constraint *a, Constraint *b)
1937 COMPARE_SCALAR_FIELD(contype);
1938 COMPARE_STRING_FIELD(name);
1939 COMPARE_NODE_FIELD(raw_expr);
1940 COMPARE_STRING_FIELD(cooked_expr);
1941 COMPARE_NODE_FIELD(keys);
1942 COMPARE_NODE_FIELD(options);
1943 COMPARE_STRING_FIELD(indexspace);
1945 return true;
1948 static bool
1949 _equalDefElem(DefElem *a, DefElem *b)
1951 COMPARE_STRING_FIELD(defname);
1952 COMPARE_NODE_FIELD(arg);
1954 return true;
1957 static bool
1958 _equalLockingClause(LockingClause *a, LockingClause *b)
1960 COMPARE_NODE_FIELD(lockedRels);
1961 COMPARE_SCALAR_FIELD(forUpdate);
1962 COMPARE_SCALAR_FIELD(noWait);
1964 return true;
1967 static bool
1968 _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
1970 COMPARE_SCALAR_FIELD(rtekind);
1971 COMPARE_SCALAR_FIELD(relid);
1972 COMPARE_NODE_FIELD(subquery);
1973 COMPARE_SCALAR_FIELD(jointype);
1974 COMPARE_NODE_FIELD(joinaliasvars);
1975 COMPARE_NODE_FIELD(funcexpr);
1976 COMPARE_NODE_FIELD(funccoltypes);
1977 COMPARE_NODE_FIELD(funccoltypmods);
1978 COMPARE_NODE_FIELD(values_lists);
1979 COMPARE_STRING_FIELD(ctename);
1980 COMPARE_SCALAR_FIELD(ctelevelsup);
1981 COMPARE_SCALAR_FIELD(self_reference);
1982 COMPARE_NODE_FIELD(ctecoltypes);
1983 COMPARE_NODE_FIELD(ctecoltypmods);
1984 COMPARE_NODE_FIELD(alias);
1985 COMPARE_NODE_FIELD(eref);
1986 COMPARE_SCALAR_FIELD(inh);
1987 COMPARE_SCALAR_FIELD(inFromCl);
1988 COMPARE_SCALAR_FIELD(requiredPerms);
1989 COMPARE_SCALAR_FIELD(checkAsUser);
1991 return true;
1994 static bool
1995 _equalSortGroupClause(SortGroupClause *a, SortGroupClause *b)
1997 COMPARE_SCALAR_FIELD(tleSortGroupRef);
1998 COMPARE_SCALAR_FIELD(eqop);
1999 COMPARE_SCALAR_FIELD(sortop);
2000 COMPARE_SCALAR_FIELD(nulls_first);
2002 return true;
2005 static bool
2006 _equalRowMarkClause(RowMarkClause *a, RowMarkClause *b)
2008 COMPARE_SCALAR_FIELD(rti);
2009 COMPARE_SCALAR_FIELD(forUpdate);
2010 COMPARE_SCALAR_FIELD(noWait);
2012 return true;
2015 static bool
2016 _equalWithClause(WithClause *a, WithClause *b)
2018 COMPARE_NODE_FIELD(ctes);
2019 COMPARE_SCALAR_FIELD(recursive);
2020 COMPARE_LOCATION_FIELD(location);
2022 return true;
2025 static bool
2026 _equalCommonTableExpr(CommonTableExpr *a, CommonTableExpr *b)
2028 COMPARE_STRING_FIELD(ctename);
2029 COMPARE_NODE_FIELD(aliascolnames);
2030 COMPARE_NODE_FIELD(ctequery);
2031 COMPARE_LOCATION_FIELD(location);
2032 COMPARE_SCALAR_FIELD(cterecursive);
2033 COMPARE_SCALAR_FIELD(cterefcount);
2034 COMPARE_NODE_FIELD(ctecolnames);
2035 COMPARE_NODE_FIELD(ctecoltypes);
2036 COMPARE_NODE_FIELD(ctecoltypmods);
2038 return true;
2041 static bool
2042 _equalFkConstraint(FkConstraint *a, FkConstraint *b)
2044 COMPARE_STRING_FIELD(constr_name);
2045 COMPARE_NODE_FIELD(pktable);
2046 COMPARE_NODE_FIELD(fk_attrs);
2047 COMPARE_NODE_FIELD(pk_attrs);
2048 COMPARE_SCALAR_FIELD(fk_matchtype);
2049 COMPARE_SCALAR_FIELD(fk_upd_action);
2050 COMPARE_SCALAR_FIELD(fk_del_action);
2051 COMPARE_SCALAR_FIELD(deferrable);
2052 COMPARE_SCALAR_FIELD(initdeferred);
2053 COMPARE_SCALAR_FIELD(skip_validation);
2055 return true;
2058 static bool
2059 _equalXmlSerialize(XmlSerialize *a, XmlSerialize *b)
2061 COMPARE_SCALAR_FIELD(xmloption);
2062 COMPARE_NODE_FIELD(expr);
2063 COMPARE_NODE_FIELD(typename);
2064 COMPARE_LOCATION_FIELD(location);
2066 return true;
2070 * Stuff from pg_list.h
2073 static bool
2074 _equalList(List *a, List *b)
2076 ListCell *item_a;
2077 ListCell *item_b;
2080 * Try to reject by simple scalar checks before grovelling through all the
2081 * list elements...
2083 COMPARE_SCALAR_FIELD(type);
2084 COMPARE_SCALAR_FIELD(length);
2087 * We place the switch outside the loop for the sake of efficiency; this
2088 * may not be worth doing...
2090 switch (a->type)
2092 case T_List:
2093 forboth(item_a, a, item_b, b)
2095 if (!equal(lfirst(item_a), lfirst(item_b)))
2096 return false;
2098 break;
2099 case T_IntList:
2100 forboth(item_a, a, item_b, b)
2102 if (lfirst_int(item_a) != lfirst_int(item_b))
2103 return false;
2105 break;
2106 case T_OidList:
2107 forboth(item_a, a, item_b, b)
2109 if (lfirst_oid(item_a) != lfirst_oid(item_b))
2110 return false;
2112 break;
2113 default:
2114 elog(ERROR, "unrecognized list node type: %d",
2115 (int) a->type);
2116 return false; /* keep compiler quiet */
2120 * If we got here, we should have run out of elements of both lists
2122 Assert(item_a == NULL);
2123 Assert(item_b == NULL);
2125 return true;
2129 * Stuff from value.h
2132 static bool
2133 _equalValue(Value *a, Value *b)
2135 COMPARE_SCALAR_FIELD(type);
2137 switch (a->type)
2139 case T_Integer:
2140 COMPARE_SCALAR_FIELD(val.ival);
2141 break;
2142 case T_Float:
2143 case T_String:
2144 case T_BitString:
2145 COMPARE_STRING_FIELD(val.str);
2146 break;
2147 case T_Null:
2148 /* nothing to do */
2149 break;
2150 default:
2151 elog(ERROR, "unrecognized node type: %d", (int) a->type);
2152 break;
2155 return true;
2159 * equal
2160 * returns whether two nodes are equal
2162 bool
2163 equal(void *a, void *b)
2165 bool retval;
2167 if (a == b)
2168 return true;
2171 * note that a!=b, so only one of them can be NULL
2173 if (a == NULL || b == NULL)
2174 return false;
2177 * are they the same type of nodes?
2179 if (nodeTag(a) != nodeTag(b))
2180 return false;
2182 switch (nodeTag(a))
2185 * PRIMITIVE NODES
2187 case T_Alias:
2188 retval = _equalAlias(a, b);
2189 break;
2190 case T_RangeVar:
2191 retval = _equalRangeVar(a, b);
2192 break;
2193 case T_IntoClause:
2194 retval = _equalIntoClause(a, b);
2195 break;
2196 case T_Var:
2197 retval = _equalVar(a, b);
2198 break;
2199 case T_Const:
2200 retval = _equalConst(a, b);
2201 break;
2202 case T_Param:
2203 retval = _equalParam(a, b);
2204 break;
2205 case T_Aggref:
2206 retval = _equalAggref(a, b);
2207 break;
2208 case T_ArrayRef:
2209 retval = _equalArrayRef(a, b);
2210 break;
2211 case T_FuncExpr:
2212 retval = _equalFuncExpr(a, b);
2213 break;
2214 case T_OpExpr:
2215 retval = _equalOpExpr(a, b);
2216 break;
2217 case T_DistinctExpr:
2218 retval = _equalDistinctExpr(a, b);
2219 break;
2220 case T_ScalarArrayOpExpr:
2221 retval = _equalScalarArrayOpExpr(a, b);
2222 break;
2223 case T_BoolExpr:
2224 retval = _equalBoolExpr(a, b);
2225 break;
2226 case T_SubLink:
2227 retval = _equalSubLink(a, b);
2228 break;
2229 case T_SubPlan:
2230 retval = _equalSubPlan(a, b);
2231 break;
2232 case T_AlternativeSubPlan:
2233 retval = _equalAlternativeSubPlan(a, b);
2234 break;
2235 case T_FieldSelect:
2236 retval = _equalFieldSelect(a, b);
2237 break;
2238 case T_FieldStore:
2239 retval = _equalFieldStore(a, b);
2240 break;
2241 case T_RelabelType:
2242 retval = _equalRelabelType(a, b);
2243 break;
2244 case T_CoerceViaIO:
2245 retval = _equalCoerceViaIO(a, b);
2246 break;
2247 case T_ArrayCoerceExpr:
2248 retval = _equalArrayCoerceExpr(a, b);
2249 break;
2250 case T_ConvertRowtypeExpr:
2251 retval = _equalConvertRowtypeExpr(a, b);
2252 break;
2253 case T_CaseExpr:
2254 retval = _equalCaseExpr(a, b);
2255 break;
2256 case T_CaseWhen:
2257 retval = _equalCaseWhen(a, b);
2258 break;
2259 case T_CaseTestExpr:
2260 retval = _equalCaseTestExpr(a, b);
2261 break;
2262 case T_ArrayExpr:
2263 retval = _equalArrayExpr(a, b);
2264 break;
2265 case T_RowExpr:
2266 retval = _equalRowExpr(a, b);
2267 break;
2268 case T_RowCompareExpr:
2269 retval = _equalRowCompareExpr(a, b);
2270 break;
2271 case T_CoalesceExpr:
2272 retval = _equalCoalesceExpr(a, b);
2273 break;
2274 case T_MinMaxExpr:
2275 retval = _equalMinMaxExpr(a, b);
2276 break;
2277 case T_XmlExpr:
2278 retval = _equalXmlExpr(a, b);
2279 break;
2280 case T_NullIfExpr:
2281 retval = _equalNullIfExpr(a, b);
2282 break;
2283 case T_NullTest:
2284 retval = _equalNullTest(a, b);
2285 break;
2286 case T_BooleanTest:
2287 retval = _equalBooleanTest(a, b);
2288 break;
2289 case T_CoerceToDomain:
2290 retval = _equalCoerceToDomain(a, b);
2291 break;
2292 case T_CoerceToDomainValue:
2293 retval = _equalCoerceToDomainValue(a, b);
2294 break;
2295 case T_SetToDefault:
2296 retval = _equalSetToDefault(a, b);
2297 break;
2298 case T_CurrentOfExpr:
2299 retval = _equalCurrentOfExpr(a, b);
2300 break;
2301 case T_TargetEntry:
2302 retval = _equalTargetEntry(a, b);
2303 break;
2304 case T_RangeTblRef:
2305 retval = _equalRangeTblRef(a, b);
2306 break;
2307 case T_FromExpr:
2308 retval = _equalFromExpr(a, b);
2309 break;
2310 case T_JoinExpr:
2311 retval = _equalJoinExpr(a, b);
2312 break;
2315 * RELATION NODES
2317 case T_PathKey:
2318 retval = _equalPathKey(a, b);
2319 break;
2320 case T_RestrictInfo:
2321 retval = _equalRestrictInfo(a, b);
2322 break;
2323 case T_FlattenedSubLink:
2324 retval = _equalFlattenedSubLink(a, b);
2325 break;
2326 case T_PlaceHolderVar:
2327 retval = _equalPlaceHolderVar(a, b);
2328 break;
2329 case T_SpecialJoinInfo:
2330 retval = _equalSpecialJoinInfo(a, b);
2331 break;
2332 case T_AppendRelInfo:
2333 retval = _equalAppendRelInfo(a, b);
2334 break;
2335 case T_PlaceHolderInfo:
2336 retval = _equalPlaceHolderInfo(a, b);
2337 break;
2339 case T_List:
2340 case T_IntList:
2341 case T_OidList:
2342 retval = _equalList(a, b);
2343 break;
2345 case T_Integer:
2346 case T_Float:
2347 case T_String:
2348 case T_BitString:
2349 case T_Null:
2350 retval = _equalValue(a, b);
2351 break;
2354 * PARSE NODES
2356 case T_Query:
2357 retval = _equalQuery(a, b);
2358 break;
2359 case T_InsertStmt:
2360 retval = _equalInsertStmt(a, b);
2361 break;
2362 case T_DeleteStmt:
2363 retval = _equalDeleteStmt(a, b);
2364 break;
2365 case T_UpdateStmt:
2366 retval = _equalUpdateStmt(a, b);
2367 break;
2368 case T_SelectStmt:
2369 retval = _equalSelectStmt(a, b);
2370 break;
2371 case T_SetOperationStmt:
2372 retval = _equalSetOperationStmt(a, b);
2373 break;
2374 case T_AlterTableStmt:
2375 retval = _equalAlterTableStmt(a, b);
2376 break;
2377 case T_AlterTableCmd:
2378 retval = _equalAlterTableCmd(a, b);
2379 break;
2380 case T_AlterDomainStmt:
2381 retval = _equalAlterDomainStmt(a, b);
2382 break;
2383 case T_GrantStmt:
2384 retval = _equalGrantStmt(a, b);
2385 break;
2386 case T_GrantRoleStmt:
2387 retval = _equalGrantRoleStmt(a, b);
2388 break;
2389 case T_DeclareCursorStmt:
2390 retval = _equalDeclareCursorStmt(a, b);
2391 break;
2392 case T_ClosePortalStmt:
2393 retval = _equalClosePortalStmt(a, b);
2394 break;
2395 case T_ClusterStmt:
2396 retval = _equalClusterStmt(a, b);
2397 break;
2398 case T_CopyStmt:
2399 retval = _equalCopyStmt(a, b);
2400 break;
2401 case T_CreateStmt:
2402 retval = _equalCreateStmt(a, b);
2403 break;
2404 case T_InhRelation:
2405 retval = _equalInhRelation(a, b);
2406 break;
2407 case T_DefineStmt:
2408 retval = _equalDefineStmt(a, b);
2409 break;
2410 case T_DropStmt:
2411 retval = _equalDropStmt(a, b);
2412 break;
2413 case T_TruncateStmt:
2414 retval = _equalTruncateStmt(a, b);
2415 break;
2416 case T_CommentStmt:
2417 retval = _equalCommentStmt(a, b);
2418 break;
2419 case T_FetchStmt:
2420 retval = _equalFetchStmt(a, b);
2421 break;
2422 case T_IndexStmt:
2423 retval = _equalIndexStmt(a, b);
2424 break;
2425 case T_CreateFunctionStmt:
2426 retval = _equalCreateFunctionStmt(a, b);
2427 break;
2428 case T_FunctionParameter:
2429 retval = _equalFunctionParameter(a, b);
2430 break;
2431 case T_AlterFunctionStmt:
2432 retval = _equalAlterFunctionStmt(a, b);
2433 break;
2434 case T_RemoveFuncStmt:
2435 retval = _equalRemoveFuncStmt(a, b);
2436 break;
2437 case T_RemoveOpClassStmt:
2438 retval = _equalRemoveOpClassStmt(a, b);
2439 break;
2440 case T_RemoveOpFamilyStmt:
2441 retval = _equalRemoveOpFamilyStmt(a, b);
2442 break;
2443 case T_RenameStmt:
2444 retval = _equalRenameStmt(a, b);
2445 break;
2446 case T_AlterObjectSchemaStmt:
2447 retval = _equalAlterObjectSchemaStmt(a, b);
2448 break;
2449 case T_AlterOwnerStmt:
2450 retval = _equalAlterOwnerStmt(a, b);
2451 break;
2452 case T_RuleStmt:
2453 retval = _equalRuleStmt(a, b);
2454 break;
2455 case T_NotifyStmt:
2456 retval = _equalNotifyStmt(a, b);
2457 break;
2458 case T_ListenStmt:
2459 retval = _equalListenStmt(a, b);
2460 break;
2461 case T_UnlistenStmt:
2462 retval = _equalUnlistenStmt(a, b);
2463 break;
2464 case T_TransactionStmt:
2465 retval = _equalTransactionStmt(a, b);
2466 break;
2467 case T_CompositeTypeStmt:
2468 retval = _equalCompositeTypeStmt(a, b);
2469 break;
2470 case T_CreateEnumStmt:
2471 retval = _equalCreateEnumStmt(a, b);
2472 break;
2473 case T_ViewStmt:
2474 retval = _equalViewStmt(a, b);
2475 break;
2476 case T_LoadStmt:
2477 retval = _equalLoadStmt(a, b);
2478 break;
2479 case T_CreateDomainStmt:
2480 retval = _equalCreateDomainStmt(a, b);
2481 break;
2482 case T_CreateOpClassStmt:
2483 retval = _equalCreateOpClassStmt(a, b);
2484 break;
2485 case T_CreateOpClassItem:
2486 retval = _equalCreateOpClassItem(a, b);
2487 break;
2488 case T_CreateOpFamilyStmt:
2489 retval = _equalCreateOpFamilyStmt(a, b);
2490 break;
2491 case T_AlterOpFamilyStmt:
2492 retval = _equalAlterOpFamilyStmt(a, b);
2493 break;
2494 case T_CreatedbStmt:
2495 retval = _equalCreatedbStmt(a, b);
2496 break;
2497 case T_AlterDatabaseStmt:
2498 retval = _equalAlterDatabaseStmt(a, b);
2499 break;
2500 case T_AlterDatabaseSetStmt:
2501 retval = _equalAlterDatabaseSetStmt(a, b);
2502 break;
2503 case T_DropdbStmt:
2504 retval = _equalDropdbStmt(a, b);
2505 break;
2506 case T_VacuumStmt:
2507 retval = _equalVacuumStmt(a, b);
2508 break;
2509 case T_ExplainStmt:
2510 retval = _equalExplainStmt(a, b);
2511 break;
2512 case T_CreateSeqStmt:
2513 retval = _equalCreateSeqStmt(a, b);
2514 break;
2515 case T_AlterSeqStmt:
2516 retval = _equalAlterSeqStmt(a, b);
2517 break;
2518 case T_VariableSetStmt:
2519 retval = _equalVariableSetStmt(a, b);
2520 break;
2521 case T_VariableShowStmt:
2522 retval = _equalVariableShowStmt(a, b);
2523 break;
2524 case T_DiscardStmt:
2525 retval = _equalDiscardStmt(a, b);
2526 break;
2527 case T_CreateTableSpaceStmt:
2528 retval = _equalCreateTableSpaceStmt(a, b);
2529 break;
2530 case T_DropTableSpaceStmt:
2531 retval = _equalDropTableSpaceStmt(a, b);
2532 break;
2533 case T_CreateTrigStmt:
2534 retval = _equalCreateTrigStmt(a, b);
2535 break;
2536 case T_DropPropertyStmt:
2537 retval = _equalDropPropertyStmt(a, b);
2538 break;
2539 case T_CreatePLangStmt:
2540 retval = _equalCreatePLangStmt(a, b);
2541 break;
2542 case T_DropPLangStmt:
2543 retval = _equalDropPLangStmt(a, b);
2544 break;
2545 case T_CreateRoleStmt:
2546 retval = _equalCreateRoleStmt(a, b);
2547 break;
2548 case T_AlterRoleStmt:
2549 retval = _equalAlterRoleStmt(a, b);
2550 break;
2551 case T_AlterRoleSetStmt:
2552 retval = _equalAlterRoleSetStmt(a, b);
2553 break;
2554 case T_DropRoleStmt:
2555 retval = _equalDropRoleStmt(a, b);
2556 break;
2557 case T_LockStmt:
2558 retval = _equalLockStmt(a, b);
2559 break;
2560 case T_ConstraintsSetStmt:
2561 retval = _equalConstraintsSetStmt(a, b);
2562 break;
2563 case T_ReindexStmt:
2564 retval = _equalReindexStmt(a, b);
2565 break;
2566 case T_CheckPointStmt:
2567 retval = true;
2568 break;
2569 case T_CreateSchemaStmt:
2570 retval = _equalCreateSchemaStmt(a, b);
2571 break;
2572 case T_CreateConversionStmt:
2573 retval = _equalCreateConversionStmt(a, b);
2574 break;
2575 case T_CreateCastStmt:
2576 retval = _equalCreateCastStmt(a, b);
2577 break;
2578 case T_DropCastStmt:
2579 retval = _equalDropCastStmt(a, b);
2580 break;
2581 case T_PrepareStmt:
2582 retval = _equalPrepareStmt(a, b);
2583 break;
2584 case T_ExecuteStmt:
2585 retval = _equalExecuteStmt(a, b);
2586 break;
2587 case T_DeallocateStmt:
2588 retval = _equalDeallocateStmt(a, b);
2589 break;
2590 case T_DropOwnedStmt:
2591 retval = _equalDropOwnedStmt(a, b);
2592 break;
2593 case T_ReassignOwnedStmt:
2594 retval = _equalReassignOwnedStmt(a, b);
2595 break;
2596 case T_AlterTSDictionaryStmt:
2597 retval = _equalAlterTSDictionaryStmt(a, b);
2598 break;
2599 case T_AlterTSConfigurationStmt:
2600 retval = _equalAlterTSConfigurationStmt(a, b);
2601 break;
2603 case T_A_Expr:
2604 retval = _equalAExpr(a, b);
2605 break;
2606 case T_ColumnRef:
2607 retval = _equalColumnRef(a, b);
2608 break;
2609 case T_ParamRef:
2610 retval = _equalParamRef(a, b);
2611 break;
2612 case T_A_Const:
2613 retval = _equalAConst(a, b);
2614 break;
2615 case T_FuncCall:
2616 retval = _equalFuncCall(a, b);
2617 break;
2618 case T_A_Star:
2619 retval = _equalAStar(a, b);
2620 break;
2621 case T_A_Indices:
2622 retval = _equalAIndices(a, b);
2623 break;
2624 case T_A_Indirection:
2625 retval = _equalA_Indirection(a, b);
2626 break;
2627 case T_A_ArrayExpr:
2628 retval = _equalA_ArrayExpr(a, b);
2629 break;
2630 case T_ResTarget:
2631 retval = _equalResTarget(a, b);
2632 break;
2633 case T_TypeCast:
2634 retval = _equalTypeCast(a, b);
2635 break;
2636 case T_SortBy:
2637 retval = _equalSortBy(a, b);
2638 break;
2639 case T_RangeSubselect:
2640 retval = _equalRangeSubselect(a, b);
2641 break;
2642 case T_RangeFunction:
2643 retval = _equalRangeFunction(a, b);
2644 break;
2645 case T_TypeName:
2646 retval = _equalTypeName(a, b);
2647 break;
2648 case T_IndexElem:
2649 retval = _equalIndexElem(a, b);
2650 break;
2651 case T_ColumnDef:
2652 retval = _equalColumnDef(a, b);
2653 break;
2654 case T_Constraint:
2655 retval = _equalConstraint(a, b);
2656 break;
2657 case T_DefElem:
2658 retval = _equalDefElem(a, b);
2659 break;
2660 case T_LockingClause:
2661 retval = _equalLockingClause(a, b);
2662 break;
2663 case T_RangeTblEntry:
2664 retval = _equalRangeTblEntry(a, b);
2665 break;
2666 case T_SortGroupClause:
2667 retval = _equalSortGroupClause(a, b);
2668 break;
2669 case T_RowMarkClause:
2670 retval = _equalRowMarkClause(a, b);
2671 break;
2672 case T_WithClause:
2673 retval = _equalWithClause(a, b);
2674 break;
2675 case T_CommonTableExpr:
2676 retval = _equalCommonTableExpr(a, b);
2677 break;
2678 case T_FkConstraint:
2679 retval = _equalFkConstraint(a, b);
2680 break;
2681 case T_PrivGrantee:
2682 retval = _equalPrivGrantee(a, b);
2683 break;
2684 case T_FuncWithArgs:
2685 retval = _equalFuncWithArgs(a, b);
2686 break;
2687 case T_XmlSerialize:
2688 retval = _equalXmlSerialize(a, b);
2689 break;
2691 default:
2692 elog(ERROR, "unrecognized node type: %d",
2693 (int) nodeTag(a));
2694 retval = false; /* keep compiler quiet */
2695 break;
2698 return retval;