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 1wgulF-006Ucz-07 for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jul 2026 01:38:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wgulD-003yGb-0y for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jul 2026 01:38:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wgulC-003yGH-38 for pgsql-bugs@lists.postgresql.org; Tue, 07 Jul 2026 01:38:07 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wgul4-000000029uH-3Y26 for pgsql-bugs@lists.postgresql.org; Tue, 07 Jul 2026 01:38:01 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-37e0a189b0bso2590003a91.1 for ; Mon, 06 Jul 2026 18:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783388276; cv=none; d=google.com; s=arc-20260327; b=pGbj4bmUX8mqR3RgGl5l28BI470jD4XMzQs4BAt0o+C0nLMb0y0GNz8ksTzQ9/99JG QzPIWL1T93NN8W0uqqoWejadByPmrVobWu29P1CnKcd4VsFguzq691Y7/gsxPOif4Wop KIwNXp0ThLKYPSfoL2oaQ+zFfsHNXJXRO+hSB/y/LkZNDzpkK/9avhW1f95YVPalwOva fJ25yidOccBZhuoxnOeMwfz46Nsek6JZishovxlrjRtJYb1udO54Mqukpm2zhEdg3Wvn wZNe1EFlD0gnjCLHbFKCMYCvwzbfQ671oCMORyHNkiSSrtlkmqFRhP4TxxRF5rvBEahY Cv1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=MW22mhDf8YVcHTj5AIFouQv1vtALQ0rmfGdJXk+XZPE=; fh=JXVXBrdd+UlLTc0VEvHnJlXdhHqueeAKTQ2v70WDMcA=; b=iM0LsObhWnd9l4CYLcSf5dlDpmDoQbABR1rBF7NVdHw4BEIG1ZljuMMDwX08nNAUpi CjgGYeDpF0fdl7Q1sKQP/NBeb0DQs1x+izZRK9+m9U9mE57UmO+A1fOSuj0MgsMQdehT 7//b+SebyXyhZxF/Jjc0HfKb+snC86ieycAPMLVmkhbqREEgG3LWRzJy+7tytJ3SKiqI aqhRLg9y9O+xz7UuXTWGxCoxi9TdRhKk6ORtrdr0y8XAoo/GLJC5UCKYS1PQ2CFlM+Ga rV1CiHvUmROQblHu9P64keoTLM4LHJlpsJ1x4l0+kBDa/72np1lHDRO14UL3qy76hG3t JUVg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1783388276; x=1783993076; darn=lists.postgresql.org; h=content-type:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MW22mhDf8YVcHTj5AIFouQv1vtALQ0rmfGdJXk+XZPE=; b=cHvJdSBJ1rrg9w4rvOCdlMiB1SFGaFjY1vO4cNyzCkZsZ2cnCjhFOFH67IG7MaqVKd nH3eyALCBAMU0g056ZlY/4FX+Tn9HSvfrttvjwgoxmr1RMIjcInVdI8m8igm7fq7n+AM +iZgUbnVqip9eH9TmBXTPvTdOMzsoLNEY8bdLDW56ZXAKneVEAjUQwpuTort0BeK/X5D xAD/JfUqtHSh7Fq3B6Utbhcx3FpWMN+vp+yJP9twRw7TkPRW+erumtsTiDsksEp30NDj kou1bikR/1VlvBU3UAN0eqoOSxrWzLiuTu6lL4GWBaEUV4k9fjbOz5P07G4b+J3as9/C vdqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783388276; x=1783993076; h=content-type:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=MW22mhDf8YVcHTj5AIFouQv1vtALQ0rmfGdJXk+XZPE=; b=fb804DjsL929wAaiaDqGLNda0GmYLfq2AzZYRZHB9dv+wYLMJt/zW/6Lc9ZfZuncjG m6GvHG34Huph14isFvI7CFNrEH3a2OaYO8h8j0xtD5R8PgAJSrr5LPjCT/w1DSAclW4z +eDG54fIRIhEEkTkAL6lh2pEKtDf+s2BAzCkEyG/NvW59SDJAX5SqVFmurEn6JIWBaS2 XiCyGse3pk2MJmDXH++viq6AGu6GoGmpHxKoWM544uIbyRWR/3JP3Jo2oupcGMqCCJ13 vbD4dNT1ZHrozJCKDzdNHy3SD8iz52IV5XB31zNW5qeth2Wi945554hPRHmIwoWRPvS6 y9FA== X-Forwarded-Encrypted: i=1; AHgh+Rq2QhQd1KAATzxII5ZMMfiKdlwvv8U6s40RuC6PFjaSi1cEGOxn4t1/z0hKQr0SslXaJLmSOanvQftR@lists.postgresql.org X-Gm-Message-State: AOJu0Yz0j1cAmYb4jvTW6NvAK8jrJOPh/0vNe+uNw39UBLQWc02piEGp UwN8TBn9DC1NxGYhq87WRicc8V+VCo6L82Va2Tp8zh7AgBvXeV+3bUsscbd9ta+41EzZYIknRL0 O/IveoY6bKgVN7ogCfiVzvg21kpnG3DGtxgrBVXai X-Gm-Gg: AfdE7cn80C/I/rLrITa22GAfv7TQzWB++TkoGKsq3zWmJjKL6p7tT4e/pMXiTjPyKpX Z37ykjb6a0eG5L7m1Q5nH/37ujuTz7cVXg+rr7H4osk7/Ppw60l3p5R6I+NBKelmwUYCrnN6RxZ UJYCyfzGhfrLlBy0MLQW2FZbDYaVQyIhj7Y8WxiHbUAWBbpi2ieX7TWSbAoSxsHBNu2z1MLeDej c8GawOjZ9xjMwFl4GVYpzkivVkmbY7H+pPbACCaLCXGPqJw7/fx7SDNhI5bLx5ntYWOS59SvbTV MKXPgNFt X-Received: by 2002:a17:90b:4c03:b0:37f:9cdf:f03e with SMTP id 98e67ed59e1d1-3875789548cmr3243199a91.33.1783388275910; Mon, 06 Jul 2026 18:37:55 -0700 (PDT) MIME-Version: 1.0 References: <19506-9478f3012ecc2328@postgresql.org> <9ef850b9-d127-44db-9a6c-4db64436b056@gmail.com> In-Reply-To: From: Gabriele Bartolini Date: Tue, 7 Jul 2026 11:37:42 +1000 X-Gm-Features: AVVi8Cel_pkheylwdBMdAbiElGtEsl5NYFHnKB9pnU-2dTgcnsKL09B_j4mkXAo Message-ID: Subject: Re: BUG #19506: LOAD '$libdir/...' inside extension scripts ignores dynamic_library_path with extension_control_path To: Matheus Alcantara Cc: gabriele.bartolini@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form Content-Type: multipart/alternative; boundary="000000000000aebb8e0655fb70f0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000aebb8e0655fb70f0 Content-Type: text/plain; charset="UTF-8" Hi Matheus, do you think we can apply this patch to the next Postgres minor release? On Wed, 24 Jun 2026 at 19:47, Gabriele Bartolini < gabriele.bartolini@enterprisedb.com> wrote: > Hi everyone, > > I realised I hadn't sent this email with the patch. Please find the > attached patch. > > Thanks, > Gabriele > > On Fri, 5 Jun 2026 at 22:12, Matheus Alcantara > wrote: > >> On 03/06/26 19:21, PG Bug reporting form wrote: >> > The following bug has been logged on the website: >> > >> > Bug reference: 19506 >> > Logged by: Gabriele Bartolini >> > Email address: gabriele.bartolini@gmail.com >> > PostgreSQL version: 18.4 >> > Operating system: Linux (reproduced under CloudNativePG/Kubernetes) >> > Description: >> > >> > When an extension is installed in a location reached via >> > `extension_control_path` / `dynamic_library_path` (rather than the >> > compiled-in package library directory), a LOAD '$libdir/foo' hardcoded >> > inside an extension's SQL script fails to find the library. PostGIS does >> > this in its upgrade scripts, so a PostGIS upgrade fails: >> > >> > ``` >> > app=# SELECT postgis_extensions_upgrade(); >> > NOTICE: Updating extension postgis 3.6.1 >> > ERROR: could not access file "$libdir/postgis-3": No such file or >> directory >> > CONTEXT: SQL statement "LOAD '$libdir/postgis-3'" >> > extension script file "postgis--ANY--3.6.3.sql", near line 1530 >> > ``` >> > >> > This is a side effect of the fix for bug #18920 (commit f777d773878). >> Commit >> > 4f7f7b03758 (`extension_control_path`) made the feature work by >> stripping >> > the '$libdir/' prefix so that dynamic_library_path is consulted. #18920 >> then >> > restricted that stripping to the function-load path so that a >> user-issued >> > `LOAD` keeps the literal '$libdir/' prefix. As a result, a `LOAD` >> inside an >> > extension script now also keeps the literal prefix, so >> > `dynamic_library_path` is never consulted, and the library cannot be >> found. >> > >> >> The only reason that it was decided that we should strip the $libdir >> was that almost all popular extensions use $libdir prefix on >> module_pathname on .control files, so the extension_control_path would >> not work and waiting for extensions to change this will make the >> extension_control_path almost useless (I hope that we can remove this >> in the future once 18 is the minimum supported version). >> >> I'm not sure if we also want this for the LOAD command, I'm wondering >> if the postgis could remove the $libdir prefix from the LOAD command >> instead of Postgres striping this, what do you think? IIRC a simple >> LOAD 'postgis-3' on versions before 18 will still works. >> >> I think that extensions should start to remove the $libdir prefix >> since extension_control_path is going to the second release cycle, but >> I agree that it seems more complicated than it actually is. >> >> -- >> Matheus Alcantara >> EDB: https://www.enterprisedb.com >> >> >> > > -- > Gabriele Bartolini > VP, Chief Architect, Kubernetes > enterprisedb.com / Melbourne, Australia > -- Gabriele Bartolini VP, Chief Architect, Kubernetes enterprisedb.com / Melbourne, Australia --000000000000aebb8e0655fb70f0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Matheus, do you think we can apply this patch to the ne= xt Postgres minor release?


