From cf7026b64b3e56889f8a81194a57221500e23a0f Mon Sep 17 00:00:00 2001 From: Robert Haas <rhaas@postgresql.org> Date: Wed, 7 Mar 2012 16:56:42 -0500 Subject: [PATCH] psql: Avoid some spurious output if the server croaks. Fixes a regression in commit 08146775acd8bfe0fcc509c71857abb928697171. Noah Misch --- src/bin/psql/common.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 5c9bd960022..715e23167de 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -740,7 +740,7 @@ ProcessResult(PGresult **results) } while (next_result); /* may need this to recover from conn loss during COPY */ - if (!CheckConnection()) + if (!first_cycle && !CheckConnection()) return false; return success; @@ -1015,8 +1015,10 @@ SendQuery(const char *query) case PQTRANS_UNKNOWN: default: OK = false; - psql_error("unexpected transaction status (%d)\n", - transaction_status); + /* PQTRANS_UNKNOWN is expected given a broken connection. */ + if (transaction_status != PQTRANS_UNKNOWN || ConnectionUp()) + psql_error("unexpected transaction status (%d)\n", + transaction_status); break; } -- GitLab