Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wYCbj-0007dN-18 for pgsql-bugs@arkaria.postgresql.org; Sat, 13 Jun 2026 00:52:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wYCbi-002Pat-0N for pgsql-bugs@arkaria.postgresql.org; Sat, 13 Jun 2026 00:52:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wYCbh-002Pag-2m for pgsql-bugs@lists.postgresql.org; Sat, 13 Jun 2026 00:52:17 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wYCbg-000000005bR-1ts0 for pgsql-bugs@lists.postgresql.org; Sat, 13 Jun 2026 00:52:17 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 65D0q94f1803066; Fri, 12 Jun 2026 20:52:10 -0400 From: Tom Lane To: clemens.ruck@t-online.de cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19518: Path resolution for loading a function fails, if postgres is somewhere in the path. In-reply-to: <19518-902fabd6a225851f@postgresql.org> References: <19518-902fabd6a225851f@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 12 Jun 2026 19:19:31 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1803064.1781311929.1@sss.pgh.pa.us> Date: Fri, 12 Jun 2026 20:52:09 -0400 Message-ID: <1803065.1781311929@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form 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