On Mar 19, 2025, at 02:42, Peter Eisentraut <pe...@eisentraut.org> wrote:
> Committed that, thanks. š Iāve been meaning to test the patch again, so here goes. First thing I notice is that prefix= uses the magic to insert āpostgresqlā into the path if itās not already there: ``` console ⯠make PG_CONFIG=~/dev/c/postgres/pgsql-devel/bin/pg_config prefix=/Users/david/Downloads install /opt/homebrew/bin/gmkdir -p '/Users/david/Downloads/share/postgresql/extension' /opt/homebrew/bin/gmkdir -p '/Users/david/Downloads/share/postgresql/extension' /opt/homebrew/bin/gmkdir -p '/Users/david/Downloads/share/doc//postgresql/extension' /opt/homebrew/bin/ginstall -c -m 644 .//pair.control '/Users/david/Downloads/share/postgresql/extension/' /opt/homebrew/bin/ginstall -c -m 644 .//sql/pair--0.1.2.sql .//sql/pair--unpackaged--0.1.2.sql '/Users/david/Downloads/share/postgresql/extension/' /opt/homebrew/bin/ginstall -c -m 644 .//doc/pair.md '/Users/david/Downloads/share/doc//postgresql/extension/ā ``` I think this should at least be documented, but generally feels unexpected to me. Iāve attached a patch that fleshes out the docs, along with an example of setting `extension_control_path` and `dynamic_library_path` to use the locations. It might not have the information right about the need for āpostgresqlā or āpgsqlā in the path. Back in 2003[1] it was just āpostgresā, but I couldnāt find the logic for it just now. Everything else works very nicely except for extensions that use the Makefile `MODULEDIR` variable to install all of the share files except the control file into a particular directory, and the `directory` in the control file so that the files can be found. Hereās semver[2], which has both: ```console ⯠make PG_CONFIG=~/dev/c/postgres/pgsql-devel/bin/pg_config prefix=/Users/david/Downloads/postgresql install /opt/homebrew/bin/gmkdir -p '/Users/david/Downloads/postgresql/share/extension' /opt/homebrew/bin/gmkdir -p '/Users/david/Downloads/postgresql/share/semver' /opt/homebrew/bin/gmkdir -p '/Users/david/Downloads/postgresql/lib' /opt/homebrew/bin/gmkdir -p '/Users/david/Downloads/postgresql/share/doc//semver' /opt/homebrew/bin/ginstall -c -m 644 .//semver.control '/Users/david/Downloads/postgresql/share/extension/' /opt/homebrew/bin/ginstall -c -m 644 .//sql/semver--0.10.0--0.11.0.sql .//sql/semver--0.11.0--0.12.0.sql .//sql/semver--0.12.0--0.13.0.sql .//sql/semver--0.13.0--0.15.0.sql .//sql/semver--0.15.0--0.16.0.sql .//sql/semver--0.16.0--0.17.0.sql .//sql/semver--0.17.0--0.20.0.sql .//sql/semver--0.2.1--0.2.4.sql .//sql/semver--0.2.4--0.3.0.sql .//sql/semver--0.20.0--0.21.0.sql .//sql/semver--0.21.0--0.22.0.sql .//sql/semver--0.22.0--0.30.0.sql .//sql/semver--0.3.0--0.4.0.sql .//sql/semver--0.30.0--0.31.0.sql .//sql/semver--0.31.0--0.31.1.sql .//sql/semver--0.31.1--0.31.2.sql .//sql/semver--0.31.2--0.32.0.sql .//sql/semver--0.32.0--0.32.1.sql .//sql/semver--0.32.1--0.40.0.sql .//sql/semver--0.32.1.sql .//sql/semver--0.40.0.sql .//sql/semver--0.5.0--0.10.0.sql .//sql/semver--unpackaged--0.2.1.sql .//sql/semver.sql '/Users/david/Downloads/postgresql/share/semver/' /opt/homebrew/bin/ginstall -c -m 755 src/semver.dylib '/Users/david/Downloads/postgresql/lib/' /opt/homebrew/bin/gmkdir -p '/Users/david/Downloads/postgresql/lib/bitcode/src/semver' /opt/homebrew/bin/gmkdir -p '/Users/david/Downloads/postgresql/lib/bitcode'/src/semver/src/ /opt/homebrew/bin/ginstall -c -m 644 src/semver.bc '/Users/david/Downloads/postgresql/lib/bitcode'/src/semver/src/ cd '/Users/david/Downloads/postgresql/lib/bitcode' && /opt/homebrew/Cellar/llvm/19.1.7_1/bin/llvm-lto -thinlto -thinlto-action=thinlink -o src/semver.index.bc src/semver/src/semver.bc /opt/homebrew/bin/ginstall -c -m 644 .//doc/semver.mmd '/Users/david/Downloads/postgresql/share/doc//semver/ā ``` Following `MODULEDIR=semver`, it puts the SQL files into `share/semver/` instead of `share/extension/`, as expected, but then, even though the control file has `directory=semver`, it canāt load them: ```pgsql david=# create extension semver; ERROR: could not open directory "/Users/david/dev/c/postgres/pgsql-devel/share/semver": No such file or directory ``` Looks like itās only looking in the `semver` subdirectory under $libdir and not the whole path. But given that the `directory` variable in the control file can be a full path, I donāt see that thereās much of a way to generalize a solution. I guess there are three options: 1. If directory is a full path, try to load the files there. It probably already works that way, though I havenāt tired it. 2. If the directory is not a full path, check for it under each directory in `extension_control_path`? But no, that points to `share/extension`, not `share`, so it canāt really searched unless it also lops off `extension` from the end of each path. 3. Drop support for MODULEDIR and directory. I think Iād opt for #3, personally, just to simplify things. Anyway, I then built envvar, a C extension with no `directory` configuration, and it worked perfectly. I will say, though, that I will kind of miss being able to run `make install` without first running `make`, as the `prefix` variable does not work with `make`. Best, David [1]: https://postgr.es/m/pine.lnx.4.56.0307310942260.1...@krusty.credativ.de [2]: https://github.com/theory/pg-semver/ [3]: https://github.com/theory/pg-envvar
v1-0001-Flesh-out-docs-for-the-prefix-make-variable.patch
Description: Binary data
signature.asc
Description: Message signed with OpenPGP