Re: extension_control_path: ignore empty elements and deduplicate directories

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: extension_control_path: ignore empty elements and deduplicate directories
Date: 2026-11-17 05:37:38
Message-ID: D5595BF2-C586-480E-9275-415891556F14@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Nov 17, 2026, at 00:40, Matheus Alcantara <matheusssilv97(at)gmail(dot)com> wrote:
>
> On 16/11/26 13:26, Andres Freund wrote:
>> Hi,
>> On 2026-11-16 13:20:41 -0300, Matheus Alcantara wrote:
>>> On Mon Nov 16, 2026 at 12:10 PM -03, Andres Freund wrote:
>>>> I don't like silently ignoring user mistakes. Either we should make it an
>>>> error or accept it. Which user would be served by silently reinterpreting
>>>> what they might have meant?
>>>>
>>>
>>> The idea on v6 is that it just discard empty path elements. It doesn't
>>> mean that the path element will be reinterpreted. So if an user set
>>> extension_control_path = '$system:' just $system will be used.
>>>
>>> We already ignore paths that does not exists, so the idea was to follow
>>> the same behavior.
>> I don't think that's the same. A non-existing extension dir could make sense,
>> e.g. to allow installing extensions from container overlays. And it's not
>> ignoring the users intent to ignore it, since there obviously aren't
>> extensions in there. What's the argument for ignoring empty path elements
>> instead of erroring out?
>
> I think that is mostly for back-patching. Turning into an error would
> make a server to not start after a minor release upgrade. Querying
> pg_available_extensions would also break after the upgrade with an
> empty path element.
>
> Ideally I also think that raising an error would be better, but this
> back-patching issue got me, and having different behaviors across
> different versions also seems confusing to me, but I might being to
> conservative here.
>
> (Thinking while writing this, and not being too conservative, perhaps we can consider to ignore empty path elements for back-patching and change master to raise an error since the with extension_control_path = '$system:' is an invalid syntax.).
>
> --
> Matheus Alcantara
> EDB: https://www.enterprisedb.com

V1 silently discarded empty path elements, v2/v3/v4 switched to raising an error, and v5/v6 changed back to silently discarding them.

Personally, I don’t have a strong preference for either approach. Silently discarding empty elements mainly benefits backward compatibility. When /extension doesn’t exist, it preserves the existing behavior; when /extension exists, it prevents an unintended search of that directory.

I also agree that rejecting empty path elements is reasonable. A similar case in PG is dynamic_library_path. find_in_path() in dfmgr.c also rejects empty elements. If we take this approach, the main compatibility question is whether to back-patch it. Back-patching could break extension lookups on an existing cluster whose extension_control_path happens to be defined as '/path_1:/path_2:'.

As I mentioned previously, I think applying the fix only to master is also an option.

One thing I want to add is that extension_control_path currently has no way to specify an empty search list to prevent installing additional extensions. An empty string ('') is interpreted as '$system'. A workaround is to specify an empty or nonexistent directory, such as '/foo', but that still searches /foo/extension and depends on what exists there. With v6, ':' can represent an empty search list. However, I don’t see this as an argument for choosing the silent-discard approach. It's more of a separate feature. We could also provide the way to specify an empty search list while rejecting empty elements.

Since we haven’t reached an agreement yet, I’ll hold off on revising the patch for now and wait for more feedback.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ayush Tiwari 2026-11-17 05:39:24 Re: Fix two race conditions in processing interrupts
Previous Message Manu 2026-11-17 05:32:27 Use an index scan in RemoveSubscriptionRel()