pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Give a better error message on invalid hostaddr option.
4+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2018-07-19 b90d97e081 dc961e5822 ff4fb4cc1b  Fix error message when a hostaddr cannot be parsed.
* pgsql: Give a better error message on invalid hostaddr option.
@ 2017-06-09 10:06  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 1 reply; 4+ messages in thread

From: Heikki Linnakangas @ 2017-06-09 10:06 UTC (permalink / raw)
  To: pgsql-committers

Give a better error message on invalid hostaddr option.

If you accidentally pass a host name in the hostaddr option, e.g.
hostaddr=localhost, you get an error like:

psql: could not translate host name "localhost" to address: Name or service not known

That's a bit confusing, because it implies that we tried to look up
"localhost" in DNS, but it failed. To make it more clear that we tried to
parse "localhost" as a numeric network address, change the message to:

psql: could not parse network address "localhost": Name or service not known

Discussion: https://www.postgresql.org/message-id/10badbc6-4d5a-a769-623a-f7ada43e14dd@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/76b11e8a43eca4612dfccfe7f3ebd293fb8a46ec

Modified Files
--------------
src/interfaces/libpq/fe-connect.c | 41 +++++++++++++++++++++++++--------------
1 file changed, 26 insertions(+), 15 deletions(-)


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


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [COMMITTERS] pgsql: Give a better error message on invalid hostaddr option.
@ 2018-07-19 14:07  Robert Haas <robertmhaas@gmail.com>
  parent: Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 1 reply; 4+ messages in thread

From: Robert Haas @ 2018-07-19 14:07 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

On Fri, Jun 9, 2017 at 6:06 AM, Heikki Linnakangas
<heikki.linnakangas@iki.fi> wrote:
> Give a better error message on invalid hostaddr option.
>
> If you accidentally pass a host name in the hostaddr option, e.g.
> hostaddr=localhost, you get an error like:
>
> psql: could not translate host name "localhost" to address: Name or service not known
>
> That's a bit confusing, because it implies that we tried to look up
> "localhost" in DNS, but it failed. To make it more clear that we tried to
> parse "localhost" as a numeric network address, change the message to:
>
> psql: could not parse network address "localhost": Name or service not known

This commit doesn't seem to deliver the behavior described in the
commit message.  Instead, I get:

[rhaas pgsql]$ psql 'hostaddr=localhost'
psql: could not parse network address "(null)": nodename nor servname
provided, or not known

Proposed patch attached.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachments:

fix-could-not-parse-messsage-v1.patch (application/octet-stream, 529B) download diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index a7e969d7c1..bd7dac120d 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -1751,7 +1751,7 @@ connectDBStart(PGconn *conn) if (ret || !ch->addrlist) appendPQExpBuffer(&conn->errorMessage, libpq_gettext("could not parse network address \"%s\": %s\n"), - ch->host, gai_strerror(ret)); + ch->hostaddr, gai_strerror(ret)); break; case CHT_UNIX_SOCKET:
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: [COMMITTERS] pgsql: Give a better error message on invalid hostaddr option.
@ 2018-07-19 17:28  Heikki Linnakangas <hlinnaka@iki.fi>
  parent: Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Heikki Linnakangas @ 2018-07-19 17:28 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

On 19/07/18 17:07, Robert Haas wrote:
> On Fri, Jun 9, 2017 at 6:06 AM, Heikki Linnakangas
> <heikki.linnakangas@iki.fi> wrote:
>> Give a better error message on invalid hostaddr option.
>>
>> If you accidentally pass a host name in the hostaddr option, e.g.
>> hostaddr=localhost, you get an error like:
>>
>> psql: could not translate host name "localhost" to address: Name or service not known
>>
>> That's a bit confusing, because it implies that we tried to look up
>> "localhost" in DNS, but it failed. To make it more clear that we tried to
>> parse "localhost" as a numeric network address, change the message to:
>>
>> psql: could not parse network address "localhost": Name or service not known
> 
> This commit doesn't seem to deliver the behavior described in the
> commit message.  Instead, I get:
> 
> [rhaas pgsql]$ psql 'hostaddr=localhost'
> psql: could not parse network address "(null)": nodename nor servname
> provided, or not known
> 
> Proposed patch attached.

Seems that I broke this shortly afterwards, by commit 7b02ba62e9. 
Pushed, thanks!

- Heikki




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [COMMITTERS] pgsql: Give a better error message on invalid hostaddr option.
@ 2018-07-19 17:36  Robert Haas <robertmhaas@gmail.com>
  parent: Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 0 replies; 4+ messages in thread

From: Robert Haas @ 2018-07-19 17:36 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Heikki Linnakangas <heikki.linnakangas@iki.fi>; pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>

On Thu, Jul 19, 2018 at 1:28 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> Seems that I broke this shortly afterwards, by commit 7b02ba62e9. Pushed,
> thanks!

Oh, OK.  Thanks!

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2018-07-19 17:36 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-06-09 10:06 pgsql: Give a better error message on invalid hostaddr option. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2018-07-19 14:07 ` Robert Haas <robertmhaas@gmail.com>
2018-07-19 17:28   ` Heikki Linnakangas <hlinnaka@iki.fi>
2018-07-19 17:36     ` Robert Haas <robertmhaas@gmail.com>

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