aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/postmaster/postmaster.c5
-rw-r--r--src/interfaces/libpq/fe-connect.c56
2 files changed, 35 insertions, 26 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 618228364ce..4def9996f14 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.196 2000/11/29 22:04:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.197 2000/11/30 23:20:51 tgl Exp $
*
* NOTES
*
@@ -432,7 +432,6 @@ PostmasterMain(int argc, char *argv[])
NetServer = true;
break;
case 'k':
- /* Set PGUNIXSOCKET by hand. */
UnixSocketDir = optarg;
break;
#ifdef USE_SSL
@@ -732,7 +731,7 @@ usage(const char *progname)
printf(" -F turn fsync off\n");
printf(" -h HOSTNAME host name or IP address to listen on\n");
printf(" -i enable TCP/IP connections\n");
- printf(" -k FILENAME Unix domain socket location\n");
+ printf(" -k DIRECTORY Unix-domain socket location\n");
#ifdef USE_SSL
printf(" -l enable SSL connections\n");
#endif
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index b2a4c2c0dc4..173ab6c659e 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.151 2000/11/30 18:32:52 petere Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.152 2000/11/30 23:20:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -742,6 +742,36 @@ connectNoDelay(PGconn *conn)
/* ----------
+ * connectFailureMessage -
+ * create a friendly error message on connection failure.
+ * ----------
+ */
+static void
+connectFailureMessage(PGconn *conn, const char *caller, int errorno)
+{
+#ifdef HAVE_UNIX_SOCKETS
+ if (conn->raddr.sa.sa_family == AF_UNIX)
+ printfPQExpBuffer(&conn->errorMessage,
+ "%s -- connect() failed: %s\n"
+ "\tIs the postmaster running locally\n"
+ "\tand accepting connections on Unix socket '%s'?\n",
+ caller,
+ strerror(errorno),
+ conn->raddr.un.sun_path);
+ else
+#endif
+ printfPQExpBuffer(&conn->errorMessage,
+ "%s -- connect() failed: %s\n"
+ "\tIs the postmaster running (with -i) at '%s'\n"
+ "\tand accepting connections on TCP/IP port %s?\n",
+ caller,
+ strerror(errorno),
+ conn->pghost ? conn->pghost : "localhost",
+ conn->pgport);
+}
+
+
+/* ----------
* connectDBStart -
* Start to make a connection to the backend so it is ready to receive
* queries.
@@ -911,17 +941,7 @@ connectDBStart(PGconn *conn)
else
{
/* Something's gone wrong */
- printfPQExpBuffer(&conn->errorMessage,
- "connectDBStart() -- connect() failed: %s\n"
- "\tIs the postmaster running%s at '%s'\n"
- "\tand 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",
- (family == AF_UNIX && conn->pgunixsocket) ?
- conn->pgunixsocket : conn->pgport);
+ connectFailureMessage(conn, "connectDBStart()", errno);
goto connect_errReturn;
}
}
@@ -1213,17 +1233,7 @@ keep_going: /* We will come back to here until there
* see connect failures at this point, so provide a
* friendly error message.
*/
- printfPQExpBuffer(&conn->errorMessage,
- "PQconnectPoll() -- connect() failed: %s\n"
- "\tIs the postmaster running%s at '%s'\n"
- "\tand accepting connections on %s '%s'?\n",
- strerror(optval),
- (conn->raddr.sa.sa_family == AF_INET) ? " (with -i)" : "",
- conn->pghost ? conn->pghost : "localhost",
- (conn->raddr.sa.sa_family == AF_INET) ?
- "TCP/IP port" : "Unix socket",
- (conn->raddr.sa.sa_family == AF_UNIX && conn->pgunixsocket) ?
- conn->pgunixsocket : conn->pgport);
+ connectFailureMessage(conn, "PQconnectPoll()", optval);
goto error_return;
}