postgresql-jdbc.git / summary / log / commit / refs
commit d2a7d481a260c70bc62285eacb22cdebdeba8e1e
Author: Maciek Sakrejda <m.sakrejda@gmail.com>
Commit: Maciek Sakrejda <maciek@heroku.com>
Date: Wed Aug 15 04:20:24 2012 +0000
Adding pgbouncer transaction patch.
Originally from http://treehou.se/~omar/postgresql-jdbc-8.4-701-pgbouncer_txn.patch
org/postgresql/core/v3/QueryExecutorImpl.java | 6 +++++-
org/postgresql/jdbc2/AbstractJdbc2Connection.java | 7 ++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/org/postgresql/core/v3/QueryExecutorImpl.java b/org/postgresql/core/v3/QueryExecutorImpl.java
index 54dd1046..19df1a12 100644
--- a/org/postgresql/core/v3/QueryExecutorImpl.java
+++ b/org/postgresql/core/v3/QueryExecutorImpl.java
@@ -424,7 +424,11 @@ public class QueryExecutorImpl implements QueryExecutor {
protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE)
return delegateHandler;
- sendOneQuery(beginTransactionQuery, SimpleQuery.NO_PARAMETERS, 0, 0, QueryExecutor.QUERY_NO_METADATA);
+ int beginFlags = QueryExecutor.QUERY_NO_METADATA;
+ if ((flags & QueryExecutor.QUERY_ONESHOT) != 0) {
+ beginFlags |= QueryExecutor.QUERY_ONESHOT;
+ }
+ sendOneQuery(beginTransactionQuery, SimpleQuery.NO_PARAMETERS, 0, 0, beginFlags);
// Insert a handler that intercepts the BEGIN.
return new ResultHandler() {
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Connection.java b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
index d5e38c10..4e0e97c2 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Connection.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
@@ -794,8 +794,13 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
}
private void executeTransactionCommand(Query query) throws SQLException {
+ int flags = QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_SUPPRESS_BEGIN;
+ if (prepareThreshold == 0) {
+ flags |= QueryExecutor.QUERY_ONESHOT;
+ }
+
getQueryExecutor().execute(query, null, new TransactionCommandHandler(),
- 0, 0, QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_SUPPRESS_BEGIN);
+ 0, 0, flags);
}
/*
[parent: 9d55850db47d]