Re: [GENERAL] Trying to make functions in 'C' - Mailing list pgsql-general

From tolik@icomm.ru (Anatoly K. Lasareff)
Subject Re: [GENERAL] Trying to make functions in 'C'
Date
Msg-id 87n1z46vmn.fsf@tolikus.hq.aaanet.ru
Whole thread Raw
In response to Trying to make functions in 'C'  ("fabian baena" <fabbaena@hotmail.com>)
Responses Re: [GENERAL] Trying to make functions in 'C'  (selkovjr.mcs.anl.gov@mcs.anl.gov)
List pgsql-general
>>>>> "fb" == fabian baena <fabbaena@hotmail.com> writes:

 fb> I'm tying to learn how to make function in 'C'.
 fb> I'm trying to compile a program I made in 'C'.
 fb> The command I gave were:

 fb> % gcc -fPIC -c addone.c -I/usr/local/pgsql/include
 fb> % ld -G -Bdynamic -o addone.so addone.o

 fb> and created the function in postgres like this:

 fb> CREATE FUNCTION add_one(int4) RETURNS int4
 fb> AS './addone.so' LANGUAGE 'c';


 fb> The function I made looks like this:

 fb> #include "postgres.h"

 fb> int
 fb> add_one(int arg)
 fb> {
 fb> return arg + 1;
 fb> }

 fb> But when I try to test the function in postgres I recieve this error:

 fb> ERROR:  stat failed on file ./addone.so
 fb> ERROR:  stat failed on file ./addone.so
 fb> Can anyone tell where did I make a mistake?
 fb> I have a linux on a PC.

Pehaps not 'int', but 'int4' in argument and return type? Except this
I think your example is right.

--
Anatoly K. Lasareff              Email:       tolik@icomm.ru
Senior programmer

pgsql-general by date:

Previous
From: Michael Jenner
Date:
Subject: Re: RH 6.0 and PostgreSQL
Next
From: Bruce Momjian
Date:
Subject: Re: [GENERAL] Linux + PostgreSQL stats?