pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH] doc: Fix description of relative extension "directory" setting
7+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2026-11-20 207b5293b8  Fix long description of extension_control_path
  2026-11-20 4fba8bb0e5 72ab0515ef aa7d00fb75  doc: Fix description of $system in extension_control_path
  2026-11-20 3802b59db1 f9d9ab456d 60e0ccfaef  doc: Fix description of relative extension "directory" setting
* [PATCH] doc: Fix description of relative extension "directory" setting
@ 2026-10-31 03:47 Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-02 07:56 ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Chao Li <li.evan.chao@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Mahendrakar Srinivasarao @ 2026-10-31 03:47 UTC (permalink / raw)
  To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; +Cc: peter@eisentraut.org; mths.dev@pm.me

Hi,

Since PostgreSQL 18 (commit 81eaaa2c41d), the documentation of the
extension control file "directory" parameter says a relative path is
"relative to the directory where the control file was found".
However, that doesn't match the code: a relative path is resolved
against SHAREDIR,
or against the extension_control_path element in which the control
file was found, i.e. the parent of that "extension" directory.

Repro steps on master:

  /tmp/repro/extension/dir_doc_probe.control:
      default_version = '1.0'
      directory = 'scripts'
      relocatable = true

  /tmp/repro/scripts/dir_doc_probe--1.0.sql:
      CREATE TABLE dir_doc_probe_result (origin text);
      INSERT INTO dir_doc_probe_result VALUES ('installation base');

  /tmp/repro/extension/scripts/dir_doc_probe--1.0.sql:
      CREATE TABLE dir_doc_probe_result (origin text);
      INSERT INTO dir_doc_probe_result VALUES ('control-file directory');

  BEGIN;
  SET LOCAL extension_control_path = '/tmp/repro';
  CREATE EXTENSION dir_doc_probe;
  SELECT origin FROM dir_doc_probe_result;
        origin
  -------------------
   installation base
  (1 row)
  ROLLBACK;

The attached patch restores the pre-18 wording, extended to cover
extension_control_path, and clarifies the extension_control_path
description accordingly.

Attachments:

