aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-08-29 22:48:55 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-08-29 22:48:55 +0000
commitf6d7ef08a73e42c41c40e50287233e94539ce6e3 (patch)
tree6a6001df3d790f87cfa527aaaeb774ba5d403f13
parentc2f60711d25b256dbe2c1ddce833c5c69ca051cc (diff)
downloadpostgresql-f6d7ef08a73e42c41c40e50287233e94539ce6e3.tar.gz
postgresql-f6d7ef08a73e42c41c40e50287233e94539ce6e3.zip
Dept. of second thoughts: if query fails part way through, shut down
the pager before reporting the error.
-rw-r--r--src/bin/psql/common.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 87e5ebc1fdd..81323ad0d63 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.127 2006/08/29 22:25:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.128 2006/08/29 22:48:55 tgl Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -1062,8 +1062,6 @@ ExecQueryUsingCursor(const char *query, double *elapsed_msec)
/* get FETCH_COUNT tuples at a time */
results = PQexec(pset.db, fetch_cmd);
- OK = AcceptResult(results) &&
- (PQresultStatus(results) == PGRES_TUPLES_OK);
if (pset.timing)
{
@@ -1071,8 +1069,19 @@ ExecQueryUsingCursor(const char *query, double *elapsed_msec)
*elapsed_msec += DIFF_MSEC(&after, &before);
}
- if (!OK)
+ if (PQresultStatus(results) != PGRES_TUPLES_OK)
{
+ /* shut down pager before printing error message */
+ if (did_pager)
+ {
+ ClosePager(pset.queryFout);
+ pset.queryFout = queryFout_copy;
+ pset.queryFoutPipe = queryFoutPipe_copy;
+ did_pager = false;
+ }
+
+ OK = AcceptResult(results);
+ psql_assert(!OK);
PQclear(results);
break;
}