diff options
author | Marc G. Fournier <scrappy@hub.org> | 1996-08-14 04:56:55 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 1996-08-14 04:56:55 +0000 |
commit | 011ee13131f6fa2f6dbafd3827b70d051cb28f64 (patch) | |
tree | ad5243989041a4da272c248714c11aa6ebde7b5e /src/interfaces | |
parent | 6b9ecd83484e5e4c37fd59b29f83a10e9a5430d9 (diff) | |
download | postgresql-011ee13131f6fa2f6dbafd3827b70d051cb28f64.tar.gz |
|
|We're all too familiar with psql's "no response from backend" message.
|Users can't tell what this means, and psql continues prompting for
|commands after it even though the backend is dead and no commands can
|succeed. It eventually dies on a signal when the dead socket fills
|up. I extended the message to offer a better explanation and made
|psql exit when it finds the backend is dead.
|
|I also added a short message and newline when the user does a ctl-D so
|it doesn't mess up the terminal display.
|
|
Submitted by: Bryan Henderson <bryanh@giraffe.netgate.net>
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index b81ae8535b..a1586bb64c 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.15 1996/08/13 01:34:27 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.16 1996/08/14 04:56:55 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -387,17 +387,26 @@ PQexec(PGconn* conn, const char* query) /* check to see if the query string is too long */ if (strlen(query) > MAX_MESSAGE_LEN) { - sprintf(conn->errorMessage, "PQexec() -- query is too long. Maximum length is %d\n", MAX_MESSAGE_LEN -2 ); + sprintf(conn->errorMessage, "PQexec() -- query is too long. " + "Maximum length is %d\n", MAX_MESSAGE_LEN -2 ); return NULL; } + /* Don't try to send if we know there's no live connection. */ + if (conn->status != CONNECTION_OK) { + sprintf(conn->errorMessage, "PQexec() -- There is no connection " + "to the backend.\n"); + return NULL; + } + /* the frontend-backend protocol uses 'Q' to designate queries */ sprintf(buffer,"Q%s",query); /* send the query to the backend; */ if (pqPuts(buffer,pfout, pfdebug) == 1) { (void) sprintf(conn->errorMessage, - "PQexec() -- while sending query: %s\n-- fprintf to Pfout failed: errno=%d\n%s\n", + "PQexec() -- while sending query: %s\n" + "-- fprintf to Pfout failed: errno=%d\n%s\n", query, errno,strerror(errno)); return NULL; } @@ -414,7 +423,12 @@ PQexec(PGconn* conn, const char* query) if (id == EOF) { /* hmm, no response from the backend-end, that's bad */ (void) sprintf(conn->errorMessage, - "PQexec() -- No response from backend\n"); + "PQexec() -- Request was sent to backend, but backend " + "closed the channel before " + "responding. This probably means the backend " + "terminated abnormally before or while processing " + "the request.\n"); + conn->status = CONNECTION_BAD; /* No more connection to backend */ return (PGresult*)NULL; } |