0001-doc-Fix-description-of-relative-extension-directory.patch (application/octet-stream, 3.0K) download From cd80fc7beac8229432c82d633c29543ed635ccc3 Mon Sep 17 00:00:00 2001 From: Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com> Date: Sat, 31 Oct 2026 03:11:36 +0000 Subject: [PATCH] doc: Fix description of relative extension "directory" setting Commit 81eaaa2c41d changed the documentation of the "directory" control file parameter to say that a relative path is resolved against the directory where the control file was found. That is not what the code does: a relative path is resolved against the parent of that "extension" directory, i.e., SHAREDIR or the extension_control_path element in which the control file was found. This is also what the TAP test in src/test/modules/test_extensions expects, and it keeps the long-standing convention of "directory = 'extension/foo'" (with MODULEDIR) working. Restore the pre-18 wording, extended to cover extension_control_path, and mention in the description of extension_control_path that the "directory" setting can cause script files to be loaded from somewhere other than the control file's directory. Backpatch to 18, where the incorrect wording was introduced. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- doc/src/sgml/config.sgml | 4 +++- doc/src/sgml/extend.sgml | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index f7db2995c3e..bbd12a37af6 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11703,7 +11703,9 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' A path to search for extensions, specifically extension control files (<filename><replaceable>name</replaceable>.control</filename>). The remaining extension script and secondary control files are then loaded - from the same directory where the primary control file was found. + from the same directory where the primary control file was found, + unless the primary control file specifies a different + <literal>directory</literal>. See <xref linkend="extend-extensions-files"/> for details. </para> diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml index 63c5ec6d1eb..0663702c402 100644 --- a/doc/src/sgml/extend.sgml +++ b/doc/src/sgml/extend.sgml @@ -674,9 +674,10 @@ RETURNS anycompatible AS ... <para> The directory containing the extension's <acronym>SQL</acronym> script file(s). Unless an absolute path is given, the name is relative to - the directory where the control file was found. By default, - the script files are looked for in the same directory where the - control file was found. + the installation's <literal>SHAREDIR</literal> directory, or to the + <xref linkend="guc-extension-control-path"/> element in which the + control file was found. The default behavior is equivalent to + specifying <literal>directory = 'extension'</literal>. </para> </listitem> </varlistentry> -- 2.43.0
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: [PATCH] doc: Fix description of relative extension "directory" setting
  2026-10-31 03:47 [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
@ 2026-11-02 07:56 ` Chao Li <li.evan.chao@gmail.com>
  2026-11-03 09:37   ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Chao Li @ 2026-11-02 07:56 UTC (permalink / raw)
  To: Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; peter@eisentraut.org; mths.dev@pm.me



> On Oct 31, 2026, at 11:47, Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com> wrote:
> 
> Hi,
> 
> Since PostgreSQL 18 (commit 81eaaa2c41d), the documentation of the
> extension control file "directory" parameter says a relative path is
> "relative to the directory where the control file was found".
> However, that doesn't match the code: a relative path is resolved
> against SHAREDIR,
> or against the extension_control_path element in which the control
> file was found, i.e. the parent of that "extension" directory.
> 
> Repro steps on master:
> 
>  /tmp/repro/extension/dir_doc_probe.control:
>      default_version = '1.0'
>      directory = 'scripts'
>      relocatable = true
> 
>  /tmp/repro/scripts/dir_doc_probe--1.0.sql:
>      CREATE TABLE dir_doc_probe_result (origin text);
>      INSERT INTO dir_doc_probe_result VALUES ('installation base');
> 
>  /tmp/repro/extension/scripts/dir_doc_probe--1.0.sql:
>      CREATE TABLE dir_doc_probe_result (origin text);
>      INSERT INTO dir_doc_probe_result VALUES ('control-file directory');
> 
>  BEGIN;
>  SET LOCAL extension_control_path = '/tmp/repro';
>  CREATE EXTENSION dir_doc_probe;
>  SELECT origin FROM dir_doc_probe_result;
>        origin
>  -------------------
>   installation base
>  (1 row)
>  ROLLBACK;
> 
> The attached patch restores the pre-18 wording, extended to cover
> extension_control_path, and clarifies the extension_control_path
> description accordingly.
> <0001-doc-Fix-description-of-relative-extension-directory.patch>

Thanks for the patch. I think the fix is going in the right direction.

The relevant code is:
```
static char *
get_extension_script_directory(ExtensionControlFile *control)
{
	/*
	 * The directory parameter can be omitted, absolute, or relative to the
	 * installation's base directory, which can be the sharedir or a custom
	 * path that was set via extension_control_path. It depends on where the
	 * .control file was found.
	 */
	if (!control->directory)
		return pstrdup(control->control_dir);

	if (is_absolute_path(control->directory))
		return pstrdup(control->directory);

	Assert(control->basedir != NULL);
	return psprintf("%s/%s", control->basedir, control->directory);
}
```

When control->directory is a relative path, it is resolved relative to control->basedir, which is either SHAREDIR or the corresponding path element in extension_control_path.

In the patch:
```
-        the directory where the control file was found.  By default,
-        the script files are looked for in the same directory where the
-        control file was found.
+        the installation's <literal>SHAREDIR</literal> directory, or to the
+        <xref linkend="guc-extension-control-path"/> element in which the
+        control file was found.  The default behavior is equivalent to
+        specifying <literal>directory = 'extension'</literal>.
```

I think the phrase "the extension_control_path element in which the control file was found" is a little misleading.

For example, suppose we have:
```
extension_control_path = '/opt/myext/share’
```

The primary control file is found in /opt/myext/share/extension. If it specifies:
```
directory = ‘scripts’
```

the scripts will be loaded from /opt/myext/share/scripts, not /opt/myext/share/extension/scripts.

So, saying "in which the control file was found" might suggest /opt/myext/share/extension, rather than /opt/myext/share. 

I would suggest wording it more explicitly, like:
```
or to the extension_control_path element used to locate the primary control file.
```

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










^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [PATCH] doc: Fix description of relative extension "directory" setting
  2026-10-31 03:47 [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-02 07:56 ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Chao Li <li.evan.chao@gmail.com>
@ 2026-11-03 09:37   ` Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-09 16:30     ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Matheus Alcantara <matheusssilv97@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Mahendrakar Srinivasarao @ 2026-11-03 09:37 UTC (permalink / raw)
  To: Chao Li <li.evan.chao@gmail.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

+PostgreSQL Hackers

On Tue, 3 Nov 2026 at 10:53, Chao Li <li.evan.chao@gmail.com> wrote:
>
>
>
> > On Nov 3, 2026, at 00:34, Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com> wrote:
> >
> > Hi Chao,
> >
> > Thanks for the review.
> >
> >> I would suggest wording it more explicitly, like:
> >> or to the extension_control_path element used to locate the primary control file.
> >
> > Agreed, the sentence "in which the control file was found" could be read as the
> > "extension" subdirectory itself.
> >
> > v2 patch uses your suggested wording:
> > ```
> >    Unless an absolute path is given, the name is relative to the
> >    installation's SHAREDIR directory, or to the extension_control_path
> >    element used to locate the primary control file.  The default
> >    behavior is equivalent to specifying directory = 'extension'.
> > ```
> > I have also updated the commit message to match the same.
> >
> > Best regards,
> > Mahendrakar.
> >
> > <v2-0001-doc-Fix-description-of-relative-extension-directo.patch>
>
> V2 LGTM.
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
>
>

Attachments:

v2-0001-doc-Fix-description-of-relative-extension-directo.patch (application/octet-stream, 3.0K) download From 709f1f7f614edb339c3c55d2a215cbe727b054cb Mon Sep 17 00:00:00 2001 From: Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com> Date: Sat, 31 Oct 2026 03:11:36 +0000 Subject: [PATCH v2] doc: Fix description of relative extension "directory" setting Commit 81eaaa2c41d changed the documentation of the "directory" control file parameter to say that a relative path is resolved against the directory where the control file was found. That is not what the code does: a relative path is resolved against the installation's base directory, i.e., SHAREDIR or the extension_control_path element used to locate the primary control file, not the "extension" subdirectory of it in which the control file actually resides. This is also what the TAP test in src/test/modules/test_extensions expects, and it keeps the long-standing convention of "directory = 'extension/foo'" (with MODULEDIR) working. Restore the pre-18 wording, extended to cover extension_control_path, and mention in the description of extension_control_path that the "directory" setting can cause script files to be loaded from somewhere other than the control file's directory. Backpatch to 18, where the incorrect wording was introduced. --- doc/src/sgml/config.sgml | 4 +++- doc/src/sgml/extend.sgml | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index f7db2995c3e..bbd12a37af6 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11703,7 +11703,9 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' A path to search for extensions, specifically extension control files (<filename><replaceable>name</replaceable>.control</filename>). The remaining extension script and secondary control files are then loaded - from the same directory where the primary control file was found. + from the same directory where the primary control file was found, + unless the primary control file specifies a different + <literal>directory</literal>. See <xref linkend="extend-extensions-files"/> for details. </para> diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml index 63c5ec6d1eb..a283cc259a0 100644 --- a/doc/src/sgml/extend.sgml +++ b/doc/src/sgml/extend.sgml @@ -674,9 +674,10 @@ RETURNS anycompatible AS ... <para> The directory containing the extension's <acronym>SQL</acronym> script file(s). Unless an absolute path is given, the name is relative to - the directory where the control file was found. By default, - the script files are looked for in the same directory where the - control file was found. + the installation's <literal>SHAREDIR</literal> directory, or to the + <xref linkend="guc-extension-control-path"/> element used to locate + the primary control file. The default behavior is equivalent to + specifying <literal>directory = 'extension'</literal>. </para> </listitem> </varlistentry> -- 2.43.0
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: [PATCH] doc: Fix description of relative extension "directory" setting
  2026-10-31 03:47 [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-02 07:56 ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Chao Li <li.evan.chao@gmail.com>
  2026-11-03 09:37   ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
@ 2026-11-09 16:30     ` Matheus Alcantara <matheusssilv97@gmail.com>
  2026-11-10 14:24       ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Matheus Alcantara @ 2026-11-09 16:30 UTC (permalink / raw)
  To: Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>; Chao Li <li.evan.chao@gmail.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

Hi,

Thanks for the patch!

I tested extension_control_path with a few different "directory" values:
a relative 'scripts', the MODULEDIR style 'extension/foo', an absolute
path, 'extension' and no directory at all. In all cases the scripts were
loaded from where the new wording says they should be, and 'extension'
behaves the same as not setting it. The patch also applies cleanly on
REL_18_STABLE, which has the same wrong text, and the docs build fine.

I have some small comments:

1: The SHAREDIR vs extension_control_path wording

-        the directory where the control file was found.  By default,
-        the script files are looked for in the same directory where the
-        control file was found.
+        the installation's <literal>SHAREDIR</literal> directory, or to the
+        <xref linkend="guc-extension-control-path"/> element used to locate
+        the primary control file.  The default behavior is equivalent to
+        specifying <literal>directory = 'extension'</literal>.

The "or" in the new sentence doesn't say when each case applies. If the
control file is found via $system, the extension_control_path element
is $system itself, which expands to SHAREDIR/extension, not SHAREDIR,
so the "element used to locate the primary control file" can still be
read as the extension subdirectory. Maybe something like this?

    Unless an absolute path is given, the name is relative to the parent
    of the extension directory where the primary control file was
    found, that is, the installation's SHAREDIR directory, or the
    corresponding extension_control_path element.

It's just a nit though, v2 is already much better than the current text.

2: Commit message

"relative to the installation's base directory, i.e., SHAREDIR or the
extension_control_path element" is a bit loose, since a custom path
element is not really the installation's directory. Just "the base
directory" would be enough IMO.

Unrelated to the "directory" fix, but while reading the
extension_control_path docs I noticed that it says "If a list element
starts with the special string $system, the compiled-in PostgreSQL
extension directory is substituted for $system", but
get_extension_control_directories() only accepts an exact match, so
something like '$system/foo' is not expanded. CREATE EXTENSION then
fails with "component in parameter "extension_control_path" is not an
absolute path", while pg_available_extensions silently skips it.

The attached v3 includes a 0002 that fixes the docs for this. 0001 is
the same as v2-0001, so the comments above still apply to it.

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

Attachments: download all (2 files, .tar.gz)

v3-0001-doc-Fix-description-of-relative-extension-directo.patch (text/plain, 3.0K) download From 92e25f8633fb68a2fb8b872064369b242f9ec0bb Mon Sep 17 00:00:00 2001 From: Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com> Date: Sat, 31 Oct 2026 03:11:36 +0000 Subject: [PATCH v3 1/2] doc: Fix description of relative extension "directory" setting Commit 81eaaa2c41d changed the documentation of the "directory" control file parameter to say that a relative path is resolved against the directory where the control file was found. That is not what the code does: a relative path is resolved against the installation's base directory, i.e., SHAREDIR or the extension_control_path element used to locate the primary control file, not the "extension" subdirectory of it in which the control file actually resides. This is also what the TAP test in src/test/modules/test_extensions expects, and it keeps the long-standing convention of "directory = 'extension/foo'" (with MODULEDIR) working. Restore the pre-18 wording, extended to cover extension_control_path, and mention in the description of extension_control_path that the "directory" setting can cause script files to be loaded from somewhere other than the control file's directory. Backpatch to 18, where the incorrect wording was introduced. --- doc/src/sgml/config.sgml | 4 +++- doc/src/sgml/extend.sgml | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index a6a2df177f2..0a94a7cac36 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11750,7 +11750,9 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' A path to search for extensions, specifically extension control files (<filename><replaceable>name</replaceable>.control</filename>). The remaining extension script and secondary control files are then loaded - from the same directory where the primary control file was found. + from the same directory where the primary control file was found, + unless the primary control file specifies a different + <literal>directory</literal>. See <xref linkend="extend-extensions-files"/> for details. </para> diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml index 63c5ec6d1eb..a283cc259a0 100644 --- a/doc/src/sgml/extend.sgml +++ b/doc/src/sgml/extend.sgml @@ -674,9 +674,10 @@ RETURNS anycompatible AS ... <para> The directory containing the extension's <acronym>SQL</acronym> script file(s). Unless an absolute path is given, the name is relative to - the directory where the control file was found. By default, - the script files are looked for in the same directory where the - control file was found. + the installation's <literal>SHAREDIR</literal> directory, or to the + <xref linkend="guc-extension-control-path"/> element used to locate + the primary control file. The default behavior is equivalent to + specifying <literal>directory = 'extension'</literal>. </para> </listitem> </varlistentry> -- 2.50.1 (Apple Git-155)
v3-0002-doc-Fix-description-of-system-in-extension_contro.patch (text/plain, 3.2K) download From 49cccd90f206605698accae18541d656f6342c9b Mon Sep 17 00:00:00 2001 From: Matheus Alcantara <mths.dev@pm.me> Date: Mon, 9 Nov 2026 13:04:54 -0300 Subject: [PATCH v3 2/2] doc: Fix description of $system in extension_control_path The documentation says that a list element of extension_control_path that starts with $system gets the system extension directory substituted for it. However, since commit 81eaaa2c41d, get_extension_control_directories() only recognizes an element that is exactly "$system". Any other element, like "$system/foo", is taken as a literal path with the "extension" suffix appended, so CREATE EXTENSION fails with a "not an absolute path" error, while pg_available_extensions silently returns no rows for it. Expanding $system as a prefix doesn't fit well with the path elements being base directories to which "extension" is appended, since $system already points to the extension directory itself. So, rather than changing the behavior, fix the documentation to say that the element must be exactly $system. While at it, clarify that $system is the "extension" subdirectory of pg_config --sharedir and that the "extension" suffix is not appended to it. Backpatch to 18, where the current behavior was introduced. --- doc/src/sgml/config.sgml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 0a94a7cac36..1f89be6eb04 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11759,14 +11759,15 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' <para> The value for <varname>extension_control_path</varname> must be a list of absolute directory paths separated by colons (or semi-colons - on Windows). If a list element starts - with the special string <literal>$system</literal>, the + on Windows). If a list element is + the special string <literal>$system</literal>, the compiled-in <productname>PostgreSQL</productname> extension directory is substituted for <literal>$system</literal>; this is where the extensions provided by the standard <productname>PostgreSQL</productname> distribution are installed. - (Use <literal>pg_config --sharedir</literal> to find out the name of - this directory.) For example: + (This is the <filename>extension</filename> subdirectory of the + directory shown by <literal>pg_config --sharedir</literal>.) + For example: <programlisting> extension_control_path = '/usr/local/share/postgresql:/home/my_project/share:$system' </programlisting> @@ -11778,7 +11779,9 @@ extension_control_path = 'C:\tools\postgresql;H:\my_project\share;$system' subdirectory <filename>extension</filename> which will contain the <filename>.control</filename> and <filename>.sql</filename> files; the <filename>extension</filename> suffix is automatically appended to - each path element. + each path element other than <literal>$system</literal>. + <literal>$system</literal> cannot be combined with other path + components, as in <literal>$system/foo</literal>. </para> <para> -- 2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: [PATCH] doc: Fix description of relative extension "directory" setting
  2026-10-31 03:47 [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-02 07:56 ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Chao Li <li.evan.chao@gmail.com>
  2026-11-03 09:37   ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-09 16:30     ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Matheus Alcantara <matheusssilv97@gmail.com>
@ 2026-11-10 14:24       ` Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-10 16:30         ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Matheus Alcantara <matheusssilv97@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Mahendrakar Srinivasarao @ 2026-11-10 14:24 UTC (permalink / raw)
  To: Matheus Alcantara <matheusssilv97@gmail.com>; +Cc: Chao Li <li.evan.chao@gmail.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

Hi Matheus,

Thanks for testing this and for the review.

> 1: The SHAREDIR vs extension_control_path wording

Agreed. With extension_control_path = '$system', a control file in
SHAREDIR/extension with directory = 'scripts' loads its scripts from
SHAREDIR/scripts, so "the element used to locate the primary control
file" could indeed be read as SHAREDIR/extension. v4-0001 uses your
suggested wording:

    Unless an absolute path is given, the name is relative to the parent
    of the extension directory where the primary control file was found,
    that is, the installation's SHAREDIR directory, or the corresponding
    extension_control_path element.

> 2: Commit message

Fixed; it now says the path is resolved against "the base directory,
i.e., the parent of the "extension" directory in which the primary
control file was found".

> The attached v3 includes a 0002 that fixes the docs for this.

I can reproduce it: with extension_control_path = '$system/foo',
pg_available_extensions returns no rows and CREATE EXTENSION fails with
"component in parameter "extension_control_path" is not an absolute
path". It's even more confusing when combined with a valid element:
with extension_control_path = '$system/foo:$system',
pg_available_extensions lists the extensions from $system (the bad
element is silently skipped as a nonexistent directory), but CREATE
EXTENSION on any of them still fails with the same error, because
find_in_paths() rejects the first element before it gets to $system.


0002 looks good and is included in v4 unchanged.

Two related things I noticed while testing:

- The long_desc of extension_control_path in guc_parameters.dat
  (guc_tables.c on 18) has the same "loaded from the same directory
  where the primary control file was found" sentence that 0001 fixes in
  config.sgml. The new 0003 adjusts it to match. Since it's a
  translatable string, I've kept it separate and meant it for master
  only, so 0001 and 0002 can be backpatched without it.

- The '$system/foo:$system' inconsistency comes from find_in_paths()
  and pg_available_extensions handling an invalid element differently,
  and from nothing validating the value when it's set. Would a check
  hook that rejects such elements at SET time be worth pursuing? One
  concern is that it could break existing setups: a value like
  '$system:$system/foo' works today for any extension found in $system,
  but with a check hook it would be rejected, and in postgresql.conf
  that would prevent the server from starting after an upgrade.
  dynamic_library_path also only validates its elements when they're
  used. If there's interest I can start a separate thread for that;
  it's not addressed in v4.

v4-0001 and v4-0002 are rebased on current master and apply cleanly to
REL_19_STABLE and REL_18_STABLE; the docs build without warnings.
v4-0003 applies on master (and REL_19_STABLE, if wanted there); it
builds and passes make check.

Attachments: download all (3 files, .tar.gz)

v4-0001-doc-Fix-description-of-relative-extension-directo.patch (application/octet-stream, 3.1K) download From 3e986520e797f61fc05f6d176d0ae35901d9a4b1 Mon Sep 17 00:00:00 2001 From: Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com> Date: Sat, 31 Oct 2026 03:11:36 +0000 Subject: [PATCH v4 1/2] doc: Fix description of relative extension "directory" setting Commit 81eaaa2c41d changed the documentation of the "directory" control file parameter to say that a relative path is resolved against the directory where the control file was found. That is not what the code does: a relative path is resolved against the base directory, i.e., the parent of the "extension" directory in which the primary control file was found (SHAREDIR or the corresponding extension_control_path element). This is also what the TAP test in src/test/modules/test_extensions expects, and it keeps the long-standing convention of "directory = 'extension/foo'" (with MODULEDIR) working. Restore the pre-18 wording, extended to cover extension_control_path, and mention in the description of extension_control_path that the "directory" setting can cause script files to be loaded from somewhere other than the control file's directory. Backpatch to 18, where the incorrect wording was introduced. --- doc/src/sgml/config.sgml | 4 +++- doc/src/sgml/extend.sgml | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 7018ca1e3ea..d7b65469948 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11750,7 +11750,9 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' A path to search for extensions, specifically extension control files (<filename><replaceable>name</replaceable>.control</filename>). The remaining extension script and secondary control files are then loaded - from the same directory where the primary control file was found. + from the same directory where the primary control file was found, + unless the primary control file specifies a different + <literal>directory</literal>. See <xref linkend="extend-extensions-files"/> for details. </para> diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml index 63c5ec6d1eb..9bbc5b56fbf 100644 --- a/doc/src/sgml/extend.sgml +++ b/doc/src/sgml/extend.sgml @@ -674,9 +674,12 @@ RETURNS anycompatible AS ... <para> The directory containing the extension's <acronym>SQL</acronym> script file(s). Unless an absolute path is given, the name is relative to - the directory where the control file was found. By default, - the script files are looked for in the same directory where the - control file was found. + the parent of the <filename>extension</filename> directory where the + primary control file was found, that is, the installation's + <literal>SHAREDIR</literal> directory, or the corresponding + <xref linkend="guc-extension-control-path"/> element. The default + behavior is equivalent to specifying + <literal>directory = 'extension'</literal>. </para> </listitem> </varlistentry> -- 2.43.0
v4-0002-doc-Fix-description-of-system-in-extension_contro.patch (application/octet-stream, 3.2K) download From feb79ade292f4b6e2a7c539651c15cccad1a832a Mon Sep 17 00:00:00 2001 From: Matheus Alcantara <mths.dev@pm.me> Date: Mon, 9 Nov 2026 13:04:54 -0300 Subject: [PATCH v4 2/2] doc: Fix description of $system in extension_control_path The documentation says that a list element of extension_control_path that starts with $system gets the system extension directory substituted for it. However, since commit 81eaaa2c41d, get_extension_control_directories() only recognizes an element that is exactly "$system". Any other element, like "$system/foo", is taken as a literal path with the "extension" suffix appended, so CREATE EXTENSION fails with a "not an absolute path" error, while pg_available_extensions silently returns no rows for it. Expanding $system as a prefix doesn't fit well with the path elements being base directories to which "extension" is appended, since $system already points to the extension directory itself. So, rather than changing the behavior, fix the documentation to say that the element must be exactly $system. While at it, clarify that $system is the "extension" subdirectory of pg_config --sharedir and that the "extension" suffix is not appended to it. Backpatch to 18, where the current behavior was introduced. --- doc/src/sgml/config.sgml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index d7b65469948..ef0f6725de3 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -11759,14 +11759,15 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' <para> The value for <varname>extension_control_path</varname> must be a list of absolute directory paths separated by colons (or semi-colons - on Windows). If a list element starts - with the special string <literal>$system</literal>, the + on Windows). If a list element is + the special string <literal>$system</literal>, the compiled-in <productname>PostgreSQL</productname> extension directory is substituted for <literal>$system</literal>; this is where the extensions provided by the standard <productname>PostgreSQL</productname> distribution are installed. - (Use <literal>pg_config --sharedir</literal> to find out the name of - this directory.) For example: + (This is the <filename>extension</filename> subdirectory of the + directory shown by <literal>pg_config --sharedir</literal>.) + For example: <programlisting> extension_control_path = '/usr/local/share/postgresql:/home/my_project/share:$system' </programlisting> @@ -11778,7 +11779,9 @@ extension_control_path = 'C:\tools\postgresql;H:\my_project\share;$system' subdirectory <filename>extension</filename> which will contain the <filename>.control</filename> and <filename>.sql</filename> files; the <filename>extension</filename> suffix is automatically appended to - each path element. + each path element other than <literal>$system</literal>. + <literal>$system</literal> cannot be combined with other path + components, as in <literal>$system/foo</literal>. </para> <para> -- 2.43.0
v4-0003-Fix-long-description-of-extension_control_path.patch (application/octet-stream, 1.6K) download From 6c9b7ad4083bb36e8d62315d563b9c14a5963897 Mon Sep 17 00:00:00 2001 From: Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com> Date: Tue, 10 Nov 2026 14:05:25 +0000 Subject: [PATCH v4 3/3] Fix long description of extension_control_path The long description of extension_control_path says that the remaining extension script and secondary control files are loaded from the same directory where the primary control file was found. That is not the case if the primary control file specifies a "directory". Adjust it to match the documentation of extension_control_path. Since this changes a translatable string, apply to master only. --- src/backend/utils/misc/guc_parameters.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/utils/misc/guc_parameters.dat b/src/backend/utils/misc/guc_parameters.dat index 75d832eb570..93d1399d518 100644 --- a/src/backend/utils/misc/guc_parameters.dat +++ b/src/backend/utils/misc/guc_parameters.dat @@ -1069,7 +1069,7 @@ { name => 'extension_control_path', type => 'string', context => 'PGC_SUSET', group => 'CLIENT_CONN_OTHER', short_desc => 'Sets the path for extension control files.', - long_desc => 'The remaining extension script and secondary control files are then loaded from the same directory where the primary control file was found.', + long_desc => 'The remaining extension script and secondary control files are then loaded from the same directory where the primary control file was found, unless the primary control file specifies a different directory.', flags => 'GUC_SUPERUSER_ONLY', variable => 'Extension_control_path', boot_val => '"$system"', -- 2.43.0
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: [PATCH] doc: Fix description of relative extension "directory" setting
  2026-10-31 03:47 [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-02 07:56 ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Chao Li <li.evan.chao@gmail.com>
  2026-11-03 09:37   ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-09 16:30     ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Matheus Alcantara <matheusssilv97@gmail.com>
  2026-11-10 14:24       ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
@ 2026-11-10 16:30         ` Matheus Alcantara <matheusssilv97@gmail.com>
  2026-11-11 05:19           ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Chao Li <li.evan.chao@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Matheus Alcantara @ 2026-11-10 16:30 UTC (permalink / raw)
  To: Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>; +Cc: Chao Li <li.evan.chao@gmail.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

On Tue Nov 10, 2026 at 11:24 AM -03, Mahendrakar Srinivasarao wrote:
>> The attached v3 includes a 0002 that fixes the docs for this.
>
> I can reproduce it: with extension_control_path = '$system/foo',
> pg_available_extensions returns no rows and CREATE EXTENSION fails with
> "component in parameter "extension_control_path" is not an absolute
> path". It's even more confusing when combined with a valid element:
> with extension_control_path = '$system/foo:$system',
> pg_available_extensions lists the extensions from $system (the bad
> element is silently skipped as a nonexistent directory), but CREATE
> EXTENSION on any of them still fails with the same error, because
> find_in_paths() rejects the first element before it gets to $system.
>
>
> 0002 looks good and is included in v4 unchanged.
>

Thanks for checking!

> Two related things I noticed while testing:
>
> - The long_desc of extension_control_path in guc_parameters.dat
>   (guc_tables.c on 18) has the same "loaded from the same directory
>   where the primary control file was found" sentence that 0001 fixes in
>   config.sgml. The new 0003 adjusts it to match. Since it's a
>   translatable string, I've kept it separate and meant it for master
>   only, so 0001 and 0002 can be backpatched without it.
>

Good.

> - The '$system/foo:$system' inconsistency comes from find_in_paths()
>   and pg_available_extensions handling an invalid element differently,
>   and from nothing validating the value when it's set. Would a check
>   hook that rejects such elements at SET time be worth pursuing? One
>   concern is that it could break existing setups: a value like
>   '$system:$system/foo' works today for any extension found in $system,
>   but with a check hook it would be rejected, and in postgresql.conf
>   that would prevent the server from starting after an upgrade.
>   dynamic_library_path also only validates its elements when they're
>   used. If there's interest I can start a separate thread for that;
>   it's not addressed in v4.
>

This seems related with another discussion about an
extension_control_path bug [1] that accepts an empty path element and
append /extension by mistake. I think that we can discuss about this
case on this other thread.

> v4-0001 and v4-0002 are rebased on current master and apply cleanly to
> REL_19_STABLE and REL_18_STABLE; the docs build without warnings.
> v4-0003 applies on master (and REL_19_STABLE, if wanted there); it
> builds and passes make check.

v4 looks good to me, thanks! 

I've moved the CF entry from drafts to PG20-4. If there is no other
comments on this I think that we can mark this as Ready for Committer in
the following days.


[1] https://www.postgresql.org/message-id/DC2D9FA5-45C4-494F-99FC-F9B95AD4FF55@gmail.com

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






^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [PATCH] doc: Fix description of relative extension "directory" setting
  2026-10-31 03:47 [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-02 07:56 ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Chao Li <li.evan.chao@gmail.com>
  2026-11-03 09:37   ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-09 16:30     ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Matheus Alcantara <matheusssilv97@gmail.com>
  2026-11-10 14:24       ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
  2026-11-10 16:30         ` Re: [PATCH] doc: Fix description of relative extension "directory" setting Matheus Alcantara <matheusssilv97@gmail.com>
@ 2026-11-11 05:19           ` Chao Li <li.evan.chao@gmail.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Chao Li @ 2026-11-11 05:19 UTC (permalink / raw)
  To: Matheus Alcantara <matheusssilv97@gmail.com>; +Cc: Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>



> On Nov 11, 2026, at 00:30, Matheus Alcantara <matheusssilv97@gmail.com> wrote:
> 
> On Tue Nov 10, 2026 at 11:24 AM -03, Mahendrakar Srinivasarao wrote:
>>> The attached v3 includes a 0002 that fixes the docs for this.
>> 
>> I can reproduce it: with extension_control_path = '$system/foo',
>> pg_available_extensions returns no rows and CREATE EXTENSION fails with
>> "component in parameter "extension_control_path" is not an absolute
>> path". It's even more confusing when combined with a valid element:
>> with extension_control_path = '$system/foo:$system',
>> pg_available_extensions lists the extensions from $system (the bad
>> element is silently skipped as a nonexistent directory), but CREATE
>> EXTENSION on any of them still fails with the same error, because
>> find_in_paths() rejects the first element before it gets to $system.
>> 
>> 
>> 0002 looks good and is included in v4 unchanged.
>> 
> 
> Thanks for checking!
> 
>> Two related things I noticed while testing:
>> 
>> - The long_desc of extension_control_path in guc_parameters.dat
>>  (guc_tables.c on 18) has the same "loaded from the same directory
>>  where the primary control file was found" sentence that 0001 fixes in
>>  config.sgml. The new 0003 adjusts it to match. Since it's a
>>  translatable string, I've kept it separate and meant it for master
>>  only, so 0001 and 0002 can be backpatched without it.
>> 
> 
> Good.
> 
>> - The '$system/foo:$system' inconsistency comes from find_in_paths()
>>  and pg_available_extensions handling an invalid element differently,
>>  and from nothing validating the value when it's set. Would a check
>>  hook that rejects such elements at SET time be worth pursuing? One
>>  concern is that it could break existing setups: a value like
>>  '$system:$system/foo' works today for any extension found in $system,
>>  but with a check hook it would be rejected, and in postgresql.conf
>>  that would prevent the server from starting after an upgrade.
>>  dynamic_library_path also only validates its elements when they're
>>  used. If there's interest I can start a separate thread for that;
>>  it's not addressed in v4.
>> 
> 
> This seems related with another discussion about an
> extension_control_path bug [1] that accepts an empty path element and
> append /extension by mistake. I think that we can discuss about this
> case on this other thread.
> 
>> v4-0001 and v4-0002 are rebased on current master and apply cleanly to
>> REL_19_STABLE and REL_18_STABLE; the docs build without warnings.
>> v4-0003 applies on master (and REL_19_STABLE, if wanted there); it
>> builds and passes make check.
> 
> v4 looks good to me, thanks! 
> 

V4 LGTM too.

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










^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2026-11-11 05:19 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31 03:47 [PATCH] doc: Fix description of relative extension "directory" setting Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
2026-11-02 07:56 ` Chao Li <li.evan.chao@gmail.com>
2026-11-03 09:37   ` Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
2026-11-09 16:30     ` Matheus Alcantara <matheusssilv97@gmail.com>
2026-11-10 14:24       ` Mahendrakar Srinivasarao <mahendrakarforpg@gmail.com>
2026-11-10 16:30         ` Matheus Alcantara <matheusssilv97@gmail.com>
2026-11-11 05:19           ` Chao Li <li.evan.chao@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox