More C function questions

From: Jeff Davis <jeff95350(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: More C function questions
Date: 2000-01-24 00:41:07
Message-ID: 20000124004107.20174.qmail@web3004.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2000-01-24 01:09:39 It works now :)
Previous Message Alexey Vyskubov 2000-01-23 23:36:10 Re: [GENERAL] Writing C functions