88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.155 2003/11/30 20:55:09 joe Exp $
11+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.156 2003/12/28 17:29:41 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -1234,6 +1234,9 @@ PQexecStart(PGconn *conn)
12341234return false;
12351235}
12361236}
1237+ /* check for loss of connection, too */
1238+ if (conn -> status == CONNECTION_BAD )
1239+ return false;
12371240}
12381241
12391242/* OK to send a command */
@@ -1256,6 +1259,8 @@ PQexecFinish(PGconn *conn)
12561259 *
12571260 * We have to stop if we see copy in/out, however. We will resume parsing
12581261 * after application performs the data transfer.
1262+ *
1263+ * Also stop if the connection is lost (else we'll loop infinitely).
12591264 */
12601265lastResult = NULL ;
12611266while ((result = PQgetResult (conn ))!= NULL )
@@ -1281,7 +1286,8 @@ PQexecFinish(PGconn *conn)
12811286}
12821287lastResult = result ;
12831288if (result -> resultStatus == PGRES_COPY_IN ||
1284- result -> resultStatus == PGRES_COPY_OUT )
1289+ result -> resultStatus == PGRES_COPY_OUT ||
1290+ conn -> status == CONNECTION_BAD )
12851291break ;
12861292}
12871293