Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aNQkg-0002AG-Ct for pgsql-hackers@arkaria.postgresql.org; Sun, 24 Jan 2016 19:55:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aNQkf-0007uC-PI for pgsql-hackers@arkaria.postgresql.org; Sun, 24 Jan 2016 19:55:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aNQjM-0006QV-64 for pgsql-hackers@postgresql.org; Sun, 24 Jan 2016 19:53:48 +0000 Received: from wagner.pp.ru ([178.63.209.18] helo=mx.wagner.pp.ru) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aNQjJ-0004ic-LL for pgsql-hackers@postgresql.org; Sun, 24 Jan 2016 19:53:47 +0000 Received: from mail.wagner.pp.ru (unknown [192.168.217.2]) by mx.wagner.pp.ru (Postfix) with ESMTP id 49301486161; Sun, 24 Jan 2016 22:53:45 +0300 (MSK) Received: from wagner.wagner.home (wagner.wagner.home [192.168.217.1]) by mail.wagner.pp.ru (Postfix) with ESMTPSA id 9F6122001A; Sun, 24 Jan 2016 22:53:34 +0300 (MSK) Date: Sun, 24 Jan 2016 22:53:51 +0300 From: Victor Wagner To: PostgreSQL-development Cc: Thom Brown Subject: Re: Patch: Implement failover on libpq connect level. Message-ID: <20160124225351.5dd2837f@wagner.wagner.home> In-Reply-To: References: <20150818041850.GA5092@wagner.pp.ru> <56379A44.9080609@gmx.net> <20151105151235.GA21434@wagner.pp.ru> <20151106153807.GA6104@alvherre.pgsql> <20151109124404.1af6ba0c@fafnir> <5665EB79.9070805@enterprisedb.com> <20151210075419.6c9b7ca4@wagnner.wagner.home> <56780A3D.2090609@sigaev.ru> <20151221175013.644535cd@fafnir.local.vm> <20160122223051.1c7b22f6@wagner.wagner.home> X-Mailer: Claws Mail 3.13.0 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Sun, 24 Jan 2016 15:58:10 +0000 Thom Brown wrote: > > Output of \set variables without patch: > > HOST = '127.0.0.1' > PORT = > '5530,127.0.0.1:5531,127.0.0.1:5532,127.0.0.1:5533,127.0.0.1:5534,127.0.0.1:5535' > > And with patch: > > HOST = > '127.0.0.1:5530,127.0.0.1:5531,127.0.0.1:5532,127.0.0.1:5533,127.0.0.1:5534,127.0.0.1:5535' > PORT = '5488' > > They're both wrong, but I'm hoping we can just show the right > information here. I think we should show right information here, but it is not so simple. Problem is that I never keep symbolic representation of individual host/port pair. And when we connect successfully, we have only struct sockaddr representation of the it, which contain right IP address, but doesn't contain symbolic host name. Moreover, one hostname from connect string can produce more than one addrinfo structures. For example, on the machines with IPv6 support, 'localhost' hostname is resolved into both 127.0.0.1 IPv4 address and [::1] IPv6, and produces two records. So would do any name, which have both A and AAAA records in DNS. And nothing prevent domain administrator to put more than one A record for same hostname into DNS zone. So, it is just same information which can be retrieved from the backend via select inet_client_addr(); select inet_client_port(); What is really interesting for HOST and PORT variable - it is the name of host and port number used to make actual connection, as they were specified in the connect string or service file. > > Thom -- Victor Wagner -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers