diff --git a/cargo-pgrx/src/command/init.rs b/cargo-pgrx/src/command/init.rs index 5f34dec87..6c96bcb6a 100644 --- a/cargo-pgrx/src/command/init.rs +++ b/cargo-pgrx/src/command/init.rs @@ -573,7 +573,7 @@ fn make_install_postgres( ) -> eyre::Result { let mut pg_config = get_pg_installdir(pgdir); pg_config.push("bin"); - pg_config.push("pg_config"); + pg_config.push("pg_config.exe"); Ok(PgConfig::new_with_defaults(pg_config)) } @@ -644,7 +644,10 @@ fn is_root_user() -> bool { pub(crate) fn initdb(bindir: &Path, datadir: &Path) -> eyre::Result<()> { println!(" {} data directory at {}", "Initializing".bold().green(), datadir.display()); + #[cfg(not(target_os = "windows"))] let initdb = bindir.join("initdb"); + #[cfg(target_os = "windows")] + let initdb = bindir.join("initdb.exe"); let mut command = std::process::Command::new(initdb); command .stdout(Stdio::piped()) diff --git a/cargo-pgrx/src/command/start.rs b/cargo-pgrx/src/command/start.rs index 24e3a7ae2..91ba59b26 100644 --- a/cargo-pgrx/src/command/start.rs +++ b/cargo-pgrx/src/command/start.rs @@ -91,7 +91,7 @@ pub(crate) fn start_postgres(pg_config: &PgConfig) -> eyre::Result<()> { pg_config.major_version()?, port.to_string().bold().cyan() ); - let pg_ctl = pg_config.bin_dir()?.join("pg_ctl"); + let pg_ctl = pg_config.pg_ctl_path()?; let mut command = std::process::Command::new(pg_ctl); command .stdout(Stdio::piped()) diff --git a/cargo-pgrx/src/command/status.rs b/cargo-pgrx/src/command/status.rs index 7a8cd2aab..87c3d1f53 100644 --- a/cargo-pgrx/src/command/status.rs +++ b/cargo-pgrx/src/command/status.rs @@ -64,7 +64,7 @@ pub(crate) fn status_postgres(pg_config: &PgConfig) -> eyre::Result { return Ok(false); } // if Err, let the filesystem and OS handle our impending failure - let pg_ctl = pg_config.bin_dir()?.join("pg_ctl"); + let pg_ctl = pg_config.pg_ctl_path()?; let mut command = process::Command::new(pg_ctl); command.stdout(Stdio::piped()).stderr(Stdio::piped()).arg("status").arg("-D").arg(&datadir); let command_str = format!("{command:?}"); diff --git a/cargo-pgrx/src/command/stop.rs b/cargo-pgrx/src/command/stop.rs index 0fb5706ac..8370ee7ef 100644 --- a/cargo-pgrx/src/command/stop.rs +++ b/cargo-pgrx/src/command/stop.rs @@ -79,7 +79,7 @@ pub(crate) fn stop_postgres(pg_config: &PgConfig) -> eyre::Result<()> { println!("{} Postgres v{}", " Stopping".bold().green(), pg_config.major_version()?); - let pg_ctl = pg_config.bin_dir()?.join("pg_ctl"); + let pg_ctl = pg_config.pg_ctl_path()?; let mut command = std::process::Command::new(pg_ctl); command .stdout(Stdio::piped()) diff --git a/pgrx-pg-config/src/lib.rs b/pgrx-pg-config/src/lib.rs index de142aebe..3dcbfed2b 100644 --- a/pgrx-pg-config/src/lib.rs +++ b/pgrx-pg-config/src/lib.rs @@ -333,32 +333,55 @@ impl PgConfig { pub fn postmaster_path(&self) -> eyre::Result { let mut path = self.bin_dir()?; + #[cfg(not(target_os = "windows"))] path.push("postgres"); - + #[cfg(target_os = "windows")] + path.push("postgres.exe"); Ok(path) } pub fn initdb_path(&self) -> eyre::Result { let mut path = self.bin_dir()?; + #[cfg(not(target_os = "windows"))] path.push("initdb"); + #[cfg(target_os = "windows")] + path.push("initdb.exe"); Ok(path) } pub fn createdb_path(&self) -> eyre::Result { let mut path = self.bin_dir()?; + #[cfg(not(target_os = "windows"))] path.push("createdb"); + #[cfg(target_os = "windows")] + path.push("createdb.exe"); Ok(path) } pub fn dropdb_path(&self) -> eyre::Result { let mut path = self.bin_dir()?; + #[cfg(not(target_os = "windows"))] path.push("dropdb"); + #[cfg(target_os = "windows")] + path.push("dropdb.exe"); + Ok(path) + } + + pub fn pg_ctl_path(&self) -> eyre::Result { + let mut path = self.bin_dir()?; + #[cfg(not(target_os = "windows"))] + path.push("pg_ctl"); + #[cfg(target_os = "windows")] + path.push("pg_ctl.exe"); Ok(path) } pub fn psql_path(&self) -> eyre::Result { let mut path = self.bin_dir()?; + #[cfg(not(target_os = "windows"))] path.push("psql"); + #[cfg(target_os = "windows")] + path.push("psql.exe"); Ok(path) } diff --git a/pgrx-tests/src/framework.rs b/pgrx-tests/src/framework.rs index 1132e52e8..cf2a41675 100644 --- a/pgrx-tests/src/framework.rs +++ b/pgrx-tests/src/framework.rs @@ -529,7 +529,7 @@ fn start_pg(loglines: LogLines) -> eyre::Result { let mut pipe = pipe::WindowsNamedPipe::create()?; let pg_config = get_pg_config()?; - let pg_ctl = pg_config.bin_dir()?.join("pg_ctl"); + let pg_ctl = pg_config.pg_ctl_path()?; let postmaster_path = if use_valgrind() { #[allow(unused_mut)] @@ -644,7 +644,7 @@ fn start_pg(loglines: LogLines) -> eyre::Result { add_shutdown_hook(|| { let pg_config = get_pg_config().unwrap(); - let pg_ctl = pg_config.bin_dir().unwrap().join("pg_ctl"); + let pg_ctl = pg_config.pg_ctl_path().unwrap(); let mut command = if let Some(runas) = get_runas() { let mut cmd = sudo_command(runas);