pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
C function extending postgres
5+ messages / 2 participants
[nested] [flat]

* C function extending postgres
@ 2005-03-21 22:46 Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
  2005-03-22 00:21 ` Re: C function extending postgres Jonathan Daugherty <cygnus@cprogrammer.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Theo Galanakis @ 2005-03-21 22:46 UTC (permalink / raw)
  To: pgsql-sql


#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.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: C function extending postgres
  2005-03-21 22:46 C function extending postgres Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
@ 2005-03-22 00:21 ` Jonathan Daugherty <cygnus@cprogrammer.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Jonathan Daugherty @ 2005-03-22 00:21 UTC (permalink / raw)
  To: pgsql-sql

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

My guess that you're not linking against the library that containts
'proc_cpu_idle' when you build your .so.  What's the build platform?

-- 
  Jonathan Daugherty
  Command Prompt, Inc. - http://www.commandprompt.com/
  PostgreSQL Replication & Support Services, (503) 667-4564



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: C function extending postgres
@ 2005-03-22 05:09 Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
  2005-03-22 05:32 ` Re: C function extending postgres Jonathan Daugherty <cygnus@cprogrammer.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Theo Galanakis @ 2005-03-22 05:09 UTC (permalink / raw)
  To: Jonathan Daugherty <cygnus@cprogrammer.org>; +Cc: pgsql-sql


Thanks for your feedback.

I'm actually trying to use a system metrics library from
http://www-usr.inf.ufsm.br/~veiga/liblproc/index-en.html

I have tried to link the library however I'm still getting the same message.

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 -llproc -Wall -L/usr/local/include/ -o
processinfo.so processinfo.o



-----Original Message-----
From: Jonathan Daugherty [mailto:cygnus@cprogrammer.org] 
Sent: Tuesday, 22 March 2005 11:21 AM
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] C function extending postgres


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

My guess that you're not linking against the library that containts
'proc_cpu_idle' when you build your .so.  What's the build platform?

-- 
  Jonathan Daugherty
  Command Prompt, Inc. - http://www.commandprompt.com/
  PostgreSQL Replication & Support Services, (503) 667-4564

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq


______________________________________________________________________
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.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: C function extending postgres
  2005-03-22 05:09 Re: C function extending postgres Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
@ 2005-03-22 05:32 ` Jonathan Daugherty <cygnus@cprogrammer.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Jonathan Daugherty @ 2005-03-22 05:32 UTC (permalink / raw)
  To: pgsql-sql

# I'm actually trying to use a system metrics library from
# http://www-usr.inf.ufsm.br/~veiga/liblproc/index-en.html

Have you added the path of the lproc library to your /etc/ld.so.conf?

-- 
  Jonathan Daugherty
  http://www.parsed.org



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: C function extending postgres
@ 2005-03-22 05:43 Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
  0 siblings, 0 replies; 5+ messages in thread

From: Theo Galanakis @ 2005-03-22 05:43 UTC (permalink / raw)
  To: Jonathan Daugherty <cygnus@cprogrammer.org>; +Cc: pgsql-sql


Sorted Jonathan, thankyou for your help.

-----Original Message-----
From: Jonathan Daugherty [mailto:cygnus@cprogrammer.org] 
Sent: Tuesday, 22 March 2005 4:32 PM
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] C function extending postgres


# I'm actually trying to use a system metrics library from
# http://www-usr.inf.ufsm.br/~veiga/liblproc/index-en.html

Have you added the path of the lproc library to your /etc/ld.so.conf?

-- 
  Jonathan Daugherty
  http://www.parsed.org

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)


______________________________________________________________________
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.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2005-03-22 05:43 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-03-21 22:46 C function extending postgres Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
2005-03-22 00:21 ` Jonathan Daugherty <cygnus@cprogrammer.org>
2005-03-22 05:09 Re: C function extending postgres Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
2005-03-22 05:32 ` Jonathan Daugherty <cygnus@cprogrammer.org>
2005-03-22 05:43 Re: C function extending postgres Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>

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