From 0c492d28fc4fb66a3008437cd0f6a0fefd12f2ca Mon Sep 17 00:00:00 2001 From: Dom Dwyer Date: Sat, 10 Aug 2024 23:35:08 +0200 Subject: [PATCH] fix: don't read .psqlrc for automated DB export The dump_db::run_psql() function spawns a psql child process to run a an export script, but psql will automatically load and execute the content of the user's ~/.psqlrc file if it exists and execute it before the export script. The statements executed from the psqlrc file might change connection parameters (for example, the search path) in a way that causes the script to fail. This commit stops psql sourcing the psqlrc file at startup, meaning the connection should always be in a fresh / clean state. --- src/worker/jobs/dump_db.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/worker/jobs/dump_db.rs b/src/worker/jobs/dump_db.rs index adaf5cfe49..7878a27b12 100644 --- a/src/worker/jobs/dump_db.rs +++ b/src/worker/jobs/dump_db.rs @@ -180,6 +180,7 @@ pub fn run_psql(script: &Path, database_url: &str) -> anyhow::Result<()> { File::open(script).with_context(|| format!("Failed to open {}", script.display()))?; let psql = std::process::Command::new("psql") + .arg("--no-psqlrc") .arg(database_url) .current_dir(script.parent().unwrap()) .stdin(psql_script)