Skip to content

Commit f6d7ef0

Browse files
committed
Dept. of second thoughts: if query fails part way through, shut down
the pager before reporting the error.
1 parent c2f6071 commit f6d7ef0

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/bin/psql/common.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.127 2006/08/29 22:25:07 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.128 2006/08/29 22:48:55 tgl Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "common.h"
@@ -1062,17 +1062,26 @@ ExecQueryUsingCursor(const char *query, double *elapsed_msec)
10621062

10631063
/* get FETCH_COUNT tuples at a time */
10641064
results = PQexec(pset.db, fetch_cmd);
1065-
OK = AcceptResult(results) &&
1066-
(PQresultStatus(results) == PGRES_TUPLES_OK);
10671065

10681066
if (pset.timing)
10691067
{
10701068
GETTIMEOFDAY(&after);
10711069
*elapsed_msec += DIFF_MSEC(&after, &before);
10721070
}
10731071

1074-
if (!OK)
1072+
if (PQresultStatus(results) != PGRES_TUPLES_OK)
10751073
{
1074+
/* shut down pager before printing error message */
1075+
if (did_pager)
1076+
{
1077+
ClosePager(pset.queryFout);
1078+
pset.queryFout = queryFout_copy;
1079+
pset.queryFoutPipe = queryFoutPipe_copy;
1080+
did_pager = false;
1081+
}
1082+
1083+
OK = AcceptResult(results);
1084+
psql_assert(!OK);
10761085
PQclear(results);
10771086
break;
10781087
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy