This command:
let mut command = Command::new(pg_config.psql_path()?);
command
.arg("-XqAt")
.env_remove("PGUSER")
.arg("-h")
.arg(pg_config.host())
.arg("-p")
.arg(pg_config.port()?.to_string())
.arg("template1")
.arg("-c")
.arg(format!(
"select count(*) from pg_database where datname = '{}';",
dbname.replace('\'', "''")
))
.stdout(Stdio::piped())
.stderr(Stdio::piped());
Return error:
Error:
0: problem checking if database 'pgnats' exists: "C:/Users/alche/PGRX~1/13.21/bin\\psql.exe" "-XqAt" "-h" "localhost" "-p" "28813" "template1" "-c" "select count(*) from pg_database where datname = \'pgnats\';"
psql: error: FATAL: role "-c" does not exist
But here's the order of the arguments:
let mut command = Command::new(pg_config.psql_path()?);
command
.arg("-XqAt")
.env_remove("PGUSER")
.arg("-h")
.arg(pg_config.host())
.arg("-p")
.arg(pg_config.port()?.to_string())
.arg("-c")
.arg(format!(
"select count(*) from pg_database where datname = '{}';",
dbname.replace('\'', "''")
))
.arg("template1")
.stdout(Stdio::piped())
.stderr(Stdio::piped());
Running successfully.
OS: Windows 11 64-bit, build 26100
This command:
Return error:
But here's the order of the arguments:
Running successfully.
OS: Windows 11 64-bit, build 26100