Thread: Problem creating a function

Problem creating a function

From
Cornelia Boenigk
Date:
Hi all

Trying to create a function I get the following:

codex=# CREATE FUNCTION "bitvg" (integer,integer) RETURNS integer AS
'/home/database/pgdata/cobis/bitvg/bitvg.so', 'bitvg' LANGUAGE 'C';
ERROR:  could not load library
"/home/database/pgdata/cobis/bitvg/bitvg.so":
/home/database/pgdata/cobis/bitvg/bitvg.so: Kann die
Shared-Object-Datei nicht öffnen: Datei oder Verzeichnis nicht gefunden

in english: /home/database/pgdata/cobis/bitvg/bitvg.so: cannot open
shared object: file not found

The file does exist in the path /home/database/pgdata/cobis/bitvg/:
-rwxr-xr-x  1 root root   133 Jul 19 13:13 bitvg.c
-rwxr-xr-x  1 root root   782 Jul 19 13:13 bitvg.o
-rwxr-xr-x  1 root root  3198 Jul 19 13:13 bitvg.so

What do I miss?

Thank's in advance
Conni
--
http://pgsql.info | http://postgresql.de | http://pgfakt.de
Telefon: 07127 80 961

Re: Problem creating a function

From
Joe Conway
Date:
Cornelia Boenigk wrote:
> The file does exist in the path /home/database/pgdata/cobis/bitvg/:
> -rwxr-xr-x  1 root root   133 Jul 19 13:13 bitvg.c
> -rwxr-xr-x  1 root root   782 Jul 19 13:13 bitvg.o
> -rwxr-xr-x  1 root root  3198 Jul 19 13:13 bitvg.so
>
> What do I miss?

Does the postgres user have access to /home/database/pgdata/cobis/bitvg?

Try:
   su postgres
   cd /home/database/pgdata/cobis/bitvg

Joe

Re: Problem creating a function

From
Tom Lane
Date:
Cornelia Boenigk <c@cornelia-boenigk.de> writes:
> in english: /home/database/pgdata/cobis/bitvg/bitvg.so: cannot open
> shared object: file not found

> The file does exist in the path /home/database/pgdata/cobis/bitvg/:

The "file not found" might be coming from the dynamic loader trying to
load some other library that bitvg.so depends upon.  You should try "ldd"
or local equivalent on bitvg.so to check whether all its dependencies
can be found.  Also, try looking in the postmaster log --- on some
platforms, dynamic loader failures spit additional information to stderr
that can't be reported to you by the backend, but will be captured in
the postmaster log file.

            regards, tom lane

Re: Problem creating a function

From
Cornelia Boenigk
Date:
Hi Joe

 > Try:
 >   su postgres
 >   cd /home/database/pgdata/cobis/bitvg

Succeeds, ls -la shows all files in that directory and can open them
with less.

Regards
Conni


Re: Problem creating a function

From
Cornelia Boenigk
Date:
Hi Tom

 > You should try "ldd" or local equivalent on bitvg.so to check
 > whether all its dependencies can be found.

output:
ldd /home/database/pgdata/cobis/bitvg/bitvg.so
         statically linked

Regards
Conni

Re: Problem creating a function

From
Joe Conway
Date:
Cornelia Boenigk wrote:
> Hi Joe
>
>  > Try:
>  >   su postgres
>  >   cd /home/database/pgdata/cobis/bitvg
>
> Succeeds, ls -la shows all files in that directory and can open them
> with less.

Kind of odd, particularly given your reply to Tom's question in a nearby
post. Could it be an SELinux issue?

Joe

Re: Problem creating a function

From
Tom Lane
Date:
Joe Conway <mail@joeconway.com> writes:
> Could it be an SELinux issue?

I'd really expect the strerror result to be something about 'permission
denied' rather than 'file not found', if that were the problem...

            regards, tom lane

Re: Problem creating a function - solved

From
Cornelia Boenigk
Date:
Hi Tom, Joe

After compiling the C-source files

# gcc -fpic -c bitvg.c
# gcc -shared -o bitvg.so bitvg.o

the pg_restore created the function.
It is Suse 9.x and PG 8.1.4

Thanks
Conni