pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
To: pgsql-sql@postgresql.org
Subject: C function extending postgres
Date: Tue, 22 Mar 2005 09:46:39 +1100
Message-ID: <D1444817B78AB546BF2896C2B70E7F04371F84@ganesh.au.lpint.net> (raw)


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

PG_FUNCTION_INFO_V1(get_process_total);

Datum
get_process_total(PG_FUNCTION_ARGS)
{
	float ret;
	ret = proc_cpu_user() + proc_cpu_nice() + proc_cpu_system() -
proc_cpu_idle();
	PG_RETURN_FLOAT4(ret);
}

Hi ,

	I'm getting the following error when attempting to call the above
function, I have included the -I path when compiling, and have compiled a
similar function to execute and printf to linux without a problem :

Returned by postgres:
	
	ERROR:  could not load library "/usr/lib/pgsql/processinfo.so":
/usr/lib/pgsql/processinfo.so: undefined symbol: proc_cpu_idle

Compiling:
	cc -g -I /usr/local/pgsql/include -I /usr/local/pgsql/include/server
-I /usr/local/include -fpic -c processinfo.c
	cc -g -I /usr/local/pgsql/include -I /usr/local/pgsql/include/server
-I /usr/local/include -shared -o processinfo.so processinfo.o

Here is the postgres create function:
CREATE FUNCTION get_process_total() RETURNS float4
    AS '$libdir/processinfo', 'get_process_total'
LANGUAGE 'c' STABLE STRICT;

TEST:
select * from get_process_total()

Your help would be greatly appreciated.

Theo



______________________________________________________________________
This email, including attachments, is intended only for the addressee
and may be confidential, privileged and subject to copyright.  If you
have received this email in error, please advise the sender and delete
it.  If you are not the intended recipient of this email, you must not
use, copy or disclose its content to anyone.  You must not copy or 
communicate to others content that is confidential or subject to 
copyright, unless you have the consent of the content owner.

view thread (5+ messages)  latest in thread

Message-ID: <D1444817B78AB546BF2896C2B70E7F04371F84@ganesh.au.lpint.net>
Permalink:  ../D1444817B78AB546BF2896C2B70E7F04371F84@ganesh.au.lpint.net/
Also on:    postgresql.org/message-id/D1444817B78AB546BF2896C2B70E7F04371F84@ganesh.au.lpint.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: Theo.Galanakis@lonelyplanet.com.au
  Subject: Re: C function extending postgres
  In-Reply-To: <D1444817B78AB546BF2896C2B70E7F04371F84@ganesh.au.lpint.net>
  References: <D1444817B78AB546BF2896C2B70E7F04371F84@ganesh.au.lpint.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox