@@ -65,6 +65,7 @@ typedef struct ExtensionControlFile
65
65
char * name ; /* name of the extension */
66
66
char * directory ; /* directory for script files */
67
67
char * default_version ; /* default install target version, if any */
68
+ char * module_pathname ; /* string to substitute for MODULE_PATHNAME */
68
69
char * comment ; /* comment, if any */
69
70
char * schema ; /* target schema (allowed if !relocatable) */
70
71
bool relocatable ; /* is ALTER EXTENSION SET SCHEMA supported? */
@@ -493,6 +494,10 @@ parse_extension_control_file(ExtensionControlFile *control,
493
494
494
495
control -> default_version = pstrdup (item -> value );
495
496
}
497
+ else if (strcmp (item -> name , "module_pathname" ) == 0 )
498
+ {
499
+ control -> module_pathname = pstrdup (item -> value );
500
+ }
496
501
else if (strcmp (item -> name , "comment" ) == 0 )
497
502
{
498
503
control -> comment = pstrdup (item -> value );
@@ -836,7 +841,20 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
836
841
CStringGetTextDatum (sql ),
837
842
CStringGetTextDatum ("@extschema@" ),
838
843
CStringGetTextDatum (qSchemaName ))));
844
+ }
839
845
846
+ /*
847
+ * If module_pathname was set in the control file, substitute its
848
+ * value for occurrences of MODULE_PATHNAME.
849
+ */
850
+ if (control -> module_pathname )
851
+ {
852
+ sql = text_to_cstring (
853
+ DatumGetTextPP (
854
+ DirectFunctionCall3 (replace_text ,
855
+ CStringGetTextDatum (sql ),
856
+ CStringGetTextDatum ("MODULE_PATHNAME" ),
857
+ CStringGetTextDatum (control -> module_pathname ))));
840
858
}
841
859
842
860
execute_sql_string (sql , filename );
0 commit comments