]> granicus.if.org Git - postgresql/commitdiff
Fix error message when a hostaddr cannot be parsed.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 19 Jul 2018 17:24:29 +0000 (20:24 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 19 Jul 2018 17:25:05 +0000 (20:25 +0300)
We were incorrectly passing hostname, not hostaddr, in the error message,
and because of that, you got:

$ psql 'hostaddr=foo'
psql: could not parse network address "(null)": Name or service not known

Backpatch to v10, where this was broken (by commit 7b02ba62e9).

Report and fix by Robert Haas.

Discussion: https://www.postgresql.org/message-id/CA+TgmoapFQA30NomGKEaZCu3iN7mF7fux8fbbk9SouVOT2JP7w@mail.gmail.com

src/interfaces/libpq/fe-connect.c

index 92e91c4895a40fbba553bab9cc5d2f6fe7254268..67033b75b7bf3a8db750110cb7fd6139ad8d7aae 100644 (file)
@@ -1744,7 +1744,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: