From d4bf3c9c94305e692349fb6fe0c67e483b72ae87 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 7 Mar 2012 14:51:13 -0500 Subject: Expose an API for calculating catcache hash values. Now that cache invalidation callbacks get only a hash value, and not a tuple TID (per commits 632ae6829f7abda34e15082c91d9dfb3fc0f298b and b5282aa893e565b7844f8237462cb843438cdd5e), the only way they can restrict what they invalidate is to know what the hash values mean. setrefs.c was doing this via a hard-wired assumption but that seems pretty grotty, and it'll only get worse as more cases come up. So let's expose a calculation function that takes the same parameters as SearchSysCache. Per complaint from Marko Kreen. --- src/backend/optimizer/plan/setrefs.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/backend/optimizer/plan/setrefs.c') diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index 66d21b2b2c3..e1b48fb4f53 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -15,7 +15,6 @@ */ #include "postgres.h" -#include "access/hash.h" #include "access/transam.h" #include "catalog/pg_type.h" #include "nodes/makefuncs.h" @@ -1830,14 +1829,11 @@ record_plan_function_dependency(PlannerInfo *root, Oid funcid) /* * It would work to use any syscache on pg_proc, but the easiest is * PROCOID since we already have the function's OID at hand. Note - * that plancache.c knows we use PROCOID. Also, we're perhaps - * assuming more than we should about how CatalogCacheComputeHashValue - * computes hash values... + * that plancache.c knows we use PROCOID. */ inval_item->cacheId = PROCOID; - inval_item->hashValue = - DatumGetUInt32(DirectFunctionCall1(hashoid, - ObjectIdGetDatum(funcid))); + inval_item->hashValue = GetSysCacheHashValue1(PROCOID, + ObjectIdGetDatum(funcid)); root->glob->invalItems = lappend(root->glob->invalItems, inval_item); } -- cgit v1.2.3