Re: Dynamic loading of C functions: Badly stuck

From: Steve Atkins <steve(at)blighty(dot)com>
To: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Dynamic loading of C functions: Badly stuck
Date: 2006-06-21 16:56:45
Message-ID: D175D848-4AA3-4A2F-8E13-506AC62A3F6C@blighty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jun 21, 2006, at 9:42 AM, Jasbinder Bali wrote:

> Hi,
> I raised this problem yesterday aswell. I'm badly stuck at this point.
> The problem is as follows:
>
> I have a C function that i want to use in my postgres function.
> I adopt the following steps to do that.
>
> --- compile the C file as follows
> gcc -shared -o test_func.so test_func.c
> test_func.c is the name of the C file
>
> --- the name of the function that i want to use from this c file is
> called 'command'
>
> --- Postgres function is written as follows:
>
> CREATE FUNCTION command(integer) RETURNS integer
> AS 'usr/include/pgsql/server/test_func', 'command'
> LANGUAGE C STRICT;
>
> when i try to run this function, always gives me the follwoing error:
>
> ERROR: could not access file "usr/include/pgsql/server/test_func":
> No such file or directory
>
>
> I tried changin the permission of the file to 666 and even tried it
> with 755 but in vein.
>
> I checked the log file but it just prints the above error and
> doesn't give me any more information.
>
> I have no clue why is postgres not reading test_func object file.
>
> Any kind of help would be appreciated
>

IIRC the path name is relative to... dynamic_library_path and pwd, first
as given, then with ".so" appended.

Unless you've set one of those to "/" then 'usr/include/pgsql/server/
test_func'
is never going to resolve to where you want it to.

If you really want to keep it where it is, try using the correct
absolute filename.
Better, though, would be to use ... AS '$libdir/test_func.so' ... and
put the library
wherever "pg_config --pkglibdir" says - probably /usr/local/pgsql/lib.

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ricardo Vaz 2006-06-21 17:08:49 Copy from text file
Previous Message Jasbinder Bali 2006-06-21 16:49:26 Re: Dynamic loading of C functions: Badly stuck