Solution - Mailing list pgsql-general

From Jeff Davis
Subject Solution
Date
Msg-id 20000124025946.19334.qmail@web3005.mail.yahoo.com
Whole thread Raw
List pgsql-general
Of course, here is the solution I used (to create a C
function to link to with PG):

'$' means done at command prompt
'=>' means done at psql prompt

this was done in Linux (RedHat 6.1) with PG 6.5 and
gcc

1) I made the C source file, file.c, which included
postgres.h

2) compiled as object:
$ gcc -fpic -c -o file.o file.c
$ ld -Bshareable -o file.so file.o

3) added function with SQL:
=> create function function_name(int4,float) returns
float AS '/path/to/file.so' language 'c';

4) test function with SQL:
=> select function_name(7,8.3) as number;

Hope this helps someone,
Jeff Davis

PS: If I get a good array function written (which I am
working on now) I will contribute that as well.
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: looping arrays with a function
Next
From: Lamar Owen
Date:
Subject: Re: [GENERAL] RE: Where is the Database log file ?