0004-Add-a-Hook-to-handle-OSCache-stats.patch
text/x-patch
Filename: 0004-Add-a-Hook-to-handle-OSCache-stats.patch
Type: text/x-patch
Part: 3
From 5a024cbbc3261454c49d8a77afd121605abc3390 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Villemain?= <cedric@2ndquadrant.fr>
Date: Thu, 26 May 2011 00:46:03 +0200
Subject: [PATCH 4/7] Add a Hook to handle OSCache stats
The hook is in RelationGetRelationOSCacheInFork
---
src/backend/storage/buffer/bufmgr.c | 9 +++++++++
src/include/storage/bufmgr.h | 7 +++++++
src/tools/pgindent/typedefs.list | 1 +
3 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
new file mode 100644
index 670dbdf..9bfa78c
*** a/src/backend/storage/buffer/bufmgr.c
--- b/src/backend/storage/buffer/bufmgr.c
*************** static volatile BufferDesc *BufferAlloc(
*** 106,111 ****
--- 106,116 ----
static void FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln);
static void AtProcExit_Buffers(int code, Datum arg);
+ /*
+ * Hooks for plugin to get control in
+ * RelationGetRelationOSCacheInFork
+ */
+ oscache_hook_type OSCache_hook = NULL;
/*
* PrefetchBuffer -- initiate asynchronous read of a block of a relation
*************** RelationGetRelationOSCacheInFork(Relatio
*** 1938,1943 ****
--- 1943,1952 ----
{
float4 percent = 0;
+ /* if a plugin is present, let it manage things */
+ if (OSCache_hook)
+ percent = (*OSCache_hook) (relation, forkNum);
+
return percent;
}
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
new file mode 100644
index 7d22b5a..3098275
*** a/src/include/storage/bufmgr.h
--- b/src/include/storage/bufmgr.h
*************** extern void AtProcExit_LocalBuffers(void
*** 217,220 ****
--- 217,227 ----
extern BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype);
extern void FreeAccessStrategy(BufferAccessStrategy strategy);
+ /*
+ * Hooks for plugin to get control in
+ * RelationGetRelationOSCacheInFork
+ */
+ typedef float4 (*oscache_hook_type) (Relation relation, ForkNumber forkNum);
+ extern PGDLLIMPORT oscache_hook_type OSCache_hook;
+
#endif
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
new file mode 100644
index f2982cd..a1bf8fe
*** a/src/tools/pgindent/typedefs.list
--- b/src/tools/pgindent/typedefs.list
*************** OprCacheKey
*** 963,968 ****
--- 963,969 ----
OprInfo
OprProofCacheEntry
OprProofCacheKey
+ OSCache_hook_type
OutputContext
OverrideSearchPath
OverrideStackEntry
--
1.7.5.3