summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Villemain2011-04-28 22:00:34 +0000
committerCédric Villemain2011-05-01 14:33:14 +0000
commitc5f02abc6cbc605a75307ede381d7fecf2b4a206 (patch)
treed8bdc3b82e12f556cacc0c9ff9a488190e1eea7f
parente1476e4c410d22c355ef8668fd8170456d4dacea (diff)
Add 2 Hooks to handle OSCache and PGCache stats
The hooks are in: * RelationGetRelationOSCacheInFork * RelationGetRelationPGCacheInFork
-rw-r--r--src/backend/storage/buffer/bufmgr.c15
-rw-r--r--src/include/storage/bufmgr.h10
-rw-r--r--src/tools/pgindent/typedefs.list2
3 files changed, 27 insertions, 0 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 301b368d37..5cea9297e4 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -106,6 +106,13 @@ static volatile BufferDesc *BufferAlloc(SMgrRelation smgr,
static void FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln);
static void AtProcExit_Buffers(int code, Datum arg);
+/*
+ * Hooks for plugins to get control in
+ * RelationGetRelationOSCacheInFork
+ * RelationGetRelationPGCacheInFork
+ */
+oscache_hook_type OSCache_hook = NULL;
+pgcache_hook_type PGCache_hook = NULL;
/*
* PrefetchBuffer -- initiate asynchronous read of a block of a relation
@@ -1932,6 +1939,10 @@ RelationGetRelationOSCacheInFork(Relation relation, ForkNumber forkNum)
{
float4 percent = 0;
+ /* if a plugin is present, let it manage things */
+ if (OSCache_hook)
+ percent = (*OSCache_hook) (relation, forkNum);
+
return percent;
}
@@ -1945,6 +1956,10 @@ RelationGetRelationPGCacheInFork(Relation relation, ForkNumber forkNum)
{
float4 percent = 0;
+ /* if a plugin is present, let it manage things */
+ if (PGCache_hook)
+ percent = (*PGCache_hook) (relation, forkNum);
+
return percent;
}
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index 5bcc911b22..8b621de791 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -219,4 +219,14 @@ extern void AtProcExit_LocalBuffers(void);
extern BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype);
extern void FreeAccessStrategy(BufferAccessStrategy strategy);
+/*
+* Hooks for plugins to get control in
+* RelationGetRelationOSCacheInFork
+* RelationGetRelationPGCacheInFork
+*/
+typedef float4 (*oscache_hook_type) (Relation relation, ForkNumber forkNum);
+extern PGDLLIMPORT oscache_hook_type OSCache_hook;
+typedef float4 (*pgcache_hook_type) (Relation relation, ForkNumber forkNum);
+extern PGDLLIMPORT pgcache_hook_type PGCache_hook;
+
#endif
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 5e28289614..64ef53fd00 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -963,6 +963,7 @@ OprCacheKey
OprInfo
OprProofCacheEntry
OprProofCacheKey
+OSCache_hook_type
OutputContext
OverrideSearchPath
OverrideStackEntry
@@ -973,6 +974,7 @@ PBOOL
PCtxtHandle
PFN
PGAsyncStatusType
+PGCache_hook_type
PGCALL2
PGEvent
PGEventConnDestroy