Re: [GENERAL] Trying to make functions in 'C'

From: tolik(at)icomm(dot)ru (Anatoly K(dot) Lasareff)
To: "fabian baena" <fabbaena(at)hotmail(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Trying to make functions in 'C'
Date: 1999-05-17 06:46:56
Message-ID: 87n1z46vmn.fsf@tolikus.hq.aaanet.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "fb" == fabian baena <fabbaena(at)hotmail(dot)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(at)icomm(dot)ru
Senior programmer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 1999-05-17 06:51:50 Re: [GENERAL] Linux + PostgreSQL stats?
Previous Message Michael Jenner 1999-05-16 21:28:03 Re: RH 6.0 and PostgreSQL