Re: [GENERAL] Trying to make functions in 'C'
| От | tolik@icomm.ru (Anatoly K. Lasareff) |
|---|---|
| Тема | Re: [GENERAL] Trying to make functions in 'C' |
| Дата | |
| Msg-id | 87n1z46vmn.fsf@tolikus.hq.aaanet.ru обсуждение исходный текст |
| Ответ на | Trying to make functions in 'C' ("fabian baena" <fabbaena@hotmail.com>) |
| Ответы |
Re: [GENERAL] Trying to make functions in 'C'
|
| Список | 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 по дате отправления: