pgrx icon indicating copy to clipboard operation
pgrx copied to clipboard

Support Control `directory` Directive

Open theory opened this issue 1 year ago • 0 comments

I wanted to use the directory control file option; from the docs:

directory (string) The directory containing the extension's SQL script file(s). Unless an absolute path is given, the name is relative to the installation's SHAREDIR directory. The default behavior is equivalent to specifying directory = 'extension'.

Sadly it does not currently work after pgrx install:

    ERROR SQLSTATE[58P01]: could not open directory "/Users/david/.pgrx/13.14/pgrx-install/share/postgresql/jsonschema": No such file or directory
    query: CREATE EXTENSION jsonschema CASCADE;

PGXS doesn't know about it, either, requiring the MODULEDIR variable to be set to the same value. Here's how I enabled it for semver, which is a PGXS/C extension.

I think how it should work for pgrx is, if the directory field is set in the control file, it should copy the SQL files to the appropriate directory:

  • When it's a relative path, it means that instead of installing them in SHAREDIR/$directory instead of SHAREDIR/extension. Basically its default value is extension.
  • If it's an absolute path then it should be put the SQL files at that path.

I believe the option only applies to the SQL files; DSOs still go into PKGLIBDIR and the control file in SHAREDIR/extension (for now).

theory avatar Apr 05 '24 17:04 theory