1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

Make "directory" setting work with extension_control_path

The extension_control_path setting (commit 4f7f7b0375) did not
support extensions that set a custom "directory" setting in their
control file.  Very few extensions use that and during the discussion
on the previous commit it was suggested to maybe remove that
functionality.  But a fix was easier than initially thought, so this
just adds that support.  The fix is to use the control->control_dir as
a share dir to return the path of the extension script files.

To make this work more sensibly overall, the directory suffix
"extension" is no longer to be included in the extension_control_path
value.  To quote the patch, it would be

-extension_control_path = '/usr/local/share/postgresql/extension:/home/my_project/share/extension:$system'
+extension_control_path = '/usr/local/share/postgresql:/home/my_project/share:$system'

During the initial patch, there was some discussion on which of these
two approaches would be better, and the committed patch was a 50/50
decision.  But the support for the "directory" setting pushed it the
other way, and also it seems like many people didn't like the previous
behavior much.

Author: Matheus Alcantara <mths.dev@pm.me>
Reviewed-by: Christoph Berg <myon@debian.org>
Reviewed-by: David E. Wheeler <david@justatheory.com>
Discussion: https://www.postgresql.org/message-id/flat/aAi1VACxhjMhjFnb%40msg.df7cb.de#0cdf7b7d727cc593b029650daa3c4fbc
This commit is contained in:
Peter Eisentraut
2025-05-02 16:25:40 +02:00
parent a724c7889f
commit 81eaaa2c41
4 changed files with 147 additions and 58 deletions

View File

@ -11030,16 +11030,17 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
(Use <literal>pg_config --sharedir</literal> to find out the name of
this directory.) For example:
<programlisting>
extension_control_path = '/usr/local/share/postgresql/extension:/home/my_project/share/extension:$system'
extension_control_path = '/usr/local/share/postgresql:/home/my_project/share:$system'
</programlisting>
or, in a Windows environment:
<programlisting>
extension_control_path = 'C:\tools\postgresql\extension;H:\my_project\share\extension;$system'
extension_control_path = 'C:\tools\postgresql;H:\my_project\share;$system'
</programlisting>
Note that the path elements should typically end in
<literal>extension</literal> if the normal installation layouts are
followed. (The value for <literal>$system</literal> already includes
the <literal>extension</literal> suffix.)
Note that the specified paths elements are expected to have a
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.
</para>
<para>
@ -11064,7 +11065,7 @@ extension_control_path = 'C:\tools\postgresql\extension;H:\my_project\share\exte
linkend="guc-dynamic-library-path"/> to a correspondent location, for
example,
<programlisting>
extension_control_path = '/usr/local/share/postgresql/extension:$system'
extension_control_path = '/usr/local/share/postgresql:$system'
dynamic_library_path = '/usr/local/lib/postgresql:$libdir'
</programlisting>
</para>

View File

@ -674,7 +674,7 @@ 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 installation's <literal>SHAREDIR</literal> directory. By default,
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.
</para>
@ -1836,7 +1836,7 @@ make install prefix=/usr/local/extras
linkend="guc-dynamic-library-path"/> to enable the
<productname>PostgreSQL</productname> server to find the files:
<programlisting>
extension_control_path = '/usr/local/extras/share/postgresql/extension:$system'
extension_control_path = '/usr/local/extras/share/postgresql:$system'
dynamic_library_path = '/usr/local/extras/lib/postgresql:$libdir'
</programlisting>
</para>