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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: clemens(dot)ruck(at)t-online(dot)de
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19518: Path resolution for loading a function fails, if postgres is somewhere in the path.
Date: 2026-06-13 00:52:09
Message-ID: 1803065.1781311929@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message 王跃林 2026-06-13 03:50:25 Fw:Re: Fw: ltree_compare in contrib/ltree/ltree_op.c overflows int32 on deep ltree comparisons, returning the wrong sign
Previous Message Baji Shaik 2026-06-12 22:34:59 Re: uuidv7 improperly accepts dates before 1970-01-01