Skip site navigation (1) Skip section navigation (2)

Solution

From: Jeff Davis <jeff95350(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Solution
Date: 2000-01-24 02:59:46
Message-ID: 20000124025946.19334.qmail@web3005.mail.yahoo.com (view raw or flat)
Thread:
Lists: 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

Next:From: Lamar OwenDate: 2000-01-24 03:20:03
Subject: Re: [GENERAL] RE: Where is the Database log file ?
Previous:From: Marcin Mazurek - Multinet SA - PoznanDate: 2000-01-24 02:37:39
Subject: Re: [GENERAL] It works now :)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group