postgresql/src/backend/nodes/equalfuncs.c

901 lines
17 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* equalfuncs.c
* equal functions to compare the nodes
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.44 1999/07/24 23:21:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "nodes/plannodes.h"
1999-07-16 07:00:38 +02:00
#include "nodes/relation.h"
#include "utils/datum.h"
static bool equali(List *a, List *b);
/*
* Stuff from primnodes.h
*/
/*
* Resdom is a subclass of Node.
*/
static bool
_equalResdom(Resdom *a, Resdom *b)
{
if (a->resno != b->resno)
1998-09-01 05:29:17 +02:00
return false;
if (a->restype != b->restype)
1998-09-01 05:29:17 +02:00
return false;
if (a->restypmod != b->restypmod)
1998-09-01 05:29:17 +02:00
return false;
if (strcmp(a->resname, b->resname) != 0)
1998-09-01 05:29:17 +02:00
return false;
if (a->reskey != b->reskey)
1998-09-01 05:29:17 +02:00
return false;
if (a->resgroupref != b->resgroupref)
return false;
if (a->reskeyop != b->reskeyop)
1998-09-01 05:29:17 +02:00
return false;
1998-09-01 05:29:17 +02:00
return true;
}
static bool
_equalFjoin(Fjoin *a, Fjoin *b)
{
int nNodes;
if (a->fj_initialized != b->fj_initialized)
1998-09-01 05:29:17 +02:00
return false;
if (a->fj_nNodes != b->fj_nNodes)
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->fj_innerNode, b->fj_innerNode))
1998-09-01 05:29:17 +02:00
return false;
nNodes = a->fj_nNodes;
if (memcmp(a->fj_results, b->fj_results, nNodes * sizeof(Datum)) != 0)
1998-09-01 05:29:17 +02:00
return false;
if (memcmp(a->fj_alwaysDone, b->fj_alwaysDone, nNodes * sizeof(bool)) != 0)
1998-09-01 05:29:17 +02:00
return false;
1998-09-01 05:29:17 +02:00
return true;
}
/*
* Expr is a subclass of Node.
*/
static bool
_equalExpr(Expr *a, Expr *b)
{
if (a->opType != b->opType)
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->oper, b->oper))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->args, b->args))
1998-09-01 05:29:17 +02:00
return false;
1998-09-01 05:29:17 +02:00
return true;
}
static bool
_equalIter(Iter *a, Iter *b)
{
1998-09-01 05:29:17 +02:00
return equal(a->iterexpr, b->iterexpr);
}
static bool
_equalStream(Stream *a, Stream *b)
{
if (a->clausetype != b->clausetype)
1998-09-01 05:29:17 +02:00
return false;
if (a->groupup != b->groupup)
1998-09-01 05:29:17 +02:00
return false;
if (a->groupcost != b->groupcost)
1998-09-01 05:29:17 +02:00
return false;
if (a->groupsel != b->groupsel)
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->pathptr, b->pathptr))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->cinfo, b->cinfo))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->upstream, b->upstream))
1998-09-01 05:29:17 +02:00
return false;
return equal(a->downstream, b->downstream);
}
/*
* Var is a subclass of Expr.
*/
static bool
_equalVar(Var *a, Var *b)
{
if (a->varno != b->varno)
1998-09-01 05:29:17 +02:00
return false;
if (a->varattno != b->varattno)
1998-09-01 05:29:17 +02:00
return false;
if (a->vartype != b->vartype)
1998-09-01 05:29:17 +02:00
return false;
if (a->vartypmod != b->vartypmod)
1998-09-01 05:29:17 +02:00
return false;
if (a->varlevelsup != b->varlevelsup)
1998-09-01 05:29:17 +02:00
return false;
if (a->varnoold != b->varnoold)
1998-09-01 05:29:17 +02:00
return false;
if (a->varoattno != b->varoattno)
1998-09-01 05:29:17 +02:00
return false;
1998-09-01 05:29:17 +02:00
return true;
}
static bool
1997-09-08 22:59:27 +02:00
_equalArray(Array *a, Array *b)
{
if (a->arrayelemtype != b->arrayelemtype)
1998-09-01 05:29:17 +02:00
return false;
if (a->arrayndim != b->arrayndim)
1998-09-01 05:29:17 +02:00
return false;
if (a->arraylow.indx[0] != b->arraylow.indx[0])
1998-09-01 05:29:17 +02:00
return false;
if (a->arrayhigh.indx[0] != b->arrayhigh.indx[0])
1998-09-01 05:29:17 +02:00
return false;
if (a->arraylen != b->arraylen)
1998-09-01 05:29:17 +02:00
return false;
return TRUE;
}
static bool
1997-09-08 22:59:27 +02:00
_equalArrayRef(ArrayRef *a, ArrayRef *b)
{
if (a->refelemtype != b->refelemtype)
1998-09-01 05:29:17 +02:00
return false;
if (a->refattrlength != b->refattrlength)
1998-09-01 05:29:17 +02:00
return false;
if (a->refelemlength != b->refelemlength)
1998-09-01 05:29:17 +02:00
return false;
if (a->refelembyval != b->refelembyval)
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->refupperindexpr, b->refupperindexpr))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->reflowerindexpr, b->reflowerindexpr))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->refexpr, b->refexpr))
1998-09-01 05:29:17 +02:00
return false;
return equal(a->refassgnexpr, b->refassgnexpr);
}
/*
* Oper is a subclass of Expr.
*/
static bool
_equalOper(Oper *a, Oper *b)
{
if (a->opno != b->opno)
1998-09-01 05:29:17 +02:00
return false;
if (a->opresulttype != b->opresulttype)
1998-09-01 05:29:17 +02:00
return false;
1998-09-01 05:29:17 +02:00
return true;
}
/*
* Const is a subclass of Expr.
*/
static bool
_equalConst(Const *a, Const *b)
{
/*
* * this function used to do a pointer compare on a and b. That's *
* ridiculous. -- JMH, 7/11/92
*/
if (a->consttype != b->consttype)
1998-09-01 05:29:17 +02:00
return false;
if (a->constlen != b->constlen)
1998-09-01 05:29:17 +02:00
return false;
if (a->constisnull != b->constisnull)
1998-09-01 05:29:17 +02:00
return false;
if (a->constbyval != b->constbyval)
1998-09-01 05:29:17 +02:00
return false;
return (datumIsEqual(a->constvalue, b->constvalue,
a->consttype, a->constbyval, a->constlen));
}
/*
* Param is a subclass of Expr.
*/
static bool
_equalParam(Param *a, Param *b)
{
if (a->paramkind != b->paramkind)
1998-09-01 05:29:17 +02:00
return false;
if (a->paramtype != b->paramtype)
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->param_tlist, b->param_tlist))
1998-09-01 05:29:17 +02:00
return false;
switch (a->paramkind)
{
case PARAM_NAMED:
case PARAM_NEW:
case PARAM_OLD:
if (strcmp(a->paramname, b->paramname) != 0)
1998-09-01 05:29:17 +02:00
return false;
break;
case PARAM_NUM:
case PARAM_EXEC:
if (a->paramid != b->paramid)
1998-09-01 05:29:17 +02:00
return false;
break;
case PARAM_INVALID:
/*
* XXX: Hmmm... What are we supposed to return in this case ??
*/
1998-09-01 05:29:17 +02:00
return true;
break;
default:
elog(ERROR, "_equalParam: Invalid paramkind value: %d",
a->paramkind);
}
1998-09-01 05:29:17 +02:00
return true;
}
/*
* Aggref is a subclass of Expr.
*/
static bool
_equalAggref(Aggref *a, Aggref *b)
{
if (strcmp(a->aggname, b->aggname) != 0)
return false;
if (a->basetype != b->basetype)
return false;
if (a->aggtype != b->aggtype)
return false;
if (!equal(a->target, b->target))
return false;
if (a->aggno != b->aggno)
return false;
if (a->usenulls != b->usenulls)
return false;
return true;
}
/*
* Func is a subclass of Expr.
*/
static bool
_equalFunc(Func *a, Func *b)
{
if (a->funcid != b->funcid)
1998-09-01 05:29:17 +02:00
return false;
if (a->functype != b->functype)
1998-09-01 05:29:17 +02:00
return false;
if (a->funcisindex != b->funcisindex)
1998-09-01 05:29:17 +02:00
return false;
if (a->funcsize != b->funcsize)
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->func_tlist, b->func_tlist))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->func_planlist, b->func_planlist))
1998-09-01 05:29:17 +02:00
return false;
1998-09-01 05:29:17 +02:00
return true;
}
/*
* RestrictInfo is a subclass of Node.
*/
static bool
1999-05-26 00:43:53 +02:00
_equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
{
Assert(IsA(a, RestrictInfo));
Assert(IsA(b, RestrictInfo));
if (!equal(a->clause, b->clause))
1998-09-01 05:29:17 +02:00
return false;
if (a->selectivity != b->selectivity)
1998-09-01 05:29:17 +02:00
return false;
#ifdef EqualMergeOrderExists
if (!EqualMergeOrder(a->mergejoinorder, b->mergejoinorder))
1998-09-01 05:29:17 +02:00
return false;
#endif
if (a->hashjoinoperator != b->hashjoinoperator)
1998-09-01 05:29:17 +02:00
return false;
return equal(a->indexids, b->indexids);
}
1998-08-02 00:12:13 +02:00
/*
* RelOptInfo is a subclass of Node.
*/
static bool
1999-05-26 00:43:53 +02:00
_equalRelOptInfo(RelOptInfo *a, RelOptInfo *b)
1998-08-02 00:12:13 +02:00
{
Assert(IsA(a, RelOptInfo));
Assert(IsA(b, RelOptInfo));
return equal(a->relids, b->relids);
1998-08-02 00:12:13 +02:00
}
static bool
_equalJoinMethod(JoinMethod *a, JoinMethod *b)
{
Assert(IsA(a, JoinMethod));
Assert(IsA(b, JoinMethod));
if (!equal(a->jmkeys, b->jmkeys))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->clauses, b->clauses))
1998-09-01 05:29:17 +02:00
return false;
return true;
}
static bool
_equalPath(Path *a, Path *b)
{
if (a->pathtype != b->pathtype)
1998-09-01 05:29:17 +02:00
return false;
if (a->parent != b->parent)
1998-09-01 05:29:17 +02:00
return false;
/*
* if (a->path_cost != b->path_cost) return(false);
*/
1999-02-11 15:59:09 +01:00
if (a->pathorder->ordtype == SORTOP_ORDER)
{
int i = 0;
1999-02-11 15:59:09 +01:00
if (a->pathorder->ord.sortop == NULL ||
b->pathorder->ord.sortop == NULL)
{
1999-02-11 15:59:09 +01:00
if (a->pathorder->ord.sortop != b->pathorder->ord.sortop)
return false;
}
else
{
1999-02-11 15:59:09 +01:00
while (a->pathorder->ord.sortop[i] != 0 &&
b->pathorder->ord.sortop[i] != 0)
{
1999-02-11 15:59:09 +01:00
if (a->pathorder->ord.sortop[i] != b->pathorder->ord.sortop[i])
return false;
i++;
}
1999-02-11 15:59:09 +01:00
if (a->pathorder->ord.sortop[i] != 0 ||
b->pathorder->ord.sortop[i] != 0)
return false;
}
}
else
{
1999-02-11 15:59:09 +01:00
if (!equal(a->pathorder->ord.merge, b->pathorder->ord.merge))
1998-09-01 05:29:17 +02:00
return false;
}
if (!equal(a->pathkeys, b->pathkeys))
1998-09-01 05:29:17 +02:00
return false;
/*
* if (a->outerjoincost != b->outerjoincost) return(false);
*/
if (!equali(a->joinid, b->joinid))
1998-09-01 05:29:17 +02:00
return false;
return true;
}
static bool
_equalIndexPath(IndexPath *a, IndexPath *b)
{
if (!_equalPath((Path *) a, (Path *) b))
1998-09-01 05:29:17 +02:00
return false;
if (!equali(a->indexid, b->indexid))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->indexqual, b->indexqual))
1998-09-01 05:29:17 +02:00
return false;
return true;
}
static bool
1999-05-26 00:43:53 +02:00
_equalNestPath(NestPath *a, NestPath *b)
{
Assert(IsA_JoinPath(a));
Assert(IsA_JoinPath(b));
if (!_equalPath((Path *) a, (Path *) b))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->pathinfo, b->pathinfo))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->outerjoinpath, b->outerjoinpath))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->innerjoinpath, b->innerjoinpath))
1998-09-01 05:29:17 +02:00
return false;
return true;
}
static bool
_equalMergePath(MergePath *a, MergePath *b)
{
Assert(IsA(a, MergePath));
Assert(IsA(b, MergePath));
1999-02-12 07:43:53 +01:00
if (!_equalNestPath((NestPath *) a, (NestPath *) b))
1998-09-01 05:29:17 +02:00
return false;
1999-02-03 00:53:26 +01:00
if (!equal(a->path_mergeclauses, b->path_mergeclauses))
1998-09-01 05:29:17 +02:00
return false;
1999-02-03 00:53:26 +01:00
if (!equal(a->outersortkeys, b->outersortkeys))
1998-09-01 05:29:17 +02:00
return false;
1999-02-03 00:53:26 +01:00
if (!equal(a->innersortkeys, b->innersortkeys))
1998-09-01 05:29:17 +02:00
return false;
return true;
}
static bool
_equalHashPath(HashPath *a, HashPath *b)
{
Assert(IsA(a, HashPath));
Assert(IsA(b, HashPath));
1999-02-12 07:43:53 +01:00
if (!_equalNestPath((NestPath *) a, (NestPath *) b))
1998-09-01 05:29:17 +02:00
return false;
if (!equal((a->path_hashclauses), (b->path_hashclauses)))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->outerhashkeys, b->outerhashkeys))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->innerhashkeys, b->innerhashkeys))
1998-09-01 05:29:17 +02:00
return false;
return true;
}
static bool
_equalJoinKey(JoinKey *a, JoinKey *b)
{
Assert(IsA(a, JoinKey));
Assert(IsA(b, JoinKey));
if (!equal(a->outer, b->outer))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->inner, b->inner))
1998-09-01 05:29:17 +02:00
return false;
return true;
}
static bool
_equalMergeOrder(MergeOrder *a, MergeOrder *b)
{
if (a == (MergeOrder *) NULL && b == (MergeOrder *) NULL)
1998-09-01 05:29:17 +02:00
return true;
Assert(IsA(a, MergeOrder));
Assert(IsA(b, MergeOrder));
if (a->join_operator != b->join_operator)
1998-09-01 05:29:17 +02:00
return false;
if (a->left_operator != b->left_operator)
1998-09-01 05:29:17 +02:00
return false;
if (a->right_operator != b->right_operator)
1998-09-01 05:29:17 +02:00
return false;
if (a->left_type != b->left_type)
1998-09-01 05:29:17 +02:00
return false;
if (a->right_type != b->right_type)
1998-09-01 05:29:17 +02:00
return false;
return true;
}
static bool
1999-05-26 00:43:53 +02:00
_equalHashInfo(HashInfo *a, HashInfo *b)
{
Assert(IsA(a, HashInfo));
Assert(IsA(b, HashInfo));
if (a->hashop != b->hashop)
1998-09-01 05:29:17 +02:00
return false;
return true;
}
/* XXX This equality function is a quick hack, should be
* fixed to compare all fields.
*/
static bool
_equalIndexScan(IndexScan *a, IndexScan *b)
{
Assert(IsA(a, IndexScan));
Assert(IsA(b, IndexScan));
/*
* if(a->scan.plan.cost != b->scan.plan.cost) return(false);
*/
if (!equal(a->indxqual, b->indxqual))
1998-09-01 05:29:17 +02:00
return false;
if (a->scan.scanrelid != b->scan.scanrelid)
1998-09-01 05:29:17 +02:00
return false;
if (!equali(a->indxid, b->indxid))
1998-09-01 05:29:17 +02:00
return false;
return true;
}
static bool
_equalSubPlan(SubPlan *a, SubPlan *b)
{
if (a->plan_id != b->plan_id)
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->sublink->oper, b->sublink->oper))
1998-09-01 05:29:17 +02:00
return false;
1998-09-01 05:29:17 +02:00
return true;
}
static bool
1999-05-26 00:43:53 +02:00
_equalJoinInfo(JoinInfo *a, JoinInfo *b)
{
1998-09-01 05:29:17 +02:00
Assert(IsA(a, JoinInfo));
Assert(IsA(b, JoinInfo));
1999-02-18 01:49:48 +01:00
if (!equal(a->unjoined_relids, b->unjoined_relids))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->jinfo_restrictinfo, b->jinfo_restrictinfo))
1998-09-01 05:29:17 +02:00
return false;
if (a->mergejoinable != b->mergejoinable)
1998-09-01 05:29:17 +02:00
return false;
if (a->hashjoinable != b->hashjoinable)
1998-09-01 05:29:17 +02:00
return false;
return true;
}
/*
* Stuff from execnodes.h
*/
/*
* EState is a subclass of Node.
*/
static bool
_equalEState(EState *a, EState *b)
{
if (a->es_direction != b->es_direction)
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->es_range_table, b->es_range_table))
1998-09-01 05:29:17 +02:00
return false;
if (a->es_result_relation_info != b->es_result_relation_info)
1998-09-01 05:29:17 +02:00
return false;
1998-09-01 05:29:17 +02:00
return true;
}
/*
* Stuff from parsenodes.h
*/
static bool
_equalQuery(Query *a, Query *b)
{
if (a->commandType != b->commandType)
return false;
if (!equal(a->utilityStmt, b->utilityStmt))
return false;
if (a->resultRelation != b->resultRelation)
return false;
1999-05-25 18:15:34 +02:00
if (a->into && b->into)
{
if (strcmp(a->into, b->into) != 0)
return false;
1999-05-25 18:15:34 +02:00
}
else
{
if (a->into != b->into)
return false;
}
if (a->isPortal != b->isPortal)
return false;
if (a->isBinary != b->isBinary)
return false;
if (a->isTemp != b->isTemp)
return false;
if (a->unionall != b->unionall)
return false;
if (a->hasAggs != b->hasAggs)
return false;
if (a->hasSubLinks != b->hasSubLinks)
return false;
1999-05-25 18:15:34 +02:00
if (a->uniqueFlag && b->uniqueFlag)
{
if (strcmp(a->uniqueFlag, b->uniqueFlag) != 0)
return false;
1999-05-25 18:15:34 +02:00
}
else
{
if (a->uniqueFlag != b->uniqueFlag)
return false;
}
if (!equal(a->sortClause, b->sortClause))
return false;
if (!equal(a->rtable, b->rtable))
return false;
if (!equal(a->targetList, b->targetList))
return false;
if (!equal(a->qual, b->qual))
return false;
if (!equal(a->rowMark, b->rowMark))
return false;
if (!equal(a->groupClause, b->groupClause))
return false;
if (!equal(a->havingQual, b->havingQual))
return false;
if (!equal(a->intersectClause, b->intersectClause))
return false;
if (!equal(a->unionClause, b->unionClause))
return false;
if (!equal(a->limitOffset, b->limitOffset))
return false;
if (!equal(a->limitCount, b->limitCount))
return false;
1999-05-25 18:15:34 +02:00
/*
* We do not check the internal-to-the-planner fields base_rel_list
* and join_rel_list. They might not be set yet, and in any case they
* should be derivable from the other fields.
*/
return true;
}
static bool
_equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
{
1999-05-25 18:15:34 +02:00
if (a->relname && b->relname)
{
if (strcmp(a->relname, b->relname) != 0)
return false;
1999-05-25 18:15:34 +02:00
}
else
{
if (a->relname != b->relname)
return false;
}
1999-05-25 18:15:34 +02:00
if (a->refname && b->refname)
{
if (strcmp(a->refname, b->refname) != 0)
return false;
1999-05-25 18:15:34 +02:00
}
else
{
if (a->refname != b->refname)
return false;
}
if (a->relid != b->relid)
return false;
if (a->inh != b->inh)
return false;
if (a->inFromCl != b->inFromCl)
return false;
if (a->skipAcl != b->skipAcl)
return false;
return true;
}
static bool
_equalTargetEntry(TargetEntry *a, TargetEntry *b)
{
if (!equal(a->resdom, b->resdom))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->fjoin, b->fjoin))
1998-09-01 05:29:17 +02:00
return false;
if (!equal(a->expr, b->expr))
1998-09-01 05:29:17 +02:00
return false;
1998-09-01 05:29:17 +02:00
return true;
}
/*
* Stuff from pg_list.h
*/
static bool
_equalValue(Value *a, Value *b)
{
if (a->type != b->type)
1998-09-01 05:29:17 +02:00
return false;
switch (a->type)
{
case T_String:
return strcmp(a->val.str, b->val.str);
case T_Integer:
1998-09-01 05:29:17 +02:00
return a->val.ival == b->val.ival;
case T_Float:
1998-09-01 05:29:17 +02:00
return a->val.dval == b->val.dval;
default:
break;
}
1998-09-01 05:29:17 +02:00
return true;
}
/*
* equal
* returns whether two nodes are equal
*/
bool
equal(void *a, void *b)
{
bool retval = false;
if (a == b)
1998-09-01 05:29:17 +02:00
return true;
/*
* note that a!=b, so only one of them can be NULL
*/
if (a == NULL || b == NULL)
1998-09-01 05:29:17 +02:00
return false;
/*
* are they the same type of nodes?
*/
if (nodeTag(a) != nodeTag(b))
1998-09-01 05:29:17 +02:00
return false;
switch (nodeTag(a))
{
case T_Resdom:
retval = _equalResdom(a, b);
break;
case T_Fjoin:
retval = _equalFjoin(a, b);
break;
case T_Expr:
retval = _equalExpr(a, b);
break;
case T_Iter:
retval = _equalIter(a, b);
break;
case T_Stream:
retval = _equalStream(a, b);
break;
case T_Var:
retval = _equalVar(a, b);
break;
case T_Array:
retval = _equalArray(a, b);
break;
case T_ArrayRef:
retval = _equalArrayRef(a, b);
break;
case T_Oper:
retval = _equalOper(a, b);
break;
case T_Const:
retval = _equalConst(a, b);
break;
case T_Param:
retval = _equalParam(a, b);
break;
case T_Aggref:
retval = _equalAggref(a, b);
break;
case T_Func:
retval = _equalFunc(a, b);
break;
case T_RestrictInfo:
retval = _equalRestrictInfo(a, b);
break;
1998-08-02 00:12:13 +02:00
case T_RelOptInfo:
retval = _equalRelOptInfo(a, b);
break;
case T_JoinMethod:
retval = _equalJoinMethod(a, b);
break;
case T_Path:
retval = _equalPath(a, b);
break;
case T_IndexPath:
retval = _equalIndexPath(a, b);
break;
1999-02-12 07:43:53 +01:00
case T_NestPath:
retval = _equalNestPath(a, b);
break;
case T_MergePath:
retval = _equalMergePath(a, b);
break;
case T_HashPath:
retval = _equalHashPath(a, b);
break;
case T_JoinKey:
retval = _equalJoinKey(a, b);
break;
case T_MergeOrder:
retval = _equalMergeOrder(a, b);
break;
case T_HashInfo:
retval = _equalHashInfo(a, b);
break;
case T_IndexScan:
retval = _equalIndexScan(a, b);
break;
case T_SubPlan:
retval = _equalSubPlan(a, b);
break;
1998-09-01 05:29:17 +02:00
case T_JoinInfo:
retval = _equalJoinInfo(a, b);
break;
case T_EState:
retval = _equalEState(a, b);
break;
case T_Integer:
case T_String:
case T_Float:
retval = _equalValue(a, b);
break;
case T_List:
{
List *la = (List *) a;
List *lb = (List *) b;
List *l;
if (a == NULL && b == NULL)
1998-09-01 05:29:17 +02:00
return true;
if (length(a) != length(b))
1998-09-01 05:29:17 +02:00
return false;
foreach(l, la)
{
if (!equal(lfirst(l), lfirst(lb)))
1998-09-01 05:29:17 +02:00
return false;
lb = lnext(lb);
}
retval = true;
}
break;
case T_Query:
retval = _equalQuery(a, b);
break;
case T_RangeTblEntry:
retval = _equalRangeTblEntry(a, b);
break;
case T_TargetEntry:
retval = _equalTargetEntry(a, b);
break;
default:
elog(NOTICE, "equal: don't know whether nodes of type %d are equal",
nodeTag(a));
break;
}
return retval;
}
/*
* equali
* compares two lists of integers
*
* XXX temp hack. needs something like T_IntList
*/
static bool
equali(List *a, List *b)
{
List *la = (List *) a;
List *lb = (List *) b;
List *l;
if (a == NULL && b == NULL)
1998-09-01 05:29:17 +02:00
return true;
if (length(a) != length(b))
1998-09-01 05:29:17 +02:00
return false;
foreach(l, la)
{
if (lfirsti(l) != lfirsti(lb))
1998-09-01 05:29:17 +02:00
return false;
lb = lnext(lb);
}
return true;
}