📄 equalfuncs.c
字号:
/*------------------------------------------------------------------------- * * equalfuncs.c * equal functions to compare the nodes * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * $Header: /usr/local/cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.39.2.1 1999/07/29 03:34:11 tgl Exp $ * *------------------------------------------------------------------------- */#include <string.h>#include "postgres.h"#include "nodes/nodes.h"#include "nodes/primnodes.h"#include "nodes/relation.h"#include "nodes/execnodes.h"#include "nodes/plannodes.h"#include "utils/builtins.h" /* for namestrcmp() */#include "utils/datum.h"#include "utils/elog.h"#include "storage/itemptr.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) return false; if (a->restype != b->restype) return false; if (a->restypmod != b->restypmod) return false; if (strcmp(a->resname, b->resname) != 0) return false; if (a->reskey != b->reskey) return false; if (a->resgroupref != b->resgroupref) return false; if (a->reskeyop != b->reskeyop) return false; return true;}static bool_equalFjoin(Fjoin *a, Fjoin *b){ int nNodes; if (a->fj_initialized != b->fj_initialized) return false; if (a->fj_nNodes != b->fj_nNodes) return false; if (!equal(a->fj_innerNode, b->fj_innerNode)) return false; nNodes = a->fj_nNodes; if (memcmp(a->fj_results, b->fj_results, nNodes * sizeof(Datum)) != 0) return false; if (memcmp(a->fj_alwaysDone, b->fj_alwaysDone, nNodes * sizeof(bool)) != 0) return false; return true;}/* * Expr is a subclass of Node. */static bool_equalExpr(Expr *a, Expr *b){ if (a->opType != b->opType) return false; if (!equal(a->oper, b->oper)) return false; if (!equal(a->args, b->args)) return false; return true;}static bool_equalIter(Iter *a, Iter *b){ return equal(a->iterexpr, b->iterexpr);}static bool_equalStream(Stream *a, Stream *b){ if (a->clausetype != b->clausetype) return false; if (a->groupup != b->groupup) return false; if (a->groupcost != b->groupcost) return false; if (a->groupsel != b->groupsel) return false; if (!equal(a->pathptr, b->pathptr)) return false; if (!equal(a->cinfo, b->cinfo)) return false; if (!equal(a->upstream, b->upstream)) 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) return false; if (a->varattno != b->varattno) return false; if (a->vartype != b->vartype) return false; if (a->vartypmod != b->vartypmod) return false; if (a->varlevelsup != b->varlevelsup) return false; if (a->varnoold != b->varnoold) return false; if (a->varoattno != b->varoattno) return false; return true;}static bool_equalArray(Array *a, Array *b){ if (a->arrayelemtype != b->arrayelemtype) return false; if (a->arrayndim != b->arrayndim) return false; if (a->arraylow.indx[0] != b->arraylow.indx[0]) return false; if (a->arrayhigh.indx[0] != b->arrayhigh.indx[0]) return false; if (a->arraylen != b->arraylen) return false; return TRUE;}static bool_equalArrayRef(ArrayRef *a, ArrayRef *b){ if (a->refelemtype != b->refelemtype) return false; if (a->refattrlength != b->refattrlength) return false; if (a->refelemlength != b->refelemlength) return false; if (a->refelembyval != b->refelembyval) return false; if (!equal(a->refupperindexpr, b->refupperindexpr)) return false; if (!equal(a->reflowerindexpr, b->reflowerindexpr)) return false; if (!equal(a->refexpr, b->refexpr)) 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) return false; if (a->opresulttype != b->opresulttype) return false; 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) return false; if (a->constlen != b->constlen) return false; if (a->constisnull != b->constisnull) return false; if (a->constbyval != b->constbyval) 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) return false; if (a->paramtype != b->paramtype) return false; if (!equal(a->param_tlist, b->param_tlist)) return false; switch (a->paramkind) { case PARAM_NAMED: case PARAM_NEW: case PARAM_OLD: if (strcmp(a->paramname, b->paramname) != 0) return false; break; case PARAM_NUM: case PARAM_EXEC: if (a->paramid != b->paramid) return false; break; case PARAM_INVALID: /* * XXX: Hmmm... What are we supposed to return in this case ?? */ return true; break; default: elog(ERROR, "_equalParam: Invalid paramkind value: %d", a->paramkind); } 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) return false; if (a->functype != b->functype) return false; if (a->funcisindex != b->funcisindex) return false; if (a->funcsize != b->funcsize) return false; if (!equal(a->func_tlist, b->func_tlist)) return false; if (!equal(a->func_planlist, b->func_planlist)) return false; return true;}/* * RestrictInfo is a subclass of Node. */static bool_equalRestrictInfo(RestrictInfo *a, RestrictInfo *b){ Assert(IsA(a, RestrictInfo)); Assert(IsA(b, RestrictInfo)); if (!equal(a->clause, b->clause)) return false; if (a->selectivity != b->selectivity) return false; if (a->notclause != b->notclause) return false;#ifdef EqualMergeOrderExists if (!EqualMergeOrder(a->mergejoinorder, b->mergejoinorder)) return false;#endif if (a->hashjoinoperator != b->hashjoinoperator) return false; return equal(a->indexids, b->indexids);}/* * RelOptInfo is a subclass of Node. */static bool_equalRelOptInfo(RelOptInfo *a, RelOptInfo *b){ Assert(IsA(a, RelOptInfo)); Assert(IsA(b, RelOptInfo)); return equal(a->relids, b->relids);}static bool_equalJoinMethod(JoinMethod *a, JoinMethod *b){ Assert(IsA(a, JoinMethod)); Assert(IsA(b, JoinMethod)); if (!equal(a->jmkeys, b->jmkeys)) return false; if (!equal(a->clauses, b->clauses)) return false; return true;}static bool_equalPath(Path *a, Path *b){ if (a->pathtype != b->pathtype) return false; if (a->parent != b->parent) return false; /* * if (a->path_cost != b->path_cost) return(false); */ if (a->pathorder->ordtype == SORTOP_ORDER) { int i = 0; if (a->pathorder->ord.sortop == NULL || b->pathorder->ord.sortop == NULL) { if (a->pathorder->ord.sortop != b->pathorder->ord.sortop) return false; } else { while (a->pathorder->ord.sortop[i] != 0 && b->pathorder->ord.sortop[i] != 0) { if (a->pathorder->ord.sortop[i] != b->pathorder->ord.sortop[i]) return false; i++; } if (a->pathorder->ord.sortop[i] != 0 || b->pathorder->ord.sortop[i] != 0) return false; } } else { if (!equal(a->pathorder->ord.merge, b->pathorder->ord.merge)) return false; } if (!equal(a->pathkeys, b->pathkeys)) return false; /* * if (a->outerjoincost != b->outerjoincost) return(false); */ if (!equali(a->joinid, b->joinid)) return false; return true;}static bool_equalIndexPath(IndexPath *a, IndexPath *b){ if (!_equalPath((Path *) a, (Path *) b)) return false; if (!equali(a->indexid, b->indexid)) return false; if (!equal(a->indexqual, b->indexqual)) return false; return true;}static bool_equalNestPath(NestPath *a, NestPath *b){ Assert(IsA_JoinPath(a)); Assert(IsA_JoinPath(b)); if (!_equalPath((Path *) a, (Path *) b)) return false; if (!equal(a->pathinfo, b->pathinfo)) return false; if (!equal(a->outerjoinpath, b->outerjoinpath)) return false; if (!equal(a->innerjoinpath, b->innerjoinpath)) return false; return true;}static bool_equalMergePath(MergePath *a, MergePath *b){ Assert(IsA(a, MergePath)); Assert(IsA(b, MergePath)); if (!_equalNestPath((NestPath *) a, (NestPath *) b)) return false; if (!equal(a->path_mergeclauses, b->path_mergeclauses)) return false; if (!equal(a->outersortkeys, b->outersortkeys)) return false; if (!equal(a->innersortkeys, b->innersortkeys)) return false; return true;}static bool_equalHashPath(HashPath *a, HashPath *b){ Assert(IsA(a, HashPath)); Assert(IsA(b, HashPath)); if (!_equalNestPath((NestPath *) a, (NestPath *) b)) return false; if (!equal((a->path_hashclauses), (b->path_hashclauses))) return false; if (!equal(a->outerhashkeys, b->outerhashkeys)) return false; if (!equal(a->innerhashkeys, b->innerhashkeys)) 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))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -