aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-exec.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-12-28 17:29:51 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-12-28 17:29:51 +0000
commit2315548ed7a8dda84316f325eb633c6f0c09b842 (patch)
tree128478a3a85fd032ceadd34fc28b2c3022ac991b /src/interfaces/libpq/fe-exec.c
parenta8c003ea9d9a7caa413d50a05a3120d9ce22e83a (diff)
downloadpostgresql-2315548ed7a8dda84316f325eb633c6f0c09b842.tar.gz
postgresql-2315548ed7a8dda84316f325eb633c6f0c09b842.zip
Avoid infinite loop if connection is lost during PQexecStart() or
PQexecFinish(). Per report from Andreas Pflug.
Diffstat (limited to 'src/interfaces/libpq/fe-exec.c')
-rw-r--r--src/interfaces/libpq/fe-exec.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 03fec88e677..1c557a10aeb 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.153.2.1 2003/11/30 20:53:43 joe Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.153.2.2 2003/12/28 17:29:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1234,6 +1234,9 @@ PQexecStart(PGconn *conn)
return false;
}
}
+ /* check for loss of connection, too */
+ if (conn->status == CONNECTION_BAD)
+ return false;
}
/* OK to send a command */
@@ -1256,6 +1259,8 @@ PQexecFinish(PGconn *conn)
*
* We have to stop if we see copy in/out, however. We will resume parsing
* after application performs the data transfer.
+ *
+ * Also stop if the connection is lost (else we'll loop infinitely).
*/
lastResult = NULL;
while ((result = PQgetResult(conn)) != NULL)
@@ -1281,7 +1286,8 @@ PQexecFinish(PGconn *conn)
}
lastResult = result;
if (result->resultStatus == PGRES_COPY_IN ||
- result->resultStatus == PGRES_COPY_OUT)
+ result->resultStatus == PGRES_COPY_OUT ||
+ conn->status == CONNECTION_BAD)
break;
}