Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit207f6ed

Browse files
committed
Print the error message before attempting to reset the connection after a
backend crash.
1 parent352cd1f commit207f6ed

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

‎src/bin/psql/common.c

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.27 2000/11/27 02:20:36 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.28 2000/12/15 17:54:43 petere Exp $
77
*/
88
#include"postgres.h"
99
#include"common.h"
@@ -315,32 +315,6 @@ PSQLexec(const char *query)
315315
if (PQresultStatus(res)!=PGRES_COPY_OUT)
316316
cancelConn=NULL;
317317

318-
if (PQstatus(pset.db)==CONNECTION_BAD)
319-
{
320-
if (!pset.cur_cmd_interactive)
321-
{
322-
psql_error("connection to server was lost\n");
323-
exit(EXIT_BADCONN);
324-
}
325-
fputs("The connection to the server was lost. Attempting reset: ",stderr);
326-
PQreset(pset.db);
327-
if (PQstatus(pset.db)==CONNECTION_BAD)
328-
{
329-
fputs("Failed.\n",stderr);
330-
PQfinish(pset.db);
331-
PQclear(res);
332-
pset.db=NULL;
333-
SetVariable(pset.vars,"DBNAME",NULL);
334-
SetVariable(pset.vars,"HOST",NULL);
335-
SetVariable(pset.vars,"PORT",NULL);
336-
SetVariable(pset.vars,"USER",NULL);
337-
SetVariable(pset.vars,"ENCODING",NULL);
338-
returnNULL;
339-
}
340-
else
341-
fputs("Succeeded.\n",stderr);
342-
}
343-
344318
if (res&& (PQresultStatus(res)==PGRES_COMMAND_OK||
345319
PQresultStatus(res)==PGRES_TUPLES_OK||
346320
PQresultStatus(res)==PGRES_COPY_IN||
@@ -351,6 +325,31 @@ PSQLexec(const char *query)
351325
{
352326
psql_error("%s",PQerrorMessage(pset.db));
353327
PQclear(res);
328+
329+
if (PQstatus(pset.db)==CONNECTION_BAD)
330+
{
331+
if (!pset.cur_cmd_interactive)
332+
{
333+
psql_error("connection to server was lost\n");
334+
exit(EXIT_BADCONN);
335+
}
336+
fputs("The connection to the server was lost. Attempting reset: ",stderr);
337+
PQreset(pset.db);
338+
if (PQstatus(pset.db)==CONNECTION_BAD)
339+
{
340+
fputs("Failed.\n",stderr);
341+
PQfinish(pset.db);
342+
pset.db=NULL;
343+
SetVariable(pset.vars,"DBNAME",NULL);
344+
SetVariable(pset.vars,"HOST",NULL);
345+
SetVariable(pset.vars,"PORT",NULL);
346+
SetVariable(pset.vars,"USER",NULL);
347+
SetVariable(pset.vars,"ENCODING",NULL);
348+
}
349+
else
350+
fputs("Succeeded.\n",stderr);
351+
}
352+
354353
returnNULL;
355354
}
356355
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp