@@ -1548,7 +1548,7 @@ PQappendPipelinedCommand(PGconn *conn, PGcommandQueueEntry * entry)
1548
1548
1549
1549
/*
1550
1550
* PQrecyclePipelinedCommand
1551
- * Push a command queue entry onto the freelist. It must be a dangling entry
1551
+ * Push a command queue entry onto the freelist. It must be an entry
1552
1552
* with null next pointer and not referenced by any other entry's next pointer.
1553
1553
*/
1554
1554
static void
@@ -2041,18 +2041,24 @@ PQexitBatchMode(PGconn *conn)
2041
2041
2042
2042
/*
2043
2043
* PQbatchSendQueue
2044
- * End a batch submission by sending a protocol sync. The connection will
2045
- * remain in batch mode and unavailable for new synchronous command execution
2046
- * functions until all results from the batch are processed by the client.
2047
2044
*
2048
- * It's legal to start submitting another batch immediately, without waiting
2049
- * for the results of the current batch. There's no need to end batch mode
2050
- * and start it again.
2045
+ * End a batch submission.
2051
2046
*
2052
- * If a command in a batch fails, every subsequent command up to and including
2053
- * the PQbatchQueueSync command result gets set to PGRES_BATCH_ABORTED state. If the
2054
- * whole batch is processed without error, a PGresult with PGRES_BATCH_END is
2055
- * produced.
2047
+ * It's legal to start submitting another batch immediately, without
2048
+ * waiting for the results of the current batch. There's no need to end batch
2049
+ * mode and start it again.
2050
+ *
2051
+ * If a command in a batch fails, every subsequent command up to and
2052
+ * including the PQbatchQueueSync command result gets set to PGRES_BATCH_ABORTED
2053
+ * state. If the whole batch is processed without error, a PGresult with
2054
+ * PGRES_BATCH_END is produced.
2055
+ *
2056
+ * Queries can already have been sent before PQbatchSendQueue is called, but
2057
+ * PQbatchSendQueue need to be called before retrieving command results.
2058
+ *
2059
+ * The connection will remain in batch mode and unavailable for new synchronous
2060
+ * command execution functions until all results from the batch are processed
2061
+ * by the client.
2056
2062
*/
2057
2063
int
2058
2064
PQbatchSendQueue (PGconn * conn )
@@ -2070,12 +2076,14 @@ PQbatchSendQueue(PGconn *conn)
2070
2076
case PGASYNC_IDLE :
2071
2077
printfPQExpBuffer (& conn -> errorMessage ,
2072
2078
libpq_gettext_noop ("internal error, IDLE in batch mode" ));
2079
+ return 0 ;
2073
2080
break ;
2074
2081
case PGASYNC_COPY_IN :
2075
2082
case PGASYNC_COPY_OUT :
2076
2083
case PGASYNC_COPY_BOTH :
2077
2084
printfPQExpBuffer (& conn -> errorMessage ,
2078
2085
libpq_gettext_noop ("internal error, COPY in batch mode" ));
2086
+ return 0 ;
2079
2087
break ;
2080
2088
case PGASYNC_READY :
2081
2089
case PGASYNC_READY_MORE :
@@ -4375,7 +4383,8 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
4375
4383
static int
4376
4384
pqBatchFlush (PGconn * conn )
4377
4385
{
4378
- if ((conn -> batch_status == PQBATCH_MODE_OFF )|| (conn -> outCount >= OUTBUFFER_THRESHOLD ))
4386
+ if ((conn -> batch_status == PQBATCH_MODE_OFF ) ||
4387
+ (conn -> outCount >= OUTBUFFER_THRESHOLD ))
4379
4388
return (pqFlush (conn ));
4380
4389
return 0 ; /* Just to keep compiler quiet */
4381
4390
}
0 commit comments