More C function questions - Mailing list pgsql-general

From Jeff Davis
Subject More C function questions
Date
Msg-id 20000124004107.20174.qmail@web3004.mail.yahoo.com
Whole thread Raw
List pgsql-general
Thanks for the advice so far, but I ran into another
problem:

I made what I thought was a fine object file that I
wanted to import as a function with:

CREATE FUNCTION addtwo(int4) returns int4 as
'/var/lib/pgsql/functions/tmp.so' language 'c';

Everything seemed to be fine until I go to use the
function, called addtwo(int4):

select addtwo(7) as number;

ERROR:  Load of file /var/lib/pgsql/functions/tmp.so
failed: /var/lib/pgsql/functions/tmp.so: ELF file's
phentsize not the expected size

here is my C code (tmp.c):
#include <pgsql/postgres.h>
int4 addtwo(int4);
int4 addtwo(int4 arg)
{
        return(arg+2);
}

and I used:
gcc -c tmp.c -o tmp.so
to compile.

To make sure it was working outside of PG I did a
seperate C file which called the function and that
worked by compiling the test C file like:
gcc test.c tmp.so
and the function call defined in tmp.so worked fine


Thanks again,
Jeff Davis
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

pgsql-general by date:

Previous
From: Alexey Vyskubov
Date:
Subject: Re: [GENERAL] Writing C functions
Next
From: Jeff Davis
Date:
Subject: It works now :)