I have an extension: https://github.com/CraigTyle/Mathexp
My task is to make the extension not relocatable: it should be possible to install the extension in any sc
First, you have to change relocatable
to false
in the extension's control file.
Other than that, the recommendation you got is partly reasonable and partly nonsense.
You should define your functions like this:
CREATE FUNCTION .... AS
$$ /* function body */ $$
SET search_path = @extschema@;
Then the search_path
is fixed to pg_catalog
, pg_temp
and your extension schema for the duration of the function call.
That means that all access to objects without an explicit schema will only search in these schemas.
Then you don't have to worry about explicitly qualifying everything in the function with @extschema@
, and you can use operators without having to worry, because search_path
applies to operators as well. (You can also schema-qualify operators: OPERATOR(schema.+)
, but that's obviously painful and harms readability.)