Improve error message when connect() call fails:

report kernel's errno value.
This commit is contained in:
Tom Lane 1999-01-17 03:37:19 +00:00
parent 4deb20f4ce
commit 4a6285ee44
1 changed files with 7 additions and 4 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.86 1998/10/14 05:31:48 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.87 1999/01/17 03:37:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -584,9 +584,12 @@ connectDB(PGconn *conn)
if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) < 0)
{
(void) sprintf(conn->errorMessage,
"connectDB() failed: Is the postmaster running and accepting%s connections at '%s' on port '%s'?\n",
conn->pghost ? " TCP/IP(with -i)" : "",
conn->pghost ? conn->pghost : "UNIX Socket",
"connectDB() -- connect() failed: %s\n"
"Is the postmaster running%s at '%s' and accepting connections on %s '%s'?\n",
strerror(errno),
(family == AF_INET) ? " (with -i)" : "",
conn->pghost ? conn->pghost : "localhost",
(family == AF_INET) ? "TCP/IP port" : "Unix socket",
conn->pgport);
goto connect_errReturn;
}