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 1wznx3-004GQ2-20 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Aug 2026 04:12:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wznx2-005guz-1u for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Aug 2026 04:12:24 +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 1wznx2-005gur-0z for pgsql-hackers@lists.postgresql.org; Fri, 28 Aug 2026 04:12:24 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wznx0-00000002my5-2zxL for pgsql-hackers@lists.postgresql.org; Fri, 28 Aug 2026 04:12:23 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-39682983a0fso571921a91.3 for ; Thu, 27 Aug 2026 21:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787890342; x=1788495142; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=Vh7BXilf5vQVOZj66iWmqpZ2ShBE5Y0VsEJ8UMSL2WU=; b=nao0HyxqDfRrA3bElMGJhVPcEw6LOdwguLESf5EBOAJ2t2Ut3zGO03KsFbpfGfmFdC nfzGn4KYISF76GbQCmJiRo4gKO/WYACpS6dOl7TlvRar7VXJ0M0ckDYtG1gIRUJxYpI7 OixHDj+Dm4EETaeK/hyiAg5Qnh1/JljEdW8k/dgZojeMDCfRywgcSGS7vAjrQAfZ12sT IzPjLaVNsdkPlvT3TzBIsM519Wsl3cEBeZqYwLFHPLVUuOrNir09gVarWnK41qdXazxg MDHsi6c0uhTS2+P5rzzrnogMzmHekoOgIYjn9NXl0hWJUtznYloKgMJp9l+8Me0pYP7g l3Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787890342; x=1788495142; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Vh7BXilf5vQVOZj66iWmqpZ2ShBE5Y0VsEJ8UMSL2WU=; b=pKbjrYQc9MpWzlU9CwIphRoct2o58TzfbyqXZHbJjJfpNCfM1me+sSi8aXYLalRols Y5jgmZqP4mHnmiwI/ciefkI21QvA237hNHWWKOtW9fnXdRdUCQA3b3vklxySVkkWCI8+ yCpvas7ZkWBS98P0bcIE5qirl4qhsZBXIKKU+vfvByUVNibB86i3ZmK7rMckfacZhD1m yCQQ7ndxSy3/x/PSgaZ3azV/EuLBj1hkNGJOrL7D2jN4NNeTJmmlwUUejvECBRWJW3ew /VlsFqb0LSBsBaRvnV97fSGE2k+viJk+huGOkue2mDORU3Z0uDhEsFm5iCIG50Pxy9we /ISw== X-Gm-Message-State: AFuF++lH48re4xG28KvvqCxseH5BVtV+4BwbKwRhD//lFomdHeBihrat +/YvFo3OVmmCUIVYpqVOVnmzvfWSepcWwtFnprZgLa+MDv1IKLNxnd+J X-Gm-Gg: AR+sD137LII1Hefo4Lw8GE+FrE1DYylfH6X7BC1u581+kqRXowhH+x7zbKOmFfplI0m giwtqsb3VXR14JqXuo1vIc/gNa6QANz5LtSxJAwmAkvz5kqy+WZOSkHhqtp0TRzLJ75fRS1JhaL KGxtPWFsYLW/5Rz3d9a7dNZvYImcTBy/US7MJRMrUW4EbWTyhhltY7Zy7H6xu89gKTFMUEprOXV bFXRlLP7FlKObO46dsuj4M+pABoNnpaMCIHTUEOIYHzZks4nhTfRYDPru8p8VeV9A1vcMJtdfJ3 sKYmmFalAE8xAi3FyItVWBXQX+EqrjPRhcs0kFue0pS4hyDaajeqQndXqWny2OM6t1aPOHL24BC qu3Xvz0AV+AAZFhpQcLfDHsKaY3AuUlleNEs89ZzmR9ymeMC7Lqy6z9UVXU/ZjKo1Xxub1M/P33 qrt7z3mICep2kA5X+An51Hwlw8WauHN8yTwIkKt13/yhdBbNeYbOCpXVOb+fnl9d6sjeQEx4e0W 4PUiMvZf4KU9vVOQ9c4Q2I9oQy5CuswiEVv97BGd3Cm47m7 X-Received: by 2002:a17:90b:530c:b0:381:1c96:829b with SMTP id 98e67ed59e1d1-396d0d4c43amr8723269a91.3.1787890341732; Thu, 27 Aug 2026 21:12:21 -0700 (PDT) Received: from smtpclient.apple (mx-ll-171.5.165-154.dynamic.3bb.co.th. [171.5.165.154]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-396db196903sm816854a91.0.2026.08.27.21.12.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2026 21:12:20 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [Proposal] add portaddr like hostaddr From: Denis Smirnov In-Reply-To: <636a2d5b-adaf-45d7-a255-870682a8cc73@gmail.com> Date: Fri, 28 Aug 2026 11:12:07 +0700 Cc: pgsql-hackers@lists.postgresql.org Content-Transfer-Encoding: 7bit Message-Id: <8067FAF9-B462-4BB1-84A1-DF3D302A7672@gmail.com> 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> <636a2d5b-adaf-45d7-a255-870682a8cc73@gmail.com> To: Diego 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 Hi Diego, > hostaddr is the first hop, the only thing libpq dials, and host is > who the user says is at the end of it. That is not the libpq model. libpq describes an OS socket endpoint and, when required, a server name. For TCP, hostaddr is the numeric destination address and port is the destination port. When hostaddr is absent, host is resolved through DNS. When both are present, host is retained for TLS and GSSAPI. host is therefore a name used for address resolution and authentication, not a general identity at the end of an arbitrary route. Its use as a .pgpass lookup key does not change that model. > The patch does not expose two endpoints: it exposes one endpoint and > one identity. By two endpoints I meant the two sides of the forwarding mapping created by pgcli: the local listener and the remote database target. The socket endpoint used by libpq is already complete: 127.0.0.1:39907 The remote target: db.example.com:5432 belongs to the SSH forwarding configuration owned by pgcli. portaddr would combine the address from the local endpoint with the port from the remote endpoint. It does not complete one endpoint. > What remains is the case where no port can be written in advance, > because it does not exist yet. The port exists before pgcli calls libpq. The current pgcli code starts the SSH tunnel, reads local_bind_ports[0], and then passes that port to PGExecute. libpq is never asked to connect without a known port. pgcli creates the tunnel and owns both sides of the mapping. Once the tunnel is started, pgcli knows the selected local port. It therefore has all the information needed to construct consistent SSH forwarding and libpq configuration: SSH maps the local endpoint to the remote database, while libpq and .pgpass use that local endpoint. How pgcli stores or generates this mapping is a pgcli implementation detail. It does not require libpq to introduce a second port. Best regards, Denis Smirnov