Skip to content

Commit d2c2c83

Browse files
committed
Andres Freund remarks.
1 parent 1d6033b commit d2c2c83

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/interfaces/libpq/fe-exec.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ PQappendPipelinedCommand(PGconn *conn, PGcommandQueueEntry * entry)
15481548

15491549
/*
15501550
* 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
15521552
* with null next pointer and not referenced by any other entry's next pointer.
15531553
*/
15541554
static void
@@ -2041,18 +2041,24 @@ PQexitBatchMode(PGconn *conn)
20412041

20422042
/*
20432043
* 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.
20472044
*
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.
20512046
*
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.
20562062
*/
20572063
int
20582064
PQbatchSendQueue(PGconn *conn)
@@ -2070,12 +2076,14 @@ PQbatchSendQueue(PGconn *conn)
20702076
case PGASYNC_IDLE:
20712077
printfPQExpBuffer(&conn->errorMessage,
20722078
libpq_gettext_noop("internal error, IDLE in batch mode"));
2079+
return 0;
20732080
break;
20742081
case PGASYNC_COPY_IN:
20752082
case PGASYNC_COPY_OUT:
20762083
case PGASYNC_COPY_BOTH:
20772084
printfPQExpBuffer(&conn->errorMessage,
20782085
libpq_gettext_noop("internal error, COPY in batch mode"));
2086+
return 0;
20792087
break;
20802088
case PGASYNC_READY:
20812089
case PGASYNC_READY_MORE:
@@ -4375,7 +4383,8 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
43754383
static int
43764384
pqBatchFlush(PGconn *conn)
43774385
{
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))
43794388
return(pqFlush(conn));
43804389
return 0; /* Just to keep compiler quiet */
43814390
}

src/interfaces/libpq/libpq-int.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,7 @@ extern ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len);
832832
#define pqIsnonblocking(conn) ((conn)->nonblocking)
833833

834834
/*
835-
* Connection's outbuffer threshold is set to 64k as it is safe
836-
* in Windows as per comments in pqSendSome() API.
835+
* Connection's outbuffer threshold.
837836
*/
838837
#define OUTBUFFER_THRESHOLD 65536
839838

0 commit comments

Comments
 (0)