How to make an extension not relocatable?

前端 未结 1 1428
野性不改
野性不改 2020-12-12 05:18

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

相关标签:
1条回答
  • 2020-12-12 06:17

    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.)

    0 讨论(0)
提交回复
热议问题