1 /*-------------------------------------------------------------------------
4 * Equality functions to compare node trees.
6 * NOTE: a general convention when copying or comparing plan nodes is
7 * that we ignore the executor state subnode. We do not need to look
8 * at it because no current uses of copyObject() or equal() need to
9 * deal with already-executing plan trees. By leaving the state subnodes
10 * out, we avoid needing to write copy/compare routines for all the
11 * different executor state node types.
13 * Currently, in fact, equal() doesn't know how to compare Plan nodes
14 * at all, let alone their executor-state subnodes. This will probably
15 * need to be fixed someday, but presently there is no need to compare
19 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
20 * Portions Copyright (c) 1994, Regents of the University of California
23 * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.108 2001/11/05 05:00:14 tgl Exp $
25 *-------------------------------------------------------------------------
30 #include "nodes/plannodes.h"
31 #include "nodes/relation.h"
32 #include "utils/datum.h"
35 /* Macro for comparing string fields that might be NULL */
36 #define equalstr(a, b) \
37 (((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
41 * Stuff from primnodes.h
45 _equalResdom(Resdom *a, Resdom *b)
47 if (a->resno != b->resno)
49 if (a->restype != b->restype)
51 if (a->restypmod != b->restypmod)
53 if (!equalstr(a->resname, b->resname))
55 if (a->ressortgroupref != b->ressortgroupref)
57 if (a->reskey != b->reskey)
59 if (a->reskeyop != b->reskeyop)
61 /* we ignore resjunk flag ... is this correct? */
67 _equalFjoin(Fjoin *a, Fjoin *b)
71 if (a->fj_initialized != b->fj_initialized)
73 if (a->fj_nNodes != b->fj_nNodes)
75 if (!equal(a->fj_innerNode, b->fj_innerNode))
78 nNodes = a->fj_nNodes;
79 if (memcmp(a->fj_results, b->fj_results, nNodes * sizeof(Datum)) != 0)
81 if (memcmp(a->fj_alwaysDone, b->fj_alwaysDone, nNodes * sizeof(bool)) != 0)
88 _equalExpr(Expr *a, Expr *b)
91 * We do not examine typeOid, since the optimizer often doesn't bother
92 * to set it in created nodes, and it is logically a derivative of the
95 if (a->opType != b->opType)
97 if (!equal(a->oper, b->oper))
99 if (!equal(a->args, b->args))
106 _equalVar(Var *a, Var *b)
108 if (a->varno != b->varno)
110 if (a->varattno != b->varattno)
112 if (a->vartype != b->vartype)
114 if (a->vartypmod != b->vartypmod)
116 if (a->varlevelsup != b->varlevelsup)
118 if (a->varnoold != b->varnoold)
120 if (a->varoattno != b->varoattno)
127 _equalOper(Oper *a, Oper *b)
129 if (a->opno != b->opno)
131 if (a->opresulttype != b->opresulttype)
135 * We do not examine opid or op_fcache, since these are logically
136 * derived from opno, and they may not be set yet depending on how far
137 * along the node is in the parse/plan pipeline.
139 * (Besides, op_fcache is executor state, which we don't check --- see
140 * notes at head of file.)
142 * It's probably not really necessary to check opresulttype either...
149 _equalConst(Const *a, Const *b)
151 if (a->consttype != b->consttype)
153 if (a->constlen != b->constlen)
155 if (a->constisnull != b->constisnull)
157 if (a->constbyval != b->constbyval)
159 /* XXX What about constisset and constiscast? */
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,
168 return datumIsEqual(a->constvalue, b->constvalue,
169 a->constbyval, a->constlen);
173 _equalParam(Param *a, Param *b)
175 if (a->paramkind != b->paramkind)
177 if (a->paramtype != b->paramtype)
180 switch (a->paramkind)
185 if (strcmp(a->paramname, b->paramname) != 0)
190 if (a->paramid != b->paramid)
196 * XXX: Hmmm... What are we supposed to return in this case ??
201 elog(ERROR, "_equalParam: Invalid paramkind value: %d",
209 _equalFunc(Func *a, Func *b)
211 if (a->funcid != b->funcid)
213 if (a->functype != b->functype)
215 /* Note we do not look at func_fcache; see notes for _equalOper */
221 _equalAggref(Aggref *a, Aggref *b)
223 if (strcmp(a->aggname, b->aggname) != 0)
225 if (a->basetype != b->basetype)
227 if (a->aggtype != b->aggtype)
229 if (!equal(a->target, b->target))
231 if (a->aggstar != b->aggstar)
233 if (a->aggdistinct != b->aggdistinct)
235 /* ignore aggno, which is only a private field for the executor */
240 _equalSubLink(SubLink *a, SubLink *b)
242 if (a->subLinkType != b->subLinkType)
244 if (a->useor != b->useor)
246 if (!equal(a->lefthand, b->lefthand))
248 if (!equal(a->oper, b->oper))
250 if (!equal(a->subselect, b->subselect))
256 _equalArrayRef(ArrayRef *a, ArrayRef *b)
258 if (a->refelemtype != b->refelemtype)
260 if (a->refattrlength != b->refattrlength)
262 if (a->refelemlength != b->refelemlength)
264 if (a->refelembyval != b->refelembyval)
266 if (!equal(a->refupperindexpr, b->refupperindexpr))
268 if (!equal(a->reflowerindexpr, b->reflowerindexpr))
270 if (!equal(a->refexpr, b->refexpr))
272 return equal(a->refassgnexpr, b->refassgnexpr);
276 _equalFieldSelect(FieldSelect *a, FieldSelect *b)
278 if (!equal(a->arg, b->arg))
280 if (a->fieldnum != b->fieldnum)
282 if (a->resulttype != b->resulttype)
284 if (a->resulttypmod != b->resulttypmod)
290 _equalRelabelType(RelabelType *a, RelabelType *b)
292 if (!equal(a->arg, b->arg))
294 if (a->resulttype != b->resulttype)
296 if (a->resulttypmod != b->resulttypmod)
302 _equalRangeTblRef(RangeTblRef *a, RangeTblRef *b)
304 if (a->rtindex != b->rtindex)
311 _equalFromExpr(FromExpr *a, FromExpr *b)
313 if (!equal(a->fromlist, b->fromlist))
315 if (!equal(a->quals, b->quals))
322 _equalJoinExpr(JoinExpr *a, JoinExpr *b)
324 if (a->jointype != b->jointype)
326 if (a->isNatural != b->isNatural)
328 if (!equal(a->larg, b->larg))
330 if (!equal(a->rarg, b->rarg))
332 if (!equal(a->using, b->using))
334 if (!equal(a->quals, b->quals))
336 if (!equal(a->alias, b->alias))
338 if (!equal(a->colnames, b->colnames))
340 if (!equal(a->colvars, b->colvars))
347 * Stuff from relation.h
351 _equalRelOptInfo(RelOptInfo *a, RelOptInfo *b)
354 * We treat RelOptInfos as equal if they refer to the same base rels
355 * joined in the same order. Is this appropriate/sufficient?
357 return equali(a->relids, b->relids);
361 _equalIndexOptInfo(IndexOptInfo *a, IndexOptInfo *b)
364 * We treat IndexOptInfos as equal if they refer to the same index. Is
367 if (a->indexoid != b->indexoid)
373 _equalPathKeyItem(PathKeyItem *a, PathKeyItem *b)
375 if (a->sortop != b->sortop)
377 if (!equal(a->key, b->key))
383 _equalPath(Path *a, Path *b)
385 if (a->pathtype != b->pathtype)
387 if (!equal(a->parent, b->parent))
391 * do not check path costs, since they may not be set yet, and being
392 * float values there are roundoff error issues anyway...
394 if (!equal(a->pathkeys, b->pathkeys))
400 _equalIndexPath(IndexPath *a, IndexPath *b)
402 if (!_equalPath((Path *) a, (Path *) b))
404 if (!equal(a->indexinfo, b->indexinfo))
406 if (!equal(a->indexqual, b->indexqual))
408 if (a->indexscandir != b->indexscandir)
410 if (!equali(a->joinrelids, b->joinrelids))
412 if (a->alljoinquals != b->alljoinquals)
416 * Skip 'rows' because of possibility of floating-point roundoff
417 * error. It should be derivable from the other fields anyway.
423 _equalTidPath(TidPath *a, TidPath *b)
425 if (!_equalPath((Path *) a, (Path *) b))
427 if (!equal(a->tideval, b->tideval))
429 if (!equali(a->unjoined_relids, b->unjoined_relids))
435 _equalAppendPath(AppendPath *a, AppendPath *b)
437 if (!_equalPath((Path *) a, (Path *) b))
439 if (!equal(a->subpaths, b->subpaths))
445 _equalJoinPath(JoinPath *a, JoinPath *b)
447 if (!_equalPath((Path *) a, (Path *) b))
449 if (a->jointype != b->jointype)
451 if (!equal(a->outerjoinpath, b->outerjoinpath))
453 if (!equal(a->innerjoinpath, b->innerjoinpath))
455 if (!equal(a->joinrestrictinfo, b->joinrestrictinfo))
461 _equalNestPath(NestPath *a, NestPath *b)
463 if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b))
469 _equalMergePath(MergePath *a, MergePath *b)
471 if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b))
473 if (!equal(a->path_mergeclauses, b->path_mergeclauses))
475 if (!equal(a->outersortkeys, b->outersortkeys))
477 if (!equal(a->innersortkeys, b->innersortkeys))
483 _equalHashPath(HashPath *a, HashPath *b)
485 if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b))
487 if (!equal(a->path_hashclauses, b->path_hashclauses))
493 _equalSubPlan(SubPlan *a, SubPlan *b)
495 /* should compare plans, but have to settle for comparing plan IDs */
496 if (a->plan_id != b->plan_id)
499 if (!equal(a->rtable, b->rtable))
502 if (!equal(a->sublink, b->sublink))
509 _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
511 if (!equal(a->clause, b->clause))
513 if (a->ispusheddown != b->ispusheddown)
517 * We ignore eval_cost, this_selec, left/right_pathkey, and
518 * left/right_bucketsize, since they may not be set yet, and should be
519 * derivable from the clause anyway. Probably it's not really
520 * necessary to compare any of these remaining fields ...
522 if (!equal(a->subclauseindices, b->subclauseindices))
524 if (a->mergejoinoperator != b->mergejoinoperator)
526 if (a->left_sortop != b->left_sortop)
528 if (a->right_sortop != b->right_sortop)
530 if (a->hashjoinoperator != b->hashjoinoperator)
536 _equalJoinInfo(JoinInfo *a, JoinInfo *b)
538 if (!equali(a->unjoined_relids, b->unjoined_relids))
540 if (!equal(a->jinfo_restrictinfo, b->jinfo_restrictinfo))
546 _equalIter(Iter *a, Iter *b)
548 return equal(a->iterexpr, b->iterexpr);
552 _equalStream(Stream *a, Stream *b)
554 if (a->clausetype != b->clausetype)
556 if (a->groupup != b->groupup)
558 if (a->groupcost != b->groupcost)
560 if (a->groupsel != b->groupsel)
562 if (!equal(a->pathptr, b->pathptr))
564 if (!equal(a->cinfo, b->cinfo))
566 if (!equal(a->upstream, b->upstream))
568 return equal(a->downstream, b->downstream);
572 * Stuff from parsenodes.h
576 _equalQuery(Query *a, Query *b)
578 if (a->commandType != b->commandType)
580 if (!equal(a->utilityStmt, b->utilityStmt))
582 if (a->resultRelation != b->resultRelation)
584 if (!equalstr(a->into, b->into))
586 if (a->isPortal != b->isPortal)
588 if (a->isBinary != b->isBinary)
590 if (a->isTemp != b->isTemp)
592 if (a->hasAggs != b->hasAggs)
594 if (a->hasSubLinks != b->hasSubLinks)
596 if (!equal(a->rtable, b->rtable))
598 if (!equal(a->jointree, b->jointree))
600 if (!equali(a->rowMarks, b->rowMarks))
602 if (!equal(a->targetList, b->targetList))
604 if (!equal(a->groupClause, b->groupClause))
606 if (!equal(a->havingQual, b->havingQual))
608 if (!equal(a->distinctClause, b->distinctClause))
610 if (!equal(a->sortClause, b->sortClause))
612 if (!equal(a->limitOffset, b->limitOffset))
614 if (!equal(a->limitCount, b->limitCount))
616 if (!equal(a->setOperations, b->setOperations))
618 if (!equali(a->resultRelations, b->resultRelations))
622 * We do not check the internal-to-the-planner fields: base_rel_list,
623 * other_rel_list, join_rel_list, equi_key_list, query_pathkeys. They
624 * might not be set yet, and in any case they should be derivable from
631 _equalInsertStmt(InsertStmt *a, InsertStmt *b)
633 if (!equalstr(a->relname, b->relname))
635 if (!equal(a->cols, b->cols))
637 if (!equal(a->targetList, b->targetList))
639 if (!equal(a->selectStmt, b->selectStmt))
646 _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
648 if (!equalstr(a->relname, b->relname))
650 if (!equal(a->whereClause, b->whereClause))
652 if (a->inhOpt != b->inhOpt)
659 _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
661 if (!equalstr(a->relname, b->relname))
663 if (!equal(a->targetList, b->targetList))
665 if (!equal(a->whereClause, b->whereClause))
667 if (!equal(a->fromClause, b->fromClause))
669 if (a->inhOpt != b->inhOpt)
676 _equalSelectStmt(SelectStmt *a, SelectStmt *b)
678 if (!equal(a->distinctClause, b->distinctClause))
680 if (!equalstr(a->into, b->into))
682 if (a->istemp != b->istemp)
684 if (!equal(a->intoColNames, b->intoColNames))
686 if (!equal(a->targetList, b->targetList))
688 if (!equal(a->fromClause, b->fromClause))
690 if (!equal(a->whereClause, b->whereClause))
692 if (!equal(a->groupClause, b->groupClause))
694 if (!equal(a->havingClause, b->havingClause))
696 if (!equal(a->sortClause, b->sortClause))
698 if (!equalstr(a->portalname, b->portalname))
700 if (a->binary != b->binary)
702 if (!equal(a->limitOffset, b->limitOffset))
704 if (!equal(a->limitCount, b->limitCount))
706 if (!equal(a->forUpdate, b->forUpdate))
710 if (a->all != b->all)
712 if (!equal(a->larg, b->larg))
714 if (!equal(a->rarg, b->rarg))
721 _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b)
725 if (a->all != b->all)
727 if (!equal(a->larg, b->larg))
729 if (!equal(a->rarg, b->rarg))
731 if (!equali(a->colTypes, b->colTypes))
738 _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
740 if (a->subtype != b->subtype)
742 if (!equalstr(a->relname, b->relname))
744 if (a->inhOpt != b->inhOpt)
746 if (!equalstr(a->name, b->name))
748 if (!equal(a->def, b->def))
750 if (a->behavior != b->behavior)
757 _equalGrantStmt(GrantStmt *a, GrantStmt *b)
759 if (a->is_grant != b->is_grant)
761 if (!equal(a->relnames, b->relnames))
763 if (!equalstr(a->privileges, b->privileges))
765 if (!equal(a->grantees, b->grantees))
772 _equalPrivGrantee(PrivGrantee *a, PrivGrantee *b)
774 return equalstr(a->username, b->username)
775 && equalstr(a->groupname, b->groupname);
779 _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
781 if (!equalstr(a->portalname, b->portalname))
788 _equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
790 if (!equalstr(a->relname, b->relname))
792 if (!equalstr(a->indexname, b->indexname))
799 _equalCopyStmt(CopyStmt *a, CopyStmt *b)
801 if (a->binary != b->binary)
803 if (!equalstr(a->relname, b->relname))
805 if (a->oids != b->oids)
807 if (a->direction != b->direction)
809 if (!equalstr(a->filename, b->filename))
811 if (!equalstr(a->delimiter, b->delimiter))
813 if (!equalstr(a->null_print, b->null_print))
820 _equalCreateStmt(CreateStmt *a, CreateStmt *b)
822 if (!equalstr(a->relname, b->relname))
824 if (!equal(a->tableElts, b->tableElts))
826 if (!equal(a->inhRelnames, b->inhRelnames))
828 if (!equal(a->constraints, b->constraints))
830 if (a->istemp != b->istemp)
832 if (a->hasoids != b->hasoids)
839 _equalVersionStmt(VersionStmt *a, VersionStmt *b)
841 if (!equalstr(a->relname, b->relname))
843 if (a->direction != b->direction)
845 if (!equalstr(a->fromRelname, b->fromRelname))
847 if (!equalstr(a->date, b->date))
854 _equalDefineStmt(DefineStmt *a, DefineStmt *b)
856 if (a->defType != b->defType)
858 if (!equalstr(a->defname, b->defname))
860 if (!equal(a->definition, b->definition))
867 _equalDropStmt(DropStmt *a, DropStmt *b)
869 if (!equal(a->names, b->names))
871 if (a->removeType != b->removeType)
878 _equalTruncateStmt(TruncateStmt *a, TruncateStmt *b)
880 if (!equalstr(a->relName, b->relName))
887 _equalCommentStmt(CommentStmt *a, CommentStmt *b)
889 if (a->objtype != b->objtype)
891 if (!equalstr(a->objname, b->objname))
893 if (!equalstr(a->objproperty, b->objproperty))
895 if (!equal(a->objlist, b->objlist))
897 if (!equalstr(a->comment, b->comment))
904 _equalFetchStmt(FetchStmt *a, FetchStmt *b)
906 if (a->direction != b->direction)
908 if (a->howMany != b->howMany)
910 if (!equalstr(a->portalname, b->portalname))
912 if (a->ismove != b->ismove)
919 _equalIndexStmt(IndexStmt *a, IndexStmt *b)
921 if (!equalstr(a->idxname, b->idxname))
923 if (!equalstr(a->relname, b->relname))
925 if (!equalstr(a->accessMethod, b->accessMethod))
927 if (!equal(a->indexParams, b->indexParams))
929 if (!equal(a->whereClause, b->whereClause))
931 if (!equal(a->rangetable, b->rangetable))
933 if (a->unique != b->unique)
935 if (a->primary != b->primary)
942 _equalProcedureStmt(ProcedureStmt *a, ProcedureStmt *b)
944 if (a->replace != b->replace)
946 if (!equalstr(a->funcname, b->funcname))
948 if (!equal(a->argTypes, b->argTypes))
950 if (!equal(a->returnType, b->returnType))
952 if (!equal(a->withClause, b->withClause))
954 if (!equal(a->as, b->as))
956 if (!equalstr(a->language, b->language))
963 _equalRemoveAggrStmt(RemoveAggrStmt *a, RemoveAggrStmt *b)
965 if (!equalstr(a->aggname, b->aggname))
967 if (!equal(a->aggtype, b->aggtype))
974 _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b)
976 if (!equalstr(a->funcname, b->funcname))
978 if (!equal(a->args, b->args))
985 _equalRemoveOperStmt(RemoveOperStmt *a, RemoveOperStmt *b)
987 if (!equalstr(a->opname, b->opname))
989 if (!equal(a->args, b->args))
997 _equalRenameStmt(RenameStmt *a, RenameStmt *b)
999 if (!equalstr(a->relname, b->relname))
1001 if (a->inhOpt != b->inhOpt)
1003 if (!equalstr(a->column, b->column))
1005 if (!equalstr(a->newname, b->newname))
1012 _equalRuleStmt(RuleStmt *a, RuleStmt *b)
1014 if (!equalstr(a->rulename, b->rulename))
1016 if (!equal(a->whereClause, b->whereClause))
1018 if (a->event != b->event)
1020 if (!equal(a->object, b->object))
1022 if (a->instead != b->instead)
1024 if (!equal(a->actions, b->actions))
1031 _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
1033 if (!equalstr(a->relname, b->relname))
1040 _equalListenStmt(ListenStmt *a, ListenStmt *b)
1042 if (!equalstr(a->relname, b->relname))
1049 _equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
1051 if (!equalstr(a->relname, b->relname))
1058 _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
1060 if (a->command != b->command)
1067 _equalViewStmt(ViewStmt *a, ViewStmt *b)
1069 if (!equalstr(a->viewname, b->viewname))
1071 if (!equal(a->aliases, b->aliases))
1073 if (!equal(a->query, b->query))
1080 _equalLoadStmt(LoadStmt *a, LoadStmt *b)
1082 if (!equalstr(a->filename, b->filename))
1089 _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
1091 if (!equalstr(a->dbname, b->dbname))
1093 if (!equalstr(a->dbpath, b->dbpath))
1095 if (!equalstr(a->dbtemplate, b->dbtemplate))
1097 if (a->encoding != b->encoding)
1104 _equalDropdbStmt(DropdbStmt *a, DropdbStmt *b)
1106 if (!equalstr(a->dbname, b->dbname))
1113 _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
1115 if (a->vacuum != b->vacuum)
1117 if (a->full != b->full)
1119 if (a->analyze != b->analyze)
1121 if (a->freeze != b->freeze)
1123 if (a->verbose != b->verbose)
1125 if (!equalstr(a->vacrel, b->vacrel))
1127 if (!equal(a->va_cols, b->va_cols))
1134 _equalExplainStmt(ExplainStmt *a, ExplainStmt *b)
1136 if (!equal(a->query, b->query))
1138 if (a->verbose != b->verbose)
1140 if (a->analyze != b->analyze)
1147 _equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b)
1149 if (!equalstr(a->seqname, b->seqname))
1151 if (!equal(a->options, b->options))
1158 _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
1160 if (!equalstr(a->name, b->name))
1162 if (!equal(a->args, b->args))
1169 _equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b)
1171 if (!equalstr(a->name, b->name))
1178 _equalVariableResetStmt(VariableResetStmt *a, VariableResetStmt *b)
1180 if (!equalstr(a->name, b->name))
1187 _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b)
1189 if (!equalstr(a->trigname, b->trigname))
1191 if (!equalstr(a->relname, b->relname))
1193 if (!equalstr(a->funcname, b->funcname))
1195 if (!equal(a->args, b->args))
1197 if (a->before != b->before)
1199 if (a->row != b->row)
1201 if (strcmp(a->actions, b->actions) != 0)
1203 if (!equalstr(a->lang, b->lang))
1205 if (!equalstr(a->text, b->text))
1207 if (!equal(a->attr, b->attr))
1209 if (!equalstr(a->when, b->when))
1211 if (a->isconstraint != b->isconstraint)
1213 if (a->deferrable != b->deferrable)
1215 if (a->initdeferred != b->initdeferred)
1217 if (!equalstr(a->constrrelname, b->constrrelname))
1224 _equalDropTrigStmt(DropTrigStmt *a, DropTrigStmt *b)
1226 if (!equalstr(a->trigname, b->trigname))
1228 if (!equalstr(a->relname, b->relname))
1235 _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b)
1237 if (!equalstr(a->plname, b->plname))
1239 if (!equalstr(a->plhandler, b->plhandler))
1241 if (!equalstr(a->plcompiler, b->plcompiler))
1243 if (a->pltrusted != b->pltrusted)
1250 _equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b)
1252 if (!equalstr(a->plname, b->plname))
1259 _equalCreateUserStmt(CreateUserStmt *a, CreateUserStmt *b)
1261 if (!equalstr(a->user, b->user))
1263 if (!equal(a->options, b->options))
1270 _equalAlterUserStmt(AlterUserStmt *a, AlterUserStmt *b)
1272 if (!equalstr(a->user, b->user))
1274 if (!equal(a->options, b->options))
1281 _equalDropUserStmt(DropUserStmt *a, DropUserStmt *b)
1283 if (!equal(a->users, b->users))
1290 _equalLockStmt(LockStmt *a, LockStmt *b)
1292 if (!equal(a->rellist, b->rellist))
1294 if (a->mode != b->mode)
1301 _equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b)
1303 if (!equal(a->constraints, b->constraints))
1305 if (a->deferred != b->deferred)
1312 _equalCreateGroupStmt(CreateGroupStmt *a, CreateGroupStmt *b)
1314 if (!equalstr(a->name, b->name))
1316 if (!equal(a->options, b->options))
1323 _equalAlterGroupStmt(AlterGroupStmt *a, AlterGroupStmt *b)
1325 if (!equalstr(a->name, b->name))
1327 if (a->action != b->action)
1329 if (!equal(a->listUsers, b->listUsers))
1336 _equalDropGroupStmt(DropGroupStmt *a, DropGroupStmt *b)
1338 if (!equalstr(a->name, b->name))
1345 _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
1347 if (a->reindexType != b->reindexType)
1349 if (!equalstr(a->name, b->name))
1351 if (a->force != b->force)
1353 if (a->all != b->all)
1360 _equalAExpr(A_Expr *a, A_Expr *b)
1362 if (a->oper != b->oper)
1364 if (!equalstr(a->opname, b->opname))
1366 if (!equal(a->lexpr, b->lexpr))
1368 if (!equal(a->rexpr, b->rexpr))
1375 _equalAttr(Attr *a, Attr *b)
1377 if (strcmp(a->relname, b->relname) != 0)
1379 if (!equal(a->paramNo, b->paramNo))
1381 if (!equal(a->attrs, b->attrs))
1383 if (!equal(a->indirection, b->indirection))
1390 _equalAConst(A_Const *a, A_Const *b)
1392 if (!equal(&a->val, &b->val))
1394 if (!equal(a->typename, b->typename))
1401 _equalParamNo(ParamNo *a, ParamNo *b)
1403 if (a->number != b->number)
1405 if (!equal(a->typename, b->typename))
1407 if (!equal(a->indirection, b->indirection))
1414 _equalIdent(Ident *a, Ident *b)
1416 if (!equalstr(a->name, b->name))
1418 if (!equal(a->indirection, b->indirection))
1420 if (a->isRel != b->isRel)
1427 _equalFuncCall(FuncCall *a, FuncCall *b)
1429 if (!equalstr(a->funcname, b->funcname))
1431 if (!equal(a->args, b->args))
1433 if (a->agg_star != b->agg_star)
1435 if (a->agg_distinct != b->agg_distinct)
1442 _equalAIndices(A_Indices *a, A_Indices *b)
1444 if (!equal(a->lidx, b->lidx))
1446 if (!equal(a->uidx, b->uidx))
1453 _equalResTarget(ResTarget *a, ResTarget *b)
1455 if (!equalstr(a->name, b->name))
1457 if (!equal(a->indirection, b->indirection))
1459 if (!equal(a->val, b->val))
1466 _equalTypeCast(TypeCast *a, TypeCast *b)
1468 if (!equal(a->arg, b->arg))
1470 if (!equal(a->typename, b->typename))
1477 _equalSortGroupBy(SortGroupBy *a, SortGroupBy *b)
1479 if (!equalstr(a->useOp, b->useOp))
1481 if (!equal(a->node, b->node))
1488 _equalRangeVar(RangeVar *a, RangeVar *b)
1490 if (!equalstr(a->relname, b->relname))
1492 if (a->inhOpt != b->inhOpt)
1494 if (!equal(a->name, b->name))
1501 _equalRangeSubselect(RangeSubselect *a, RangeSubselect *b)
1503 if (!equal(a->subquery, b->subquery))
1505 if (!equal(a->name, b->name))
1512 _equalTypeName(TypeName *a, TypeName *b)
1514 if (!equalstr(a->name, b->name))
1516 if (a->timezone != b->timezone)
1518 if (a->setof != b->setof)
1520 if (a->typmod != b->typmod)
1522 if (!equal(a->arrayBounds, b->arrayBounds))
1529 _equalIndexElem(IndexElem *a, IndexElem *b)
1531 if (!equalstr(a->name, b->name))
1533 if (!equal(a->args, b->args))
1535 if (!equalstr(a->class, b->class))
1542 _equalColumnDef(ColumnDef *a, ColumnDef *b)
1544 if (!equalstr(a->colname, b->colname))
1546 if (!equal(a->typename, b->typename))
1548 if (a->is_not_null != b->is_not_null)
1550 if (!equal(a->raw_default, b->raw_default))
1552 if (!equalstr(a->cooked_default, b->cooked_default))
1554 if (!equal(a->constraints, b->constraints))
1561 _equalConstraint(Constraint *a, Constraint *b)
1563 if (a->contype != b->contype)
1565 if (!equalstr(a->name, b->name))
1567 if (!equal(a->raw_expr, b->raw_expr))
1569 if (!equalstr(a->cooked_expr, b->cooked_expr))
1571 if (!equal(a->keys, b->keys))
1578 _equalDefElem(DefElem *a, DefElem *b)
1580 if (!equalstr(a->defname, b->defname))
1582 if (!equal(a->arg, b->arg))
1589 _equalTargetEntry(TargetEntry *a, TargetEntry *b)
1591 if (!equal(a->resdom, b->resdom))
1593 if (!equal(a->fjoin, b->fjoin))
1595 if (!equal(a->expr, b->expr))
1602 _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
1604 if (!equalstr(a->relname, b->relname))
1606 if (a->relid != b->relid)
1608 if (!equal(a->subquery, b->subquery))
1610 if (!equal(a->alias, b->alias))
1612 if (!equal(a->eref, b->eref))
1614 if (a->inh != b->inh)
1616 if (a->inFromCl != b->inFromCl)
1618 if (a->checkForRead != b->checkForRead)
1620 if (a->checkForWrite != b->checkForWrite)
1622 if (a->checkAsUser != b->checkAsUser)
1629 _equalSortClause(SortClause *a, SortClause *b)
1631 if (a->tleSortGroupRef != b->tleSortGroupRef)
1633 if (a->sortop != b->sortop)
1640 _equalFkConstraint(FkConstraint *a, FkConstraint *b)
1642 if (!equalstr(a->constr_name, b->constr_name))
1644 if (!equalstr(a->pktable_name, b->pktable_name))
1646 if (!equal(a->fk_attrs, b->fk_attrs))
1648 if (!equal(a->pk_attrs, b->pk_attrs))
1650 if (!equalstr(a->match_type, b->match_type))
1652 if (a->actions != b->actions)
1654 if (a->deferrable != b->deferrable)
1656 if (a->initdeferred != b->initdeferred)
1663 _equalCaseExpr(CaseExpr *a, CaseExpr *b)
1665 if (a->casetype != b->casetype)
1667 if (!equal(a->arg, b->arg))
1669 if (!equal(a->args, b->args))
1671 if (!equal(a->defresult, b->defresult))
1678 _equalCaseWhen(CaseWhen *a, CaseWhen *b)
1680 if (!equal(a->expr, b->expr))
1682 if (!equal(a->result, b->result))
1689 _equalNullTest(NullTest *a, NullTest *b)
1691 if (!equal(a->arg, b->arg))
1693 if (a->nulltesttype != b->nulltesttype)
1699 _equalBooleanTest(BooleanTest *a, BooleanTest *b)
1701 if (!equal(a->arg, b->arg))
1703 if (a->booltesttype != b->booltesttype)
1709 * Stuff from pg_list.h
1713 _equalValue(Value *a, Value *b)
1715 if (a->type != b->type)
1721 return a->val.ival == b->val.ival;
1725 return strcmp(a->val.str, b->val.str) == 0;
1735 * returns whether two nodes are equal
1738 equal(void *a, void *b)
1740 bool retval = false;
1746 * note that a!=b, so only one of them can be NULL
1748 if (a == NULL || b == NULL)
1752 * are they the same type of nodes?
1754 if (nodeTag(a) != nodeTag(b))
1760 retval = _equalSubPlan(a, b);
1764 retval = _equalResdom(a, b);
1767 retval = _equalFjoin(a, b);
1770 retval = _equalExpr(a, b);
1773 retval = _equalVar(a, b);
1776 retval = _equalOper(a, b);
1779 retval = _equalConst(a, b);
1782 retval = _equalParam(a, b);
1785 retval = _equalAggref(a, b);
1788 retval = _equalSubLink(a, b);
1791 retval = _equalFunc(a, b);
1794 retval = _equalFieldSelect(a, b);
1797 retval = _equalArrayRef(a, b);
1800 retval = _equalIter(a, b);
1803 retval = _equalRelabelType(a, b);
1806 retval = _equalRangeTblRef(a, b);
1809 retval = _equalFromExpr(a, b);
1812 retval = _equalJoinExpr(a, b);
1816 retval = _equalRelOptInfo(a, b);
1819 retval = _equalPath(a, b);
1822 retval = _equalIndexPath(a, b);
1825 retval = _equalNestPath(a, b);
1828 retval = _equalMergePath(a, b);
1831 retval = _equalHashPath(a, b);
1834 retval = _equalPathKeyItem(a, b);
1836 case T_RestrictInfo:
1837 retval = _equalRestrictInfo(a, b);
1840 retval = _equalJoinInfo(a, b);
1843 retval = _equalStream(a, b);
1846 retval = _equalTidPath(a, b);
1849 retval = _equalAppendPath(a, b);
1851 case T_IndexOptInfo:
1852 retval = _equalIndexOptInfo(a, b);
1857 List *la = (List *) a;
1858 List *lb = (List *) b;
1862 * Try to reject by length check before we grovel through
1863 * all the elements...
1865 if (length(la) != length(lb))
1869 if (!equal(lfirst(l), lfirst(lb)))
1880 retval = _equalValue(a, b);
1884 retval = _equalQuery(a, b);
1887 retval = _equalInsertStmt(a, b);
1890 retval = _equalDeleteStmt(a, b);
1893 retval = _equalUpdateStmt(a, b);
1896 retval = _equalSelectStmt(a, b);
1898 case T_SetOperationStmt:
1899 retval = _equalSetOperationStmt(a, b);
1901 case T_AlterTableStmt:
1902 retval = _equalAlterTableStmt(a, b);
1905 retval = _equalGrantStmt(a, b);
1907 case T_ClosePortalStmt:
1908 retval = _equalClosePortalStmt(a, b);
1911 retval = _equalClusterStmt(a, b);
1914 retval = _equalCopyStmt(a, b);
1917 retval = _equalCreateStmt(a, b);
1920 retval = _equalVersionStmt(a, b);
1923 retval = _equalDefineStmt(a, b);
1926 retval = _equalDropStmt(a, b);
1928 case T_TruncateStmt:
1929 retval = _equalTruncateStmt(a, b);
1932 retval = _equalCommentStmt(a, b);
1935 retval = _equalFetchStmt(a, b);
1938 retval = _equalIndexStmt(a, b);
1940 case T_ProcedureStmt:
1941 retval = _equalProcedureStmt(a, b);
1943 case T_RemoveAggrStmt:
1944 retval = _equalRemoveAggrStmt(a, b);
1946 case T_RemoveFuncStmt:
1947 retval = _equalRemoveFuncStmt(a, b);
1949 case T_RemoveOperStmt:
1950 retval = _equalRemoveOperStmt(a, b);
1953 retval = _equalRenameStmt(a, b);
1956 retval = _equalRuleStmt(a, b);
1959 retval = _equalNotifyStmt(a, b);
1962 retval = _equalListenStmt(a, b);
1964 case T_UnlistenStmt:
1965 retval = _equalUnlistenStmt(a, b);
1967 case T_TransactionStmt:
1968 retval = _equalTransactionStmt(a, b);
1971 retval = _equalViewStmt(a, b);
1974 retval = _equalLoadStmt(a, b);
1976 case T_CreatedbStmt:
1977 retval = _equalCreatedbStmt(a, b);
1980 retval = _equalDropdbStmt(a, b);
1983 retval = _equalVacuumStmt(a, b);
1986 retval = _equalExplainStmt(a, b);
1988 case T_CreateSeqStmt:
1989 retval = _equalCreateSeqStmt(a, b);
1991 case T_VariableSetStmt:
1992 retval = _equalVariableSetStmt(a, b);
1994 case T_VariableShowStmt:
1995 retval = _equalVariableShowStmt(a, b);
1997 case T_VariableResetStmt:
1998 retval = _equalVariableResetStmt(a, b);
2000 case T_CreateTrigStmt:
2001 retval = _equalCreateTrigStmt(a, b);
2003 case T_DropTrigStmt:
2004 retval = _equalDropTrigStmt(a, b);
2006 case T_CreatePLangStmt:
2007 retval = _equalCreatePLangStmt(a, b);
2009 case T_DropPLangStmt:
2010 retval = _equalDropPLangStmt(a, b);
2012 case T_CreateUserStmt:
2013 retval = _equalCreateUserStmt(a, b);
2015 case T_AlterUserStmt:
2016 retval = _equalAlterUserStmt(a, b);
2018 case T_DropUserStmt:
2019 retval = _equalDropUserStmt(a, b);
2022 retval = _equalLockStmt(a, b);
2024 case T_ConstraintsSetStmt:
2025 retval = _equalConstraintsSetStmt(a, b);
2027 case T_CreateGroupStmt:
2028 retval = _equalCreateGroupStmt(a, b);
2030 case T_AlterGroupStmt:
2031 retval = _equalAlterGroupStmt(a, b);
2033 case T_DropGroupStmt:
2034 retval = _equalDropGroupStmt(a, b);
2037 retval = _equalReindexStmt(a, b);
2039 case T_CheckPointStmt:
2044 retval = _equalAExpr(a, b);
2047 retval = _equalAttr(a, b);
2050 retval = _equalAConst(a, b);
2053 retval = _equalParamNo(a, b);
2056 retval = _equalIdent(a, b);
2059 retval = _equalFuncCall(a, b);
2062 retval = _equalAIndices(a, b);
2065 retval = _equalResTarget(a, b);
2068 retval = _equalTypeCast(a, b);
2071 retval = _equalSortGroupBy(a, b);
2074 retval = _equalRangeVar(a, b);
2076 case T_RangeSubselect:
2077 retval = _equalRangeSubselect(a, b);
2080 retval = _equalTypeName(a, b);
2083 retval = _equalIndexElem(a, b);
2086 retval = _equalColumnDef(a, b);
2089 retval = _equalConstraint(a, b);
2092 retval = _equalDefElem(a, b);
2095 retval = _equalTargetEntry(a, b);
2097 case T_RangeTblEntry:
2098 retval = _equalRangeTblEntry(a, b);
2101 retval = _equalSortClause(a, b);
2104 /* GroupClause is equivalent to SortClause */
2105 retval = _equalSortClause(a, b);
2108 retval = _equalCaseExpr(a, b);
2111 retval = _equalCaseWhen(a, b);
2114 retval = _equalNullTest(a, b);
2117 retval = _equalBooleanTest(a, b);
2119 case T_FkConstraint:
2120 retval = _equalFkConstraint(a, b);
2123 retval = _equalPrivGrantee(a, b);
2127 elog(NOTICE, "equal: don't know whether nodes of type %d are equal",