Re: [GENERAL] Stats Collector - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Re: [GENERAL] Stats Collector
Date
Msg-id GNELIHDDFBOCMGBFGEFOGEGCCDAA.chriskl@familyhealth.com.au
Whole thread Raw
Responses Re: [GENERAL] Stats Collector  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> Looks to me, someone forgot something. That would be me and now I
> remember that I originally wanted to add some utility command for that.
>
> What you need in the meantime is a little C function that calls
>
> void pgstat_reset_counters(void);
>
> I might find the time tomorrow to write one for you if you don't know
> how.

Is this the kind of thing you mean?

#include "postgres.h"
#include "fmgr.h"

extern Datum pg_reset_stats(PG_FUNCTION_ARGS);

PG_FUNCTION_INFO_V1(pg_reset_stats);

Datum
pg_reset_stats(PG_FUNCTION_ARGS)
{       void pgstat_reset_counters(void);
       PG_RETURN_VOID();
}

With this code I get this:

test=# select pg_reset_stats();
ERROR:  Unable to look up type id 0

I'm creating it like this:

create or replace function pg_reset_stats() returns opaque as
'/home/chriskl/local/lib/postgresql/pg_reset_stats.so'      language 'C';
 

Is it something to do with the return type being declared wrongly?
Hmm...the manual indicates that opaque functions cannot be called directly -
so what the heck do I do?

Also, where would I put this function in the main postgres source and how
would I modify initdb?

Chris



pgsql-hackers by date:

Previous
From: Larry Rosenman
Date:
Subject: Re: Virus Emails
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] Stats Collector