diff options
| author | Tom Lane | 2011-08-16 23:27:46 +0000 |
|---|---|---|
| committer | Tom Lane | 2011-08-16 23:27:46 +0000 |
| commit | b5282aa893e565b7844f8237462cb843438cdd5e (patch) | |
| tree | b19170597a0a94685cc8c978c1c5800c411d02d1 /src/backend/optimizer | |
| parent | 632ae6829f7abda34e15082c91d9dfb3fc0f298b (diff) | |
Revise sinval code to remove no-longer-used tuple TID from inval messages.
This requires adjusting the API for syscache callback functions: they now
get a hash value, not a TID, to identify the target tuple. Most of them
weren't paying any attention to that argument anyway, but plancache did
require a small amount of fixing.
Also, improve performance a trifle by avoiding sending duplicate inval
messages when a heap_update isn't changing the catcache lookup columns.
Diffstat (limited to 'src/backend/optimizer')
| -rw-r--r-- | src/backend/optimizer/plan/setrefs.c | 23 | ||||
| -rw-r--r-- | src/backend/optimizer/util/predtest.c | 4 |
2 files changed, 12 insertions, 15 deletions
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index 60a1484c992..c3a5aac2fab 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -15,6 +15,7 @@ */ #include "postgres.h" +#include "access/hash.h" #include "access/transam.h" #include "catalog/pg_type.h" #include "nodes/makefuncs.h" @@ -1751,25 +1752,21 @@ record_plan_function_dependency(PlannerGlobal *glob, Oid funcid) */ if (funcid >= (Oid) FirstBootstrapObjectId) { - HeapTuple func_tuple; - PlanInvalItem *inval_item; - - func_tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); - if (!HeapTupleIsValid(func_tuple)) - elog(ERROR, "cache lookup failed for function %u", funcid); - - inval_item = makeNode(PlanInvalItem); + PlanInvalItem *inval_item = makeNode(PlanInvalItem); /* - * It would work to use any syscache on pg_proc, but plancache.c - * expects us to use PROCOID. + * 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... */ inval_item->cacheId = PROCOID; - inval_item->tupleId = func_tuple->t_self; + inval_item->hashValue = + DatumGetUInt32(DirectFunctionCall1(hashoid, + ObjectIdGetDatum(funcid))); glob->invalItems = lappend(glob->invalItems, inval_item); - - ReleaseSysCache(func_tuple); } } diff --git a/src/backend/optimizer/util/predtest.c b/src/backend/optimizer/util/predtest.c index beabafb5a86..cb10a31b077 100644 --- a/src/backend/optimizer/util/predtest.c +++ b/src/backend/optimizer/util/predtest.c @@ -101,7 +101,7 @@ static bool list_member_strip(List *list, Expr *datum); static bool btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it); static Oid get_btree_test_op(Oid pred_op, Oid clause_op, bool refute_it); -static void InvalidateOprProofCacheCallBack(Datum arg, int cacheid, ItemPointer tuplePtr); +static void InvalidateOprProofCacheCallBack(Datum arg, int cacheid, uint32 hashvalue); /* @@ -1738,7 +1738,7 @@ get_btree_test_op(Oid pred_op, Oid clause_op, bool refute_it) * Callback for pg_amop inval events */ static void -InvalidateOprProofCacheCallBack(Datum arg, int cacheid, ItemPointer tuplePtr) +InvalidateOprProofCacheCallBack(Datum arg, int cacheid, uint32 hashvalue) { HASH_SEQ_STATUS status; OprProofCacheEntry *hentry; |
