Skip to content

Commit

Permalink
Prevent use of extended query protocol for BEGIN before COPY (#1639)
Browse files Browse the repository at this point in the history
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 b371153
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -630,8 +630,12 @@ public void handleWarning(SQLWarning warning) {
};

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

0 comments on commit b371153

Please sign in to comment.