Re: BUG #18971: Server passes an invalid (indirect) path in PGDATA to the external program

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: d(dot)kovalenko(at)postgrespro(dot)ru
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18971: Server passes an invalid (indirect) path in PGDATA to the external program
Date: 2025-06-28 19:13:25
Message-ID: 2334360.1751138005@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> 4) pg_probackup3 process has the following environment variables:
> PWD="/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/restored/data"
> PGDATA="../../../../../../../../../../../../home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/restored/data"
> ---------- PROBLEM
> PGDATA (4) is invalid for pg_probackup3.

I do not think this is a Postgres bug. The PGDATA environment
variable is not canonical, it is just the default to be used if
you don't specify a -D switch on the postmaster/pg_ctl command line.
In fact, it might not be set at all. (I see that pg_ctl does set
it, but pg_ctl is not the only way to start the postmaster.)
Therefore, relying on PGDATA in a restore_command script isn't safe.
You should be relying on the current working directory (PWD) instead.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dmitry Kovalenko 2025-06-28 19:32:59 Re: BUG #18971: Server passes an invalid (indirect) path in PGDATA to the external program
Previous Message Tom Lane 2025-06-28 18:26:58 Re: BUG #18953: Planner fails to build plan for complex query with LATERAL references