pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Victor Wagner <vitus@wagner.pp.ru>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Thom Brown <thom@linux.com>
Subject: Re: Patch: Implement failover on libpq connect level.
Date: Sun, 24 Jan 2016 22:53:51 +0300
Message-ID: <20160124225351.5dd2837f@wagner.wagner.home> (raw)
In-Reply-To: <CAA-aLv6=fivY55BfKkcUYaS0AUA1TzYWWdZNtggw+tcvFbfqRA@mail.gmail.com>
References: <20150818041850.GA5092@wagner.pp.ru>
	<56379A44.9080609@gmx.net>
	<20151105151235.GA21434@wagner.pp.ru>
	<CA+TgmoYKvGsZGJB-cKU=xhHnq=b6XOM=qbseVC72HwH2+p5+TA@mail.gmail.com>
	<CAMsr+YGXTK3+i5zL3AkkR5BRP+Tw+f4+Ph=Z2_g7KD-nbb+cYg@mail.gmail.com>
	<20151106153807.GA6104@alvherre.pgsql>
	<CA+TgmoYYUeojjos=7ZT6Emkmri1f4n753tx9v7jEU-y28_8zOw@mail.gmail.com>
	<CAMsr+YHr740oGcVQcuyvLt1bwBPLQtpm5U-O+tTEFifBgHWdzw@mail.gmail.com>
	<20151109124404.1af6ba0c@fafnir>
	<5665EB79.9070805@enterprisedb.com>
	<20151210075419.6c9b7ca4@wagnner.wagner.home>
	<56780A3D.2090609@sigaev.ru>
	<20151221175013.644535cd@fafnir.local.vm>
	<CAA-aLv4ddFHXA0BHZz-dLXJJNVfhj8JURDm77izZCO8UaM1oVg@mail.gmail.com>
	<20160122223051.1c7b22f6@wagner.wagner.home>
	<CAA-aLv7KGGgoSU+fa8NNisL11DKrs-BGh8qwNQjFZ1NuDC+Yxw@mail.gmail.com>
	<CAA-aLv4hrQEWfc2eV6t-3wCe_VNk+jLdVYJAPXaHKFko0UMdgw@mail.gmail.com>
	<CAA-aLv6=fivY55BfKkcUYaS0AUA1TzYWWdZNtggw+tcvFbfqRA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On Sun, 24 Jan 2016 15:58:10 +0000
Thom Brown <thom@linux.com> 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 <vitus@wagner.pp.ru>


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (165+ messages)  latest in thread

Message-ID: <20160124225351.5dd2837f@wagner.wagner.home>
Permalink:  ../20160124225351.5dd2837f@wagner.wagner.home/
Also on:    postgresql.org/message-id/20160124225351.5dd2837f@wagner.wagner.home

 · 

reply

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-jdbc@postgresql.org
  Cc: vitus@wagner.pp.ru, pgsql-hackers@postgresql.org, thom@linux.com
  Subject: Re: Patch: Implement failover on libpq connect level.
  In-Reply-To: <20160124225351.5dd2837f@wagner.wagner.home>
  References: <20150818041850.GA5092@wagner.pp.ru> <56379A44.9080609@gmx.net> <20151105151235.GA21434@wagner.pp.ru> <CA+TgmoYKvGsZGJB-cKU=xhHnq=b6XOM=qbseVC72HwH2+p5+TA@mail.gmail.com> <CAMsr+YGXTK3+i5zL3AkkR5BRP+Tw+f4+Ph=Z2_g7KD-nbb+cYg@mail.gmail.com> <20151106153807.GA6104@alvherre.pgsql> <CA+TgmoYYUeojjos=7ZT6Emkmri1f4n753tx9v7jEU-y28_8zOw@mail.gmail.com> <CAMsr+YHr740oGcVQcuyvLt1bwBPLQtpm5U-O+tTEFifBgHWdzw@mail.gmail.com> <20151109124404.1af6ba0c@fafnir> <5665EB79.9070805@enterprisedb.com> <20151210075419.6c9b7ca4@wagnner.wagner.home> <56780A3D.2090609@sigaev.ru> <20151221175013.644535cd@fafnir.local.vm> <CAA-aLv4ddFHXA0BHZz-dLXJJNVfhj8JURDm77izZCO8UaM1oVg@mail.gmail.com> <20160122223051.1c7b22f6@wagner.wagner.home> <CAA-aLv7KGGgoSU+fa8NNisL11DKrs-BGh8qwNQjFZ1NuDC+Yxw@mail.gmail.com> <CAA-aLv4hrQEWfc2eV6t-3wCe_VNk+jLdVYJAPXaHKFko0UMdgw@mail.gmail.com> <CAA-aLv6=fivY55BfKkcUYaS0AUA1TzYWWdZNtggw+tcvFbfqRA@mail.gmail.com> <20160124225351.5dd2837f@wagner.wagner.home>

* 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