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.96) (envelope-from ) id 1wu6Y4-000T90-1t for pgsql-admin@arkaria.postgresql.org; Wed, 12 Aug 2026 10:51:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wu6Y2-006tLv-0Q for pgsql-admin@arkaria.postgresql.org; Wed, 12 Aug 2026 10:51:03 +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.96) (envelope-from ) id 1wu6Y1-006tLn-2W for pgsql-admin@lists.postgresql.org; Wed, 12 Aug 2026 10:51:02 +0000 Received: from rs.plausibolo.de ([85.214.83.89] helo=plausibolo.de) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wu6Xz-00000000LCT-48oy for pgsql-admin@lists.postgresql.org; Wed, 12 Aug 2026 10:51:02 +0000 Received: from localhost (localhost [127.0.0.1]) by rs.plausibolo.de (Postfix) with ESMTP id 151913808B4; Wed, 12 Aug 2026 12:50:59 +0200 (CEST) Received: from plausibolo.de ([IPv6:::1]) by localhost (h2367442.stratoserver.net [IPv6:::1]) (amavis, port 10024) with ESMTP id RzZTI63Uln-E; Wed, 12 Aug 2026 12:50:58 +0200 (CEST) Received: from [192.168.178.88] (xdsl-89-0-250-129.nc.de [89.0.250.129]) by rs.plausibolo.de (Postfix) with ESMTPSA id 7DDF03802DC; Wed, 12 Aug 2026 12:50:58 +0200 (CEST) Content-Type: multipart/alternative; boundary="------------tuwnhboulLTZYH5yBZaW1IBV" Message-ID: Date: Wed, 12 Aug 2026 12:50:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-GB, de-DE To: PostgreSQL mailing list From: Holger Jakobs Subject: pg_upgrade from 17.10 to 18.4 on Ubuntu fails: Finding the real data directory for the target cluster sh: 1: (null)/postgres: not found Autocrypt: addr=holger@jakobs.com; keydata= xsDiBEG8IA8RBAC6WqUzEPTjest7MvFca5WlI47EgtKzOy1D1X9gSEmPj0sQrilNGEitY/+Q kPnCvI3odz1XXf/MZQtXwlxJA4lPmx8/K7MqBj9vh0J5jRznpE7l+SBDmmDobIqBAgl6BZvH 1C7e2y72h5T1/plrXonLUGzthqBtsvWl0ogoyTJqiwCg6AOhYX+Xbcl8/AXy4F4qbUq4LXsD /j6yCKRkyleN688y9YpuS5J6/ZZ/OBCM74pa2iNge3GmXn1JeUowF693QFCGHkpswmDIoGhL 5iM6GHj9HFB6rTXW5H3sR1y6ta7vXwoNBGkgiM89B1a/KsLT5L6MZgZ5AV0tj6vxwAsuLixS SDiNVNAd8vp2FfqdLlOgThsgVIwKBACsCzZa1VxpdoNSYnkTOSZhEjZkbWApdneQ2bTxXJgW +fWgVeLiojCp6I1AmQqzwHz8UN1nrsQjH8Rnxt2J/C5H/Ek9jlOFakFQXlPMZw3tNeTA1P3B 3zPyq6hKFPZHFklUquE3gHVjnX9qxSW0xvFirf6xAMCMYWRnCQHRgiXoAc0hSG9sZ2VyIEph a29icyA8aG9sZ2VyQGpha29icy5jb20+wnsEExECADsCGwMGCwkIBwMCAxUCAwMWAgECHgEC F4AWIQScuJCxWJK1p5BOebGKV5yTsxlhugUCaVdWsQUJMQE4HAAKCRCKV5yTsxlhureAAJ96 hJrXLiFGQJknuPn8vYEFTvQe4gCgjfc8YoZBMiEgbgibbp+9Ho93YZLOwE0EQbwgEBAEAKIa ShfwcoKhx0LBF0zNz2yIOzXDRg1rKFM+cr0iLfDPNLZH01LJaw9BXLHqGRV9KYroITlHN+4N TOtgSDJpX/a9PckP0aSj5G4WeN5C9WjyFzX1uYFKf3kBOSL6EXL/rwyqkyWwbtjIKW5FKleH arGWFuHYXNMhCaIRABHiQUITAAMFA/9nVjqfChfD/kmYsksVy9lmUV+fiD1OPIxLAfnT8Beo 4ClxzL0lLOhMVjzsi2YaSEPSqPXw8kFK3a6oBIauTb/nlcrn3pFaeh7Iv2bOPmvrCgOo81Fc hsrzl+gZUgxGtv8S5+BI4/kfpUfJu8E8PgKmkTDhDR9GwwJo5y+JuSMeisJmBBgRAgAmAhsM FiEEnLiQsViStaeQTnmxileck7MZYboFAmlXVsYFCTEBODYACgkQileck7MZYbomuQCgj9xe vI2QAGxQS+u27l+7zpHvUAEAoNL+6+cWX1zG3GfEk5j0nAmwPtyi List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------tuwnhboulLTZYH5yBZaW1IBV Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Dear Friends, Today a pg_upgrade failed with this awkward message: Finding the real data directory for the source cluster        ok Finding the real data directory for the target cluster        sh: 1: (null)/postgres: not found I checked the source code of pg_upgrade.c and thus options.c and found that the (null) above stems from an uninitialised variable called cmd, declared in line 433 of option.c Line 468 reads:     snprintf(cmd, sizeof(cmd), "\"%s/postgres\" -D \"%s\" -C data_directory",              cluster->bindir, cluster->pgconfig); Calling the postgres binary (from the package, didn't compile myself) works fine and gives me the correct real data directory:     $ /usr/lib/postgresql/18/bin/postgres -D /etc/postgresql/18/main -C data_directory     /var/lib/postgresql/18/main So how come that cmd is NULL in line 468? I actually cannot find where the variable was given any content, so it's NULL. This generates the error message with "(null)/postgres not found" Obviously, cmd should contain the path of the oldbin directory, which is to be derived from the path of the pg_upgrade being called. I didn't use the -B option because the documentation says that it's optional and will use the directory of pg_upgrade. https://www.postgresql.org/docs/current/pgupgrade.html tells me: |   -B| /|bindir|/ |   --new-bindir=|/|bindir |/         the new PostgreSQL executable directory; default is the directory where pg_upgrade resides Obviously, this doesn't work as described. When giving the path to the new bin directory with -B, pg_upgrade works fine. Please correct the code so that cmd gets initialised or alter the documentation making the option -B mandatory. Kind Regards, Holger -- Holger Jakobs, Bergisch Gladbach, Germany --------------tuwnhboulLTZYH5yBZaW1IBV Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Dear Friends,

Today a pg_upgrade failed with this awkward message:

Finding the real data directory for the source cluster        ok
Finding the real data directory for the target cluster        sh: 1: (null)/postgres: not found

I checked the source code of pg_upgrade.c and thus options.c and found that the (null) above stems from an uninitialised variable called cmd, declared in line 433 of option.c

Line 468 reads:

    snprintf(cmd, sizeof(cmd), "\"%s/postgres\" -D \"%s\" -C data_directory",
             cluster->bindir, cluster->pgconfig);

Calling the postgres binary (from the package, didn't compile myself) works fine and gives me the correct real data directory:

    $ /usr/lib/postgresql/18/bin/postgres -D /etc/postgresql/18/main -C data_directory
    /var/lib/postgresql/18/main

So how come that cmd is NULL in line 468? I actually cannot find where the variable was given any content, so it's NULL. This generates the error message with "(null)/postgres not found"

Obviously, cmd should contain the path of the oldbin directory, which is to be derived from the path of the pg_upgrade being called. I didn't use the -B option because the documentation says that it's optional and will use the directory of pg_upgrade.

https://www.postgresql.org/docs/current/pgupgrade.html tells me:
   -B bindir
   --new-bindir=bindir
         the new PostgreSQL executable directory; default is the directory where pg_upgrade resides

Obviously, this doesn't work as described.

When giving the path to the new bin directory with -B, pg_upgrade works fine.

Please correct the code so that cmd gets initialised or alter the documentation making the option -B mandatory.

Kind Regards,

Holger


--

Holger Jakobs, Bergisch Gladbach, Germany

--------------tuwnhboulLTZYH5yBZaW1IBV--