Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uVbIR-002SWs-1V for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Jun 2025 19:33:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uVbIN-009A5W-R6 for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Jun 2025 19:33:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uVbIN-009A5O-IQ for pgsql-bugs@lists.postgresql.org; Sat, 28 Jun 2025 19:33:04 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uVbIL-004cU6-12 for pgsql-bugs@lists.postgresql.org; Sat, 28 Jun 2025 19:33:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1751139179; bh=JYYifp+dFkKoG5C/4tFQoFhFTbRfqCQmDhKQVwD4DxU=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=x/Pf3930tEC45Tlz5PLSxr1wX4askjRon+IN+jISAfaN8vchlSsWI3JZEKZ/6sBT2 aPYVlmJS03YhGBvYWho1nGEL/IrvAQZXxG4hKLUaMzJ2dZUUNvT/nVkRcyDloJi3ja wAWs2pm4qUAuDrr7kO90rKZCxkkFyoWrh6FsXrym136AW58cfVVTuT900hVTJETfvW doB1o0s2hGiKPkmAoQqLngoPRrt6T/W5avH674OilL6QeyWWCi0LHbkYtWymSPs7HC X94d24giVZTPyY0uBrLoEzKHV+dHhojr8rz+DQNmhVPimTfXqjtlXvK/GXyKzwi22Q SQyxoHf8oPGGw== Received: from [172.30.48.6] (unknown [93.174.131.138]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: d.kovalenko@postgrespro.ru) by mail.postgrespro.ru (Postfix/465) with ESMTPSA id 757525FFF6; Sat, 28 Jun 2025 22:32:59 +0300 (MSK) Message-ID: Date: Sat, 28 Jun 2025 22:32:59 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18971: Server passes an invalid (indirect) path in PGDATA to the external program To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org References: <18971-53687392b125e4bf@postgresql.org> <2334360.1751138005@sss.pgh.pa.us> Content-Language: ru, en-US From: Dmitry Kovalenko In-Reply-To: <2334360.1751138005@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/06/28 18:43:00 #27599688 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Tom, > 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. A test executes pg_ctl with the correct path to cluster and the correct CWD. pg_ctl (and so on) executes an external program with inconsistent PGDATA and CWD. This is clearly a problem on your side ) I wonder that it was not detected earlier. For my point of view, if you can't provider a valid path in PGDATA, do not do it at all. With Best Regards, Dmitry Kovalenko