From: | Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com> |
Subject: | Re: fix psql \conninfo & \connect when using hostaddr |
Date: | 2018-11-07 14:11:39 |
Message-ID: | 4414f348-4482-2bcb-dc93-9c3d073f2431@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello all,
On 07.11.2018 16:23, Pavel Stehule wrote:
> pá 26. 10. 2018 v 15:55 odesílatel Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr
> <mailto:coelho(at)cri(dot)ensmp(dot)fr>> napsal:
> >
> > This is a follow-up to another patch I posted about libpq confusing
> > documentation & psql resulting behavior under host/hostaddr settings.
> >
> > Although the first mostly documentation patch did not gather much
> > enthousiasm, I still think both issues deserve a fix.
>
> I checked this patch, and it looks well. The documentation is correct,
> all tests passed. It does what is proposed.
>
> I think so some redundant messages can be reduced - see function
> printConnInfo - attached patch
I have few notes about patches.
> /* If the host is an absolute path, the connection is via socket unless overriden by hostaddr */
> if (is_absolute_path(host))
> if (hostaddr && *hostaddr)
> printf(_("You are connected to database \"%s\" as user \"%s\" on address \"%s\" at port \"%s\".\n"),
> db, PQuser(pset.db), hostaddr, PQport(pset.db));
> else
> printf(_("You are connected to database \"%s\" as user \"%s\" via socket in \"%s\" at port \"%s\".\n"),
> db, PQuser(pset.db), host, PQport(pset.db));
> else
> if (hostaddr && *hostaddr && strcmp(host, hostaddr) != 0)
> printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" (address \"%s\") at port \"%s\".\n"),
> db, PQuser(pset.db), host, hostaddr, PQport(pset.db));
> else
> printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" at port \"%s\".\n"),
> db, PQuser(pset.db), host, PQport(pset.db));
I think there is lack of necessary braces here for first if and second
else branches. This is true for both patches.
> /* set connip */
> if (conn->connip != NULL)
> {
> free(conn->connip);
> conn->connip = NULL;
> }
>
> {
> char host_addr[NI_MAXHOST];
> getHostaddr(conn, host_addr);
> if (strcmp(host_addr, "???") != 0)
> conn->connip = strdup(host_addr);
> }
Maybe it is better to move this code into the PQhostaddr() function?
Since connip is used only in PQhostaddr() it might be not worth to do
additional work in main PQconnectPoll().
--
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-11-07 14:25:31 | Re: plruby: rb_iterate symbol clash with libruby.so |
Previous Message | Tomas Vondra | 2018-11-07 14:11:04 | Re: valgrind on initdb |