Skip to content
Browse files

Prevent use of extended query protocol for BEGIN before COPY (#1639)

When autocommit is off and the first query in a transaction is a COPY, we were
sending a BEGIN using the extended query protocol. It was being permitted to
use named portals as well, ignoring prepareThreshold.

Fix by forcing simple query mode and marking the BEGIN as oneshot.

Fixes #1638
  • Loading branch information
ringerc authored and davecramer committed Dec 6, 2019
1 parent ad83cb3 commit b37115373935732b1ab5e59b56837ac49942718a
Showing with 6 additions and 2 deletions.
  1. +6 −2 pgjdbc/src/main/java/org/postgresql/core/v3/
@@ -630,8 +630,12 @@ public void handleWarning(SQLWarning warning) {

try {
sendOneQuery(beginTransactionQuery, SimpleQuery.NO_PARAMETERS, 0, 0,
/* Send BEGIN with simple protocol preferred */
int beginFlags = QueryExecutor.QUERY_NO_METADATA
| QueryExecutor.QUERY_ONESHOT
beginFlags = updateQueryMode(beginFlags);
sendOneQuery(beginTransactionQuery, SimpleQuery.NO_PARAMETERS, 0, 0, beginFlags);
processResults(handler, 0);
estimatedReceiveBufferBytes = 0;

0 comments on commit b371153

Please sign in to comment.
You can’t perform that action at this time.