From e26c539e9f326ea843c0ed005af093b56b55cd4d Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Sun, 14 Feb 2010 18:42:19 +0000 Subject: Wrap calls to SearchSysCache and related functions using macros. The purpose of this change is to eliminate the need for every caller of SearchSysCache, SearchSysCacheCopy, SearchSysCacheExists, GetSysCacheOid, and SearchSysCacheList to know the maximum number of allowable keys for a syscache entry (currently 4). This will make it far easier to increase the maximum number of keys in a future release should we choose to do so, and it makes the code shorter, too. Design and review by Tom Lane. --- src/backend/utils/adt/selfuncs.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'src/backend/utils/adt/selfuncs.c') diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 4bd302eab51..b83cd45d7c7 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.268 2010/01/05 21:53:59 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.269 2010/02/14 18:42:16 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -4117,11 +4117,10 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, } else if (rte->rtekind == RTE_RELATION) { - vardata->statsTuple = SearchSysCache(STATRELATTINH, - ObjectIdGetDatum(rte->relid), - Int16GetDatum(var->varattno), - BoolGetDatum(rte->inh), - 0); + vardata->statsTuple = SearchSysCache3(STATRELATTINH, + ObjectIdGetDatum(rte->relid), + Int16GetDatum(var->varattno), + BoolGetDatum(rte->inh)); vardata->freefunc = ReleaseSysCache; } else @@ -4258,11 +4257,10 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, else if (index->indpred == NIL) { vardata->statsTuple = - SearchSysCache(STATRELATTINH, + SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(index->indexoid), - Int16GetDatum(pos + 1), - BoolGetDatum(false), - 0); + Int16GetDatum(pos + 1), + BoolGetDatum(false)); vardata->freefunc = ReleaseSysCache; } if (vardata->statsTuple) @@ -6116,11 +6114,10 @@ btcostestimate(PG_FUNCTION_ARGS) } else { - vardata.statsTuple = SearchSysCache(STATRELATTINH, - ObjectIdGetDatum(relid), - Int16GetDatum(colnum), - BoolGetDatum(rte->inh), - 0); + vardata.statsTuple = SearchSysCache3(STATRELATTINH, + ObjectIdGetDatum(relid), + Int16GetDatum(colnum), + BoolGetDatum(rte->inh)); vardata.freefunc = ReleaseSysCache; } } @@ -6143,11 +6140,10 @@ btcostestimate(PG_FUNCTION_ARGS) } else { - vardata.statsTuple = SearchSysCache(STATRELATTINH, - ObjectIdGetDatum(relid), - Int16GetDatum(colnum), - BoolGetDatum(false), - 0); + vardata.statsTuple = SearchSysCache3(STATRELATTINH, + ObjectIdGetDatum(relid), + Int16GetDatum(colnum), + BoolGetDatum(false)); vardata.freefunc = ReleaseSysCache; } } -- cgit v1.2.3