From c41332ed9726f8a6c9501356beacae3fddbb1b8c Mon Sep 17 00:00:00 2001 From: "David E. Wheeler" Date: Mon, 28 Apr 2025 17:05:40 -0400 Subject: [PATCH] Remove the $libdir/ prefix from module_pathname It limits the search to PKGLIBDIR; if anyone installs it into another directory in `dynamic_library_path`, Postgres won't be able to find it. --- cargo-pgrx/README.md | 6 +++--- cargo-pgrx/src/templates/control | 2 +- pgrx-examples/aggregate/aggregate.control | 2 +- pgrx-examples/arrays/arrays.control | 2 +- pgrx-examples/bad_ideas/bad_ideas.control | 2 +- pgrx-examples/bgworker/bgworker.control | 2 +- pgrx-examples/bytea/bytea.control | 2 +- pgrx-examples/composite_type/composite_type.control | 2 +- pgrx-examples/custom_libname/other_name.control | 2 +- pgrx-examples/custom_sql/custom_sql.control | 2 +- pgrx-examples/custom_types/custom_types.control | 2 +- pgrx-examples/datetime/datetime.control | 2 +- pgrx-examples/errors/errors.control | 2 +- pgrx-examples/nostd/nostd.control | 2 +- pgrx-examples/numeric/numeric.control | 2 +- pgrx-examples/operators/operators.control | 2 +- pgrx-examples/pgtrybuilder/pgtrybuilder.control | 2 +- pgrx-examples/range/range.control | 2 +- pgrx-examples/schemas/schemas.control | 2 +- pgrx-examples/shmem/shmem.control | 2 +- pgrx-examples/spi/spi.control | 2 +- pgrx-examples/spi_srf/spi_srf.control | 2 +- pgrx-examples/srf/srf.control | 2 +- pgrx-examples/strings/strings.control | 2 +- pgrx-examples/triggers/triggers.control | 2 +- .../versioned_custom_libname_so/versioned_othername.control | 2 +- pgrx-examples/versioned_so/versioned_so.control | 2 +- pgrx-examples/wal_decoder/wal_decoder.control | 2 +- pgrx-sql-entity-graph/src/pgrx_sql.rs | 2 +- pgrx-tests/pgrx_tests.control | 2 +- 30 files changed, 32 insertions(+), 32 deletions(-) diff --git a/cargo-pgrx/README.md b/cargo-pgrx/README.md index 54ae0b8514..962d7fed21 100644 --- a/cargo-pgrx/README.md +++ b/cargo-pgrx/README.md @@ -699,7 +699,7 @@ AS 'MODULE_PATHNAME', 'hello_extension_wrapper'; ``` `MODULE_PATHNAME` is replaced by Postgres with the configured value in the `.control` file. For pgrx-based extensions, -this is usually set to `$libdir/`. +this is usually set to ``. When using versioned shared-object support, the same SQL would look as follows: @@ -707,7 +707,7 @@ When using versioned shared-object support, the same SQL would look as follows: CREATE OR REPLACE FUNCTION "hello_extension"() RETURNS text /* &str */ STRICT LANGUAGE c /* Rust */ -AS '$libdir/extension-0.0.0', 'hello_extension_wrapper'; +AS 'extension-0.0.0', 'hello_extension_wrapper'; ``` Note that the versioned shared library is hard-coded in the function definition. This corresponds to the @@ -722,7 +722,7 @@ produce the following SQL for the above function: CREATE OR REPLACE FUNCTION "hello_extension"() RETURNS text /* &str */ STRICT LANGUAGE c /* Rust */ -AS '$libdir/extension-0.1.0', 'hello_extension_wrapper'; +AS 'extension-0.1.0', 'hello_extension_wrapper'; ``` This SQL must be used in the upgrade script from `0.0.0` to `0.1.0` in order to point the `hello_extension` function to diff --git a/cargo-pgrx/src/templates/control b/cargo-pgrx/src/templates/control index e3420399e4..d2473b69a0 100644 --- a/cargo-pgrx/src/templates/control +++ b/cargo-pgrx/src/templates/control @@ -1,6 +1,6 @@ comment = '{name}: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/{name}' +module_pathname = '{name}' relocatable = false superuser = true trusted = false diff --git a/pgrx-examples/aggregate/aggregate.control b/pgrx-examples/aggregate/aggregate.control index 047c037be0..64212de7ce 100644 --- a/pgrx-examples/aggregate/aggregate.control +++ b/pgrx-examples/aggregate/aggregate.control @@ -1,5 +1,5 @@ comment = 'aggregate: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/aggregate' +module_pathname = 'aggregate' relocatable = false superuser = false diff --git a/pgrx-examples/arrays/arrays.control b/pgrx-examples/arrays/arrays.control index 6a9a251e67..5fbcbc516b 100644 --- a/pgrx-examples/arrays/arrays.control +++ b/pgrx-examples/arrays/arrays.control @@ -1,6 +1,6 @@ comment = 'arrays: Created by pgrx' default_version = '0.1.0' -module_pathname = '$libdir/arrays' +module_pathname = 'arrays' relocatable = false superuser = false schema = arrays \ No newline at end of file diff --git a/pgrx-examples/bad_ideas/bad_ideas.control b/pgrx-examples/bad_ideas/bad_ideas.control index 7983c398e8..94e6ee403c 100644 --- a/pgrx-examples/bad_ideas/bad_ideas.control +++ b/pgrx-examples/bad_ideas/bad_ideas.control @@ -1,5 +1,5 @@ comment = 'bad_ideas: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/bad_ideas' +module_pathname = 'bad_ideas' relocatable = false superuser = false diff --git a/pgrx-examples/bgworker/bgworker.control b/pgrx-examples/bgworker/bgworker.control index 3689125861..d8fa57e157 100644 --- a/pgrx-examples/bgworker/bgworker.control +++ b/pgrx-examples/bgworker/bgworker.control @@ -1,5 +1,5 @@ comment = 'bgworker: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/bgworker' +module_pathname = 'bgworker' relocatable = false superuser = false diff --git a/pgrx-examples/bytea/bytea.control b/pgrx-examples/bytea/bytea.control index cad4c8573f..cb29ecb9f0 100644 --- a/pgrx-examples/bytea/bytea.control +++ b/pgrx-examples/bytea/bytea.control @@ -1,5 +1,5 @@ comment = 'bytea: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/bytea' +module_pathname = 'bytea' relocatable = false superuser = false diff --git a/pgrx-examples/composite_type/composite_type.control b/pgrx-examples/composite_type/composite_type.control index 81f4226e69..ee577f0713 100644 --- a/pgrx-examples/composite_type/composite_type.control +++ b/pgrx-examples/composite_type/composite_type.control @@ -1,5 +1,5 @@ comment = 'composite_type: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/composite_type' +module_pathname = 'composite_type' relocatable = false superuser = false diff --git a/pgrx-examples/custom_libname/other_name.control b/pgrx-examples/custom_libname/other_name.control index c4fa6a4c3c..1dbca9f3e0 100644 --- a/pgrx-examples/custom_libname/other_name.control +++ b/pgrx-examples/custom_libname/other_name.control @@ -1,5 +1,5 @@ comment = 'custom_libname: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/other_name' +module_pathname = 'other_name' relocatable = false superuser = false diff --git a/pgrx-examples/custom_sql/custom_sql.control b/pgrx-examples/custom_sql/custom_sql.control index 299c69dbd2..7ab0cc226c 100644 --- a/pgrx-examples/custom_sql/custom_sql.control +++ b/pgrx-examples/custom_sql/custom_sql.control @@ -1,5 +1,5 @@ comment = 'custom_sql: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/custom_sql' +module_pathname = 'custom_sql' relocatable = false superuser = false diff --git a/pgrx-examples/custom_types/custom_types.control b/pgrx-examples/custom_types/custom_types.control index 9fde95cd2a..370e0b1dc5 100644 --- a/pgrx-examples/custom_types/custom_types.control +++ b/pgrx-examples/custom_types/custom_types.control @@ -1,6 +1,6 @@ comment = 'custom_types: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/custom_types' +module_pathname = 'custom_types' relocatable = false superuser = false trusted = false diff --git a/pgrx-examples/datetime/datetime.control b/pgrx-examples/datetime/datetime.control index ce2bf3a279..4c14263621 100644 --- a/pgrx-examples/datetime/datetime.control +++ b/pgrx-examples/datetime/datetime.control @@ -1,5 +1,5 @@ comment = 'arrays: Created by pgrx' default_version = '0.1.0' -module_pathname = '$libdir/datetime' +module_pathname = 'datetime' relocatable = true superuser = false \ No newline at end of file diff --git a/pgrx-examples/errors/errors.control b/pgrx-examples/errors/errors.control index 692a927f8a..c0f7fb68fc 100644 --- a/pgrx-examples/errors/errors.control +++ b/pgrx-examples/errors/errors.control @@ -1,6 +1,6 @@ comment = 'errors: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/errors' +module_pathname = 'errors' relocatable = false superuser = false schema = errors \ No newline at end of file diff --git a/pgrx-examples/nostd/nostd.control b/pgrx-examples/nostd/nostd.control index e9d1646118..b99695d09b 100644 --- a/pgrx-examples/nostd/nostd.control +++ b/pgrx-examples/nostd/nostd.control @@ -1,5 +1,5 @@ comment = 'nostd: Created by pgrx' default_version = '1.0' -module_pathname = '$libdir/nostd' +module_pathname = 'nostd' relocatable = false superuser = false diff --git a/pgrx-examples/numeric/numeric.control b/pgrx-examples/numeric/numeric.control index 9fbe0f96e5..5a373d6d96 100644 --- a/pgrx-examples/numeric/numeric.control +++ b/pgrx-examples/numeric/numeric.control @@ -1,5 +1,5 @@ comment = 'numeric: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/numeric' +module_pathname = 'numeric' relocatable = false superuser = false diff --git a/pgrx-examples/operators/operators.control b/pgrx-examples/operators/operators.control index f9d382ef93..91723f61ff 100644 --- a/pgrx-examples/operators/operators.control +++ b/pgrx-examples/operators/operators.control @@ -1,5 +1,5 @@ comment = 'operators: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/operators' +module_pathname = 'operators' relocatable = false superuser = false diff --git a/pgrx-examples/pgtrybuilder/pgtrybuilder.control b/pgrx-examples/pgtrybuilder/pgtrybuilder.control index cbcd972da3..86612ecae2 100644 --- a/pgrx-examples/pgtrybuilder/pgtrybuilder.control +++ b/pgrx-examples/pgtrybuilder/pgtrybuilder.control @@ -1,6 +1,6 @@ comment = 'pgtrybuilder: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/pgtrybuilder' +module_pathname = 'pgtrybuilder' relocatable = false superuser = false schema = pgtrybuilder \ No newline at end of file diff --git a/pgrx-examples/range/range.control b/pgrx-examples/range/range.control index 5e22c89469..0ea04c01c8 100644 --- a/pgrx-examples/range/range.control +++ b/pgrx-examples/range/range.control @@ -1,6 +1,6 @@ comment = 'range: Created by pgrx' default_version = '0.1.0' -module_pathname = '$libdir/range' +module_pathname = 'range' relocatable = false superuser = false schema = range \ No newline at end of file diff --git a/pgrx-examples/schemas/schemas.control b/pgrx-examples/schemas/schemas.control index 622e9d5df9..678fa2e989 100644 --- a/pgrx-examples/schemas/schemas.control +++ b/pgrx-examples/schemas/schemas.control @@ -1,5 +1,5 @@ comment = 'schemas: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/schemas' +module_pathname = 'schemas' relocatable = false superuser = true # b/c this extension creates objects in "pg_catalog" diff --git a/pgrx-examples/shmem/shmem.control b/pgrx-examples/shmem/shmem.control index 533705ea1e..bbf8b2f473 100644 --- a/pgrx-examples/shmem/shmem.control +++ b/pgrx-examples/shmem/shmem.control @@ -1,5 +1,5 @@ comment = 'shmem: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/shmem' +module_pathname = 'shmem' relocatable = false superuser = false diff --git a/pgrx-examples/spi/spi.control b/pgrx-examples/spi/spi.control index be7f884854..66a434750f 100644 --- a/pgrx-examples/spi/spi.control +++ b/pgrx-examples/spi/spi.control @@ -1,6 +1,6 @@ comment = 'spi: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/spi' +module_pathname = 'spi' relocatable = false superuser = false schema = 'spi' diff --git a/pgrx-examples/spi_srf/spi_srf.control b/pgrx-examples/spi_srf/spi_srf.control index 040869ffd3..d5f1034342 100644 --- a/pgrx-examples/spi_srf/spi_srf.control +++ b/pgrx-examples/spi_srf/spi_srf.control @@ -1,6 +1,6 @@ comment = 'spi_srf: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/spi_srf' +module_pathname = 'spi_srf' relocatable = false superuser = false schema = 'spi_srf' diff --git a/pgrx-examples/srf/srf.control b/pgrx-examples/srf/srf.control index ed3e4f11fa..30294986c5 100644 --- a/pgrx-examples/srf/srf.control +++ b/pgrx-examples/srf/srf.control @@ -1,6 +1,6 @@ comment = 'srf: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/srf' +module_pathname = 'srf' relocatable = false superuser = false schema = srf diff --git a/pgrx-examples/strings/strings.control b/pgrx-examples/strings/strings.control index 0540f20946..feb0f936d9 100644 --- a/pgrx-examples/strings/strings.control +++ b/pgrx-examples/strings/strings.control @@ -1,6 +1,6 @@ comment = 'strings: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/strings' +module_pathname = 'strings' relocatable = false superuser = false schema = strings \ No newline at end of file diff --git a/pgrx-examples/triggers/triggers.control b/pgrx-examples/triggers/triggers.control index 2fe3a989ef..df226b5357 100644 --- a/pgrx-examples/triggers/triggers.control +++ b/pgrx-examples/triggers/triggers.control @@ -1,5 +1,5 @@ comment = 'triggers: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/triggers' +module_pathname = 'triggers' relocatable = false superuser = false diff --git a/pgrx-examples/versioned_custom_libname_so/versioned_othername.control b/pgrx-examples/versioned_custom_libname_so/versioned_othername.control index 1ac8aaa332..bd0f67508e 100644 --- a/pgrx-examples/versioned_custom_libname_so/versioned_othername.control +++ b/pgrx-examples/versioned_custom_libname_so/versioned_othername.control @@ -1,6 +1,6 @@ comment = 'versioned_custom_libname_so: Created by pgrx' default_version = '@CARGO_VERSION@' # commenting-out module_pathname results in this extension being built/run/tested in "versioned shared-object mode" -# module_pathname = '$libdir/versioned_othername' +# module_pathname = 'versioned_othername' relocatable = false superuser = false diff --git a/pgrx-examples/versioned_so/versioned_so.control b/pgrx-examples/versioned_so/versioned_so.control index 261737e9b1..f24144206b 100644 --- a/pgrx-examples/versioned_so/versioned_so.control +++ b/pgrx-examples/versioned_so/versioned_so.control @@ -1,6 +1,6 @@ comment = 'versioned_so: Created by pgrx' default_version = '@CARGO_VERSION@' # commenting-out module_pathname results in this extension being built/run/tested in "versioned shared-object mode" -# module_pathname = '$libdir/versioned_so' +# module_pathname = 'versioned_so' relocatable = false superuser = false diff --git a/pgrx-examples/wal_decoder/wal_decoder.control b/pgrx-examples/wal_decoder/wal_decoder.control index 6734490c93..1a7c758526 100644 --- a/pgrx-examples/wal_decoder/wal_decoder.control +++ b/pgrx-examples/wal_decoder/wal_decoder.control @@ -1,6 +1,6 @@ comment = 'wal_decoder: Created by pgrx' default_version = '@CARGO_VERSION@' -module_pathname = '$libdir/wal_decoder' +module_pathname = 'wal_decoder' relocatable = false superuser = true trusted = false diff --git a/pgrx-sql-entity-graph/src/pgrx_sql.rs b/pgrx-sql-entity-graph/src/pgrx_sql.rs index 6afcd69497..6635b7b3af 100644 --- a/pgrx-sql-entity-graph/src/pgrx_sql.rs +++ b/pgrx-sql-entity-graph/src/pgrx_sql.rs @@ -456,7 +456,7 @@ impl PgrxSql { let extname = &self.extension_name; let extver = &self.control.default_version; // Note: versioned so-name format must agree with cargo pgrx - format!("$libdir/{extname}-{extver}") + format!("{extname}-{extver}") } else { String::from("MODULE_PATHNAME") } diff --git a/pgrx-tests/pgrx_tests.control b/pgrx-tests/pgrx_tests.control index ceb8c414aa..7f597ff227 100644 --- a/pgrx-tests/pgrx_tests.control +++ b/pgrx-tests/pgrx_tests.control @@ -1,5 +1,5 @@ comment = 'tests: Created by pgrx' default_version = '1.0' -module_pathname = '$libdir/pgrx_tests' +module_pathname = 'pgrx_tests' relocatable = false superuser = false