From: Denis Smirnov <darthunix@gmail.com>
To: Diego <mrstephenamell@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: [Proposal] add portaddr like hostaddr
Date: Wed, 26 Aug 2026 16:55:43 +0700
Message-ID: <63F7ADE6-DF8F-4261-9FEC-89A381E57E6A@gmail.com> (raw)
In-Reply-To: <1e3b609e-4cf7-4c39-8770-8248c8b81399@gmail.com>
References: <70436540-9d77-4014-89af-462881ed18d9@gmail.com>
<1e3b609e-4cf7-4c39-8770-8248c8b81399@gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: darthunix@gmail.com, mrstephenamell@gmail.com
Subject: Re: [Proposal] add portaddr like hostaddr
In-Reply-To: <63F7ADE6-DF8F-4261-9FEC-89A381E57E6A@gmail.com>
References: <70436540-9d77-4014-89af-462881ed18d9@gmail.com> <1e3b609e-4cf7-4c39-8770-8248c8b81399@gmail.com> <63F7ADE6-DF8F-4261-9FEC-89A381E57E6A@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox