Skip to content

Commit f777d77

Browse files
committed
Don't strip $libdir from LOAD command
Commit 4f7f7b0 implemented the extension_control_path GUC, and to make it work it was decided that we should strip the $libdir/ on module_pathname from .control files, so that extensions don't need to worry about this change. This strip logic was implemented on expand_dynamic_library_name() which works fine when executing the SQL functions from extensions, but this function is also called when the LOAD command is executed, and since the user may explicitly pass the $libdir prefix on LOAD parameter, we should not strip in this case. This commit fixes this issue by moving the strip logic from expand_dynamic_library_name() to load_external_function() that is called when the running the SQL script from extensions. Reported-by: Evan Si <evsi@amazon.com> Author: Matheus Alcantara <matheusssilv97@gmail.com> Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Rahila Syed <rahilasyed90@gmail.com> Bug: #18920 Discussion: https://www.postgresql.org/message-id/flat/18920-b350b1c0a30af006%40postgresql.org
1 parent 7f3381c commit f777d77

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/backend/utils/fmgr/dfmgr.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ load_external_function(const char *filename, const char *funcname,
9999
void *lib_handle;
100100
void *retval;
101101

102+
/*
103+
* If the value starts with "$libdir/", strip that. This is because many
104+
* extensions have hardcoded '$libdir/foo' as their library name, which
105+
* prevents using the path.
106+
*/
107+
if (strncmp(filename, "$libdir/", 8) == 0)
108+
filename += 8;
109+
102110
/* Expand the possibly-abbreviated filename to an exact path name */
103111
fullname = expand_dynamic_library_name(filename);
104112

@@ -456,14 +464,6 @@ expand_dynamic_library_name(const char *name)
456464

457465
Assert(name);
458466

459-
/*
460-
* If the value starts with "$libdir/", strip that. This is because many
461-
* extensions have hardcoded '$libdir/foo' as their library name, which
462-
* prevents using the path.
463-
*/
464-
if (strncmp(name, "$libdir/", 8) == 0)
465-
name += 8;
466-
467467
have_slash = (first_dir_separator(name) != NULL);
468468

469469
if (!have_slash)

0 commit comments

Comments
 (0)