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 1wzAMU-003qn2-2E for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Aug 2026 09:56:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wzAMS-00CL2e-2G for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Aug 2026 09:56:00 +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 1wzAMS-00CL2L-0r for pgsql-hackers@lists.postgresql.org; Wed, 26 Aug 2026 09:56:00 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wzAMQ-00000002UXW-2K0c for pgsql-hackers@lists.postgresql.org; Wed, 26 Aug 2026 09:55:59 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2d6af66ca14so9181465ad.1 for ; Wed, 26 Aug 2026 02:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787738157; x=1788342957; darn=lists.postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:content-type :message-id:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=GPfajrvQjnZNInw0sg1ASvwSYnHcH8LLfZlvRJnAAbs=; b=Y1ujdc0udZQ7wBTU1bo3IYCXuQNTr+Z15ttgaxvta8svk0kuUg0twllDnbOmpQtwED rYXFhl6YzCvSE9nHQ0dIwU48W1P2smKFY/VJGUTQvFl772QwzmUvyW+jnEt2C1aNN8n8 Pgl76DDqqvUQ5VVkR4ovmR2a3gehwXzl2X0qrzruBdRdtJo3czDlScLGGOITXVVqI4Am YaCvMe5cs0twZ0ikGCC2/GXeAmxMFbaUgptgYulWp2hi6WZ4fDc3HmihhidDldt0GzPN RrVxANulppspUEpXJMfp6NHV44BOeBvCs0kpHvpDgiBOKZ2VDnSfg/BYbljKUYqDIJdw Y4DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787738157; x=1788342957; h=references:to:cc:in-reply-to:date:subject:mime-version:content-type :message-id:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GPfajrvQjnZNInw0sg1ASvwSYnHcH8LLfZlvRJnAAbs=; b=M7vh40UpeLhSPaPmagaXgYcmozPX5LO6k4tEaAG3mrtWwCMCw6/WUs68NvwbO4K2OC 7U2SNbyzdDj5UPb+50raQGNfEwfovd77UvBZl+WX5p3NoNJXcgyYQjHHPaSd6mf3OwnO pO6KxbpW9Ktrh06gVjCTdH4pdT32RzF6CNsktbvaBpf3/pxZu8VKXR1SOTq9+f73wXBv 4CoyK+uMomZrRerJWx7O68K6KluiJ0izpTh0HiMVD+Aj1LgoknZ4cbz6EIi5uWR9dV+o y4TIKHo9ubOKHZspTnOYnisFv+0MITZhb65tX24GsnlpRQ0+HR9yNVyqOhZJQbByOyFb JsGw== X-Gm-Message-State: AFuF++lJIj3jSo40TjVtH3maeGaKzILKotTWgrktAAy4/GkHG5H327yc gA+ON0xrSvwfhTU5WBxZNmfexHXH9lDl22SiyifsaDBRq8DubAL3210G X-Gm-Gg: AR+sD11g4jA7hRl67oyv8lDTd8IXSpeffLg0G3qrl2c5YZCRxzJKpJzMXXcRBLHTmw0 7AAj4w8faCyTzE3UyHilwPZf75ys4FRAg6izNmdvJjSpADrbS0ac6Y0LB2SZGqKUFXYTdzhmaJY PeZMawQJTS06lEfNh9PTeoRkGEU+VHyJx0xFGRcgGM59QbjzGufnmv3zBqReV+LIjiDk9N9Yl0n F7n9ljh2xC8bB0ZBVOcr6CBWSGd8nz+t5S0RwTznFG96EBRx+kDPPR/9KSTyMCLSDJen0t39sAD JHLPaHbO71Jm4VeYoPN2siM0nanJ8u6gdPdhuxk1b+ZOSlRYvQe6HOwUfkOH4PLNzIj7Lu0IJ8Y EuFBN/I80rtPq4psCur7w7R4ZPstpoP6Umm2kwNxsVMknIMY/S3KWImk1E0BpmqDSmgWCwdPrXU 32WaXV70/iI+pJ5e+xsHlDjYC8bJvn0paUxO0eZhhyoI8CvwwCrTsRPPc0rVxWw9d57At/uM3Xp NvA5JMTXSd/Yxt+9x3OQvKii4mpkyJ7S9g9Y0wN/Kw= X-Received: by 2002:a17:902:d581:b0:2d1:134:b86e with SMTP id d9443c01a7336-2d707a0190cmr103323485ad.2.1787738157145; Wed, 26 Aug 2026 02:55:57 -0700 (PDT) Received: from smtpclient.apple (mx-ll-171.5.24-13.dynamic.3bb.co.th. [171.5.24.13]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d70498ca3csm5694925ad.31.2026.08.26.02.55.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2026 02:55:56 -0700 (PDT) From: Denis Smirnov Message-Id: <63F7ADE6-DF8F-4261-9FEC-89A381E57E6A@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_025E9127-74A4-42B1-8707-D35E8CABA752" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [Proposal] add portaddr like hostaddr Date: Wed, 26 Aug 2026 16:55:43 +0700 In-Reply-To: <1e3b609e-4cf7-4c39-8770-8248c8b81399@gmail.com> Cc: pgsql-hackers@lists.postgresql.org To: Diego References: <70436540-9d77-4014-89af-462881ed18d9@gmail.com> <1e3b609e-4cf7-4c39-8770-8248c8b81399@gmail.com> X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_025E9127-74A4-42B1-8707-D35E8CABA752 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Hi, I do not think portaddr should be added to libpq. Context ------- The main use case comes from pgcli: * pgcli opens an SSH tunnel on a random local port; * it replaces the original database port with that local port; * the existing .pgpass entry no longer matches; * portaddr is proposed so that libpq connects to the local port but searches .pgpass using the original port. Why this should not be in libpq ------------------------------- 1. This is a client-side problem. The two ports exist only because pgcli created the tunnel. PostgreSQL does not know about the local port. A normal libpq connection has one host and one port. 2. hostaddr is not a good model for this. host and hostaddr are a host name and its numeric network address. This distinction is needed for DNS, GSSAPI, and TLS. Ports do not have names and addresses. port and portaddr would be two different ports with different purposes: * port would identify an entry in .pgpass; * portaddr would be the port used for the connection. This gives a new and unclear meaning to port. 3. The change is much larger than the use case. It adds a new libpq parameter, environment variable, public function, and special handling in psql, pg_isready, pg_upgrade, and tests. Also, the DBeaver example does not show a need in libpq because DBeaver uses pgJDBC. What should happen instead -------------------------- The client that creates the tunnel should also manage the mapping between: * the original database endpoint; and * the local tunnel endpoint. It should handle the password lookup itself, use a tunnel-specific passfile, or manage its local ports in another way. A pgcli implementation detail should not become a new public libpq connection concept. Best regards, Denis Smirnov --Apple-Mail=_025E9127-74A4-42B1-8707-D35E8CABA752 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Hi,

I do = not think portaddr should be added to = libpq.

Context
-------

The main use case comes from pgcli:

* = pgcli opens an SSH tunnel on a random local port;
* it = replaces the original database port with that local port;
* = the existing .pgpass entry no longer matches;
* portaddr is = proposed so that libpq connects to the local port but
  = searches .pgpass using the original port.

Why = this should not be in = libpq
-------------------------------

1= . This is a client-side problem.

  =  The two ports exist only because pgcli created the tunnel. = PostgreSQL
   does not know about the local port. A = normal libpq connection has one
   host and one = port.

2. hostaddr is not a good model for = this.

   host and hostaddr are a host = name and its numeric network address.
   This = distinction is needed for DNS, GSSAPI, and = TLS.

   Ports do not have names and = addresses. port and portaddr would be two
  =  different ports with different = purposes:

   * port would identify an = entry in .pgpass;
   * portaddr would be the port = used for the connection.

   This = gives a new and unclear meaning to port.

3. The = change is much larger than the use case.

  =  It adds a new libpq parameter, environment variable, public = function,
   and special handling in psql, = pg_isready, pg_upgrade, and tests.

  =  Also, the DBeaver example does not show a need in libpq = because
   DBeaver uses = pgJDBC.

What should happen = instead
--------------------------

The = client that creates the tunnel should also manage the mapping = between:

* the original database endpoint; = and
* the local tunnel endpoint.

It = should handle the password lookup itself, use a = tunnel-specific
passfile, or manage its local ports in another = way.

A pgcli implementation detail should not = become a new public libpq
connection = concept.


Best regards,
Denis = Smirnov

= --Apple-Mail=_025E9127-74A4-42B1-8707-D35E8CABA752--