pg_buffercache插件编译适配

This commit is contained in:
luoh51
2024-11-05 17:28:09 +08:00
parent 8223912bf5
commit d461f0cf40
2 changed files with 6 additions and 5 deletions

View File

@ -4,17 +4,17 @@
\echo Use "CREATE EXTENSION pg_buffercache" to load this file. \quit
-- Register the function.
CREATE FUNCTION pg_buffercache_pages()
CREATE FUNCTION pg_buffercache_pages_wrap()
RETURNS SETOF RECORD
AS 'MODULE_PATHNAME', 'pg_buffercache_pages'
LANGUAGE C;
-- Create a view for convenient access.
CREATE VIEW pg_buffercache AS
SELECT P.* FROM pg_buffercache_pages() AS P
SELECT P.* FROM pg_buffercache_pages_wrap() AS P
(bufferid integer, relfilenode oid, reltablespace oid, reldatabase oid,
relforknumber int2, relblocknumber int8, isdirty bool, usagecount int2);
-- Don't want these to be available to public.
REVOKE ALL ON FUNCTION pg_buffercache_pages() FROM PUBLIC;
REVOKE ALL ON FUNCTION pg_buffercache_pages_wrap() FROM PUBLIC;
REVOKE ALL ON pg_buffercache FROM PUBLIC;

View File

@ -18,14 +18,13 @@
PG_MODULE_MAGIC;
Datum pg_buffercache_pages(PG_FUNCTION_ARGS);
/*
* Record structure holding the to be exposed cache data.
*/
typedef struct {
uint32 bufferid;
Oid relfilenode;
int4 bucketnode;
Oid reltablespace;
Oid reldatabase;
ForkNumber forknum;
@ -49,6 +48,8 @@ typedef struct {
*/
PG_FUNCTION_INFO_V1(pg_buffercache_pages);
extern "C" Datum pg_buffercache_pages(PG_FUNCTION_ARGS);
Datum pg_buffercache_pages(PG_FUNCTION_ARGS)
{
FuncCallContext* funcctx = NULL;