Re: extension_control_path and "directory" - Mailing list pgsql-hackers

From Christoph Berg
Subject Re: extension_control_path and "directory"
Date
Msg-id aAoQkqwktHQI5KLO@msg.df7cb.de
Whole thread Raw
In response to Re: extension_control_path and "directory"  (Matheus Alcantara <matheusssilv97@gmail.com>)
Responses Re: extension_control_path and "directory"
List pgsql-hackers
Re: Matheus Alcantara
> I've tested with the semver extension and it seems to work fine with
> this patch. Can you please check on your side to see if it's also
> working?

Hi Matheus,

thanks for the patch, it does indeed work.

diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 180f4af9be3..d68efd59118 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -376,6 +376,14 @@ get_extension_control_directories(void)
 
             /* Substitute the path macro if needed */
             mangled = substitute_path_macro(piece, "$system", system_dir);
+
+            /*
+             * Append "extension" suffix in case is a custom extension control
+             * path.
+             */
+            if (strcmp(piece, "$system") != 0)
+                mangled = psprintf("%s/extension", mangled);

This would look prettier if it was something like

             mangled = substitute_path_macro(piece, "$system", system_dir "/extension");

... but I'm wondering if it wouldn't be saner if the control path
should be stored without "extension" in that struct. Then opening the
control file would be path + "extension/" + filename and the extra
directory would be path + directory, without any on-the-fly stripping
of trailing components.

The extension_control_path GUC could also be adjusted to refer to the
directory one level above the extension/foo.control location.


+    /*
+     * Assert that the control->control_dir end with /extension suffix so that
+     * we can replace with the value from control->directory.
+     */
+    Assert(ctrldir_len >= suffix_len &&
+           strcmp(control->control_dir + ctrldir_len - suffix_len, "extension") == 0);

If control_dir is coming from extension_control_path, it might have a
different suffix. Replace the Assert by elog(ERROR). (Or see above.)

Christoph



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Fix premature xmin advancement during fast forward decoding
Next
From: shveta malik
Date:
Subject: Re: Fix slot synchronization with two_phase decoding enabled