From 6725a5db7db19549c7682746b9bcaafff1a0c126 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Villemain?= Date: Mon, 10 Aug 2009 02:53:40 +0200 Subject: [PATCH] working well, now, adjust everything, optimise, and TODO --- pgfincore.c | 16 +++++++++++----- pgfincore_84.sql.in | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pgfincore.c b/pgfincore.c index 775258f..8a885dd 100644 --- a/pgfincore.c +++ b/pgfincore.c @@ -112,10 +112,14 @@ Datum pgfincore(PG_FUNCTION_ARGS) fctx->segcount = 0; funcctx->user_fctx = fctx; - tupdesc = CreateTemplateTupleDesc(2, false); + tupdesc = CreateTemplateTupleDesc(4, false); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "relpath", TEXTOID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 2, "block_mem", + TupleDescInitEntry(tupdesc, (AttrNumber) 2, "block_disk", + INT8OID, -1, 0); + TupleDescInitEntry(tupdesc, (AttrNumber) 3, "block_mem", + INT8OID, -1, 0); + TupleDescInitEntry(tupdesc, (AttrNumber) 4, "group_mem", INT8OID, -1, 0); funcctx->tuple_desc = BlessTupleDesc(tupdesc); @@ -149,12 +153,14 @@ Datum pgfincore(PG_FUNCTION_ARGS) /* or send the result */ else { HeapTuple tuple; - Datum values[2]; - bool nulls[2]; + Datum values[4]; + bool nulls[4]; fctx->segcount++; values[0] = CStringGetTextDatum(pathname); - values[1] = Int64GetDatum(info->block_mem); + values[1] = Int64GetDatum(info->block_disk); + values[2] = Int64GetDatum(info->block_mem); + values[3] = Int64GetDatum(info->group_mem); memset(nulls, 0, sizeof(nulls)); tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls); elog(DEBUG1, "file %s contain %i block in linux cache memory", pathname, info->block_mem); diff --git a/pgfincore_84.sql.in b/pgfincore_84.sql.in index f2e9afe..a68ebdd 100644 --- a/pgfincore_84.sql.in +++ b/pgfincore_84.sql.in @@ -1,12 +1,12 @@ SET search_path = public; CREATE OR REPLACE FUNCTION -pgfincore(IN regclass, IN text, OUT relpath text, OUT block_mem bigint) +pgfincore(IN regclass, IN text, OUT relpath text, OUT block_disk bigint, OUT block_mem bigint, OUT group_mem bigint) RETURNS setof record AS 'MODULE_PATHNAME' LANGUAGE C; -CREATE OR REPLACE FUNCTION pgfincore(IN regclass, OUT relpath text, OUT block_mem bigint) +CREATE OR REPLACE FUNCTION pgfincore(IN regclass, OUT relpath text, OUT block_disk bigint, OUT block_mem bigint, OUT group_mem bigint) RETURNS setof record AS 'SELECT pgfincore($1, ''main'')' LANGUAGE SQL; -- 2.39.5