On Wed, 24 J= un 2026 at 19:47, Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> wrote:
=
Hi= everyone,

I realised I hadn't sent this email with = the patch. Please find the attached patch.

Thanks,
= Gabriele

On Fri, 5 Jun 2026 at 22:12, Matheus Alcantara <matheusssilv97@gmail= .com> wrote:
On 03/06/26 19:21, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference:=C2=A0 =C2=A0 =C2=A0 19506
> Logged by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Gabriele Bartolini
> Email address:=C2=A0 =C2=A0 =C2=A0 gabriele.bartolini@gmail.com
> PostgreSQL version: 18.4
> Operating system:=C2=A0 =C2=A0Linux (reproduced under CloudNativePG/Ku= bernetes)
> Description:
>
> When an extension is installed in a location reached via
> `extension_control_path` / `dynamic_library_path` (rather than the
> compiled-in package library directory), a LOAD '$libdir/foo' h= ardcoded
> inside an extension's SQL script fails to find the library. PostGI= S does
> this in its upgrade scripts, so a PostGIS upgrade fails:
>
> ```
> app=3D# SELECT postgis_extensions_upgrade();
> NOTICE:=C2=A0 Updating extension postgis 3.6.1
> ERROR:=C2=A0 could not access file "$libdir/postgis-3": No s= uch file or directory
> CONTEXT:=C2=A0 SQL statement "LOAD '$libdir/postgis-3'&qu= ot;
> extension script file "postgis--ANY--3.6.3.sql", near line 1= 530
> ```
>
> This is a side effect of the fix for bug #18920 (commit f777d773878). = Commit
> 4f7f7b03758 (`extension_control_path`) made the feature work by stripp= ing
> the '$libdir/' prefix so that dynamic_library_path is consulte= d. #18920 then
> restricted that stripping to the function-load path so that a user-iss= ued
> `LOAD` keeps the literal '$libdir/' prefix. As a result, a `LO= AD` inside an
> extension script now also keeps the literal prefix, so
> `dynamic_library_path` is never consulted, and the library cannot be f= ound.
>

The only reason that it was decided that we should strip the $libdir
was that almost all popular extensions use $libdir prefix on
module_pathname on .control files, so the extension_control_path would
not work and waiting for extensions to change this will make the
extension_control_path almost useless (I hope that we can remove this
in the future once 18 is the minimum supported version).

I'm not sure if we also want this for the LOAD command, I'm wonderi= ng
if the postgis could remove the $libdir prefix from the LOAD command
instead of Postgres striping this, what do you think? IIRC a simple
LOAD 'postgis-3' on versions before 18 will still works.

I think that extensions should start to remove the $libdir prefix
since extension_control_path is going to the second release cycle, but
I agree that it seems more complicated than it actually is.

--
Matheus Alcantara
EDB: https://www.enterprisedb.com




--
Gabriele Bartolini
VP, Chief Arch= itect, Kubernetes
enterprisedb.com=C2=A0/ Melbourne, Australia


--
Gabriele Bartolini
VP, Chief Arch= itect, Kubernetes
enterprisedb.com=C2=A0/ Melbourne, Australia
--000000000000aebb8e0655fb70f0--