Re: BUG #19518: Path resolution for loading a function fails, if postgres is somewhere in the path. - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #19518: Path resolution for loading a function fails, if postgres is somewhere in the path.
Date
Msg-id 1803065.1781311929@sss.pgh.pa.us
Whole thread
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> I encountered an incorrect $libdir expansion when loading a C-language
> function from a shared library.

I'm not sure if this is just a typo in your submission,
but:

> CREATE OR REPLACE FUNCTION test(integer)
> RETURNS integer
> AS '$libdir/../../../hol-lambdas/src/ext/l_udfs.so',
>    'l_test'
> LANGUAGE C
> STRICT;

This is looking for l_udfs.so, but the rest of your message
references lambda_udfs.so.  That wouldn't be the cause would it?

> The issue depends on the surrounding directory names. With the PostgreSQL
> repository located under a differently named directory, the same build and
> SQL statement resolve the expected path.

The presence of "postgres" in the --prefix string affects whether
our Makefile.global decides to append an extra directory level to
pkglib_path:

pkglibdir = $(libdir)
ifeq "$(findstring pgsql, $(pkglibdir))" ""
ifeq "$(findstring postgres, $(pkglibdir))" ""
override pkglibdir := $(pkglibdir)/postgresql
endif
endif

That is, with your specified

    --prefix=/home/testuser/projects/hol-postgres/install

the pkglib_path would be

    /home/testuser/projects/hol-postgres/install/lib

but with, say,

    --prefix=/home/testuser/projects/hol-postgrex/install

the pkglib_path would be

    /home/testuser/projects/hol-postgrex/install/lib/postgresql

thus changing the number of ".."s needed in your example.  Perhaps
that rule explains your results with different installation paths?

> I can provide the exact compiled values of PGBINDIR and PKGLIBDIR, the
> resulting runtime pkglib_path, and a patch or regression test if required.

I'm quite hesitant to change the behavior around this: it's stood for
decades and any change would certainly break a bunch of people's
build/install recipes.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Hüseyin Demir
Date:
Subject: Re: BUG #19483: pg_upgrade fails with orphan records in pg_init_priv catalog table
Next
From: 王跃林
Date:
Subject: Fw:Re: Fw: ltree_compare in contrib/ltree/ltree_op.c overflows int32 on deep ltree comparisons, returning the wrong sign