Skip to content

Commit 9e7c27c

Browse files
Stop referencing pg_config in schema generation (pgcentralfoundation#2174)
Using `pg_config` during schema gen has been unnecessary for some time now, and has escaped dead code warnings because our `tracing` used it. Remove it from `generate_schema` and `copy_sql_files`. We still need it when running `cargo pgrx schema` per se as it modifies state to determine what features it should use. This is an incremental step towards pgcentralfoundation#2152 (comment)
1 parent a82184b commit 9e7c27c

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

cargo-pgrx/src/command/install.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ pub(crate) fn install_extension(
223223
user_manifest_path,
224224
user_package,
225225
package_manifest_path,
226-
pg_config,
227226
profile,
228227
is_test,
229228
features,
@@ -348,7 +347,6 @@ fn copy_sql_files(
348347
user_manifest_path: Option<impl AsRef<Path>>,
349348
user_package: Option<&String>,
350349
package_manifest_path: impl AsRef<Path>,
351-
pg_config: &PgConfig,
352350
profile: &CargoProfile,
353351
is_test: bool,
354352
features: &clap_cargo::Features,
@@ -364,7 +362,6 @@ fn copy_sql_files(
364362
let dest = extdir.join(filename);
365363

366364
crate::command::schema::generate_schema(
367-
pg_config,
368365
user_manifest_path,
369366
user_package,
370367
&package_manifest_path,

cargo-pgrx/src/command/schema.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use eyre::{WrapErr, eyre};
1616
use object::read::macho::MachOFatFile32;
1717
use owo_colors::OwoColorize;
1818
use pgrx_pg_config::cargo::PgrxManifestExt;
19-
use pgrx_pg_config::{PgConfig, Pgrx, get_target_dir};
19+
use pgrx_pg_config::{Pgrx, get_target_dir};
2020
use std::io::Write;
2121
use std::path::{Path, PathBuf};
2222
use std::process::Stdio;
@@ -82,7 +82,8 @@ impl CommandExecute for Schema {
8282
self.package.as_ref(),
8383
self.manifest_path.as_ref(),
8484
)?;
85-
let (pg_config, _pg_version) = pg_config_and_version(
85+
// This does meaningful mutation, unfortunately
86+
let (_pg_config, _pg_version) = pg_config_and_version(
8687
&pgrx,
8788
&package_manifest,
8889
self.pg_version.clone(),
@@ -96,7 +97,6 @@ impl CommandExecute for Schema {
9697
)?;
9798

9899
generate_schema(
99-
&pg_config,
100100
self.manifest_path.as_ref(),
101101
self.package.as_ref(),
102102
package_manifest_path,
@@ -114,15 +114,13 @@ impl CommandExecute for Schema {
114114
}
115115

116116
#[tracing::instrument(level = "error", skip_all, fields(
117-
pg_version = %pg_config.version()?,
118117
profile = ?profile,
119118
test = is_test,
120119
path = path.as_ref().map(|path| tracing::field::display(path.as_ref().display())),
121120
dot,
122121
features = ?features.features,
123122
))]
124123
pub(crate) fn generate_schema(
125-
pg_config: &PgConfig,
126124
user_manifest_path: Option<impl AsRef<Path>>,
127125
user_package: Option<&String>,
128126
package_manifest_path: impl AsRef<Path>,
@@ -662,7 +660,7 @@ fn slice_arch32<'a>(data: &'a [u8], arch: &str) -> Option<&'a [u8]> {
662660
#[cfg(test)]
663661
mod tests {
664662
use crate::command::schema::*;
665-
use pgrx_pg_config::PgConfigSelector;
663+
use pgrx_pg_config::{PgConfigSelector, Pgrx};
666664

667665
#[test]
668666
fn test_parse_managed_postmasters() {

0 commit comments

Comments
 (0)