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 1wzegO-0049Dw-0t for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Aug 2026 18:18:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wzegN-003sCk-0v for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Aug 2026 18:18:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wzegM-003sCb-3D for pgsql-hackers@lists.postgresql.org; Thu, 27 Aug 2026 18:18:34 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wzegL-00000002j08-1Ugt for pgsql-hackers@lists.postgresql.org; Thu, 27 Aug 2026 18:18:34 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2d710632717so1583415ad.0 for ; Thu, 27 Aug 2026 11:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787854712; x=1788459512; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=a3bV4UGpRft2Hz/PuZmh0eQ9JrljqZBzEaijgX+7vq4=; b=Oai9P7QMROsHHirs9KRYwcGEnbwqlHlDlDXWGHxIW95H0vN+sLHoZuupKGu2lxqEEM /0bk4pQvp7jZcnYtKIumX0o7sgmoAcViX2+lgQWjK4LcY6NtMQDk3965KUH56HA1kTEo sU8dGkMCRvb3X1at8M0PBX+4cx/EeZhbpltaUdNZ/8qYYvm1eaSjrwMduBf/ANYopLKD VJAQNIwmLiavBaEaVKOw65V3l3LAaKXxelYXOj5J1i1GhnoQzNagoBwulAopH+Obmxqh AJCOG8NQT2MjyeyCs760Xy0sEc7GOzu7jAplnWGUqTJY7o/qGG/S8Ub0AIaQ8Sohh+8J 85BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787854712; x=1788459512; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=a3bV4UGpRft2Hz/PuZmh0eQ9JrljqZBzEaijgX+7vq4=; b=kFlVJvSTuYBncMpTD8IRQt1O9IL8ZXr8AtmbwXcxzk/DTYeiiXk/m6YoDnT9Di9JnM Opr6Z0+ej38TX89s3QpQSvIVwHYmVmGBZPFK6IyGhOp/jTkevBLeyLzYxPDJdeiKL5BL Va0vSDjaj1meSPAFUCbYAXHTub86TN+7VGAs5iK5jfbvSYHOEsccuz5ID3yYCzyoeRvz +/OcMcmZBrfEjdhJ+TgV/eTLjwGkdDRJ4iyjWORINJ9FHg31ICkVsS71Vj5rR0Zt8GN6 a9+WNuRj7fPPS2Xze2yXLf9ffeWRYFKakyeqn8A/1OARow3DfC1QDDnIfq5lenwKxOye qBAg== X-Gm-Message-State: AFuF++ndovXfwB+rtiCTU6MHbEshsPPBPDNeS+K1TO14RIUeG72PL/BC 1mtvBpJ98xz0fyrl/jYfjgVFdRQCTvg1fIZ46tuD9fRrlp6l4s8eFcCq X-Gm-Gg: AR+sD13980iNGwoSEISHxcFdAQ3bNj7ilGzd6W13d7EIrbeT766KUhc50RCM6fcjEA7 MViPPZ7Ai6dx76Th7Wdf+DEDKXBbx3tTx26ZMQQDyqR4c2S4BQ2bX5Riphalr4rCR4d0MnIn/Hc BUh8HepG2booIEh3ygG4bfigtC6upHTwLLMaItAYR0jX2YovkGx+v6SB67GyI0i0hk1z2zuoLTA 15fEaKCL2QYX7N6+A4E88d2V1MEa3tUHjzpqbOidUdevEScY07TOKQFnG7WsADpAnGTIruOWM4o T/BIGoTt+VD8IN2H8w9Y5dquY40Y5NU0PeFAoqUB8rKmMBbPdfHP45s+Hx60R3siuW3aFLqoTSl usyRGhPZhJLWRsPRf1Zg3xP8ZEPFlFIf5X1CMQGJE8ZS11E1N0jwJzvgJQ8qI4DM6W6EcEw24UJ hTAYFspgxFOAFsWSm86os/86GqYL4of0+Q594ZV0meD7fjnHMmJ0cZxfntZK00oAFbWmNnPQ2kC e+cg/E1 X-Received: by 2002:a17:903:1a26:b0:2d5:c099:16e2 with SMTP id d9443c01a7336-2d74e070456mr14954455ad.13.1787854712231; Thu, 27 Aug 2026 11:18:32 -0700 (PDT) Received: from [192.168.88.177] ([186.132.9.240]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3283d63bb23sm22123345eec.7.2026.08.27.11.18.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Aug 2026 11:18:30 -0700 (PDT) Message-ID: <636a2d5b-adaf-45d7-a255-870682a8cc73@gmail.com> Date: Thu, 27 Aug 2026 15:18:28 -0300 MIME-Version: 1.0 User-Agent: Betterbird (Linux) Subject: Re: [Proposal] add portaddr like hostaddr To: Denis Smirnov Cc: pgsql-hackers@lists.postgresql.org References: <70436540-9d77-4014-89af-462881ed18d9@gmail.com> <1e3b609e-4cf7-4c39-8770-8248c8b81399@gmail.com> <63F7ADE6-DF8F-4261-9FEC-89A381E57E6A@gmail.com> <71685CE0-477D-4E4B-ADFE-D3CC3873512C@gmail.com> Content-Language: en-US From: Diego In-Reply-To: <71685CE0-477D-4E4B-ADFE-D3CC3873512C@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-08-27 00:49, Denis Smirnov wrote: Hi Denis! Thank you, and thank you for conceding the client-side point. > It is not clear why libpq should expose exactly two endpoints. Which > port is the "server port" here: 39907, 6432, or 5432? Only 39907 is > visible to libpq. The same question, asked about the other coordinate, already has an answer in libpq. In your chain: libpq -> localhost:39907 -> SSH jump1 -> SSH jump2 -> PgBouncer:6432 -> PostgreSQL:5432 which one is the host? Only localhost is visible to libpq, and yet "host=db.example.com hostaddr=127.0.0.1" is supported, documented, and used in production today -- pgAdmin does exactly this for its tunnels. libpq does not model the route there either: hostaddr is the first hop, the only thing libpq dials, and host is who the user says is at the end of it. Everything in between has always been invisible, and nothing in the patch changes that. So portaddr adds no knowledge of the route. It completes the address of that same first hop. The patch does not expose two endpoints: it exposes one endpoint and one identity, which is what host and hostaddr already are. And "which port is the server port" is answered the same way as "which host": by the user, explicitly, or not at all. If you authenticate against PgBouncer, the credential is PgBouncer's and port is 6432; if the tunnel ends at PostgreSQL, it is 5432. libpq never guesses. Your example is in fact where today's workaround breaks: with PgBouncer on 6432 and PostgreSQL on 5432 on one host, the wildcard entry that a tunnel forces you to write, host:*:..., collapses both into whichever line comes first. > port and PQport() should continue to mean the port to which libpq > actually connects. PQhost() already does not mean the host to which libpq actually connects: with hostaddr it returns the host verbatim, and PQhostaddr() returns the address. Keeping port as the exception is the part that needs justification. > SSH forwarding should be configured by SSH itself, for example with > ProxyJump and LocalForward in ~/.ssh/config. Agreed for the chain itself. But LocalForward takes an explicit [bind_address:]port, so that configuration means a fixed local port, which is exactly the case I already granted Christoph: write it into .pgpass and you need no patch. (ProxyJump is not something libpq can use on its own; libpq calls connect() on a socket and never invokes ssh.) What remains is the case where no port can be written in advance, because it does not exist yet. I would like to hear other opinions on the model. Thank you, BR, Diego