postgresql-jdbc.git / summary / log / commit / refs
commit f82be902c2c7789cfdcd54ce769e03e3c54d3ffb
Author: Dave Cramer <davecramer@gmail.com>
Date: Sun Jun 28 14:46:35 2015 +0000
Merge pull request #319 from Gordiychuk/cachePreparedStatements
perf: cache prepared statements across .prepareStatement calls
doc/pgjdbc.xml | 33 ++
org/postgresql/PGProperty.java | 10 +
org/postgresql/core/CachedQuery.java | 60 +++
org/postgresql/core/NativeQuery.java | 77 ++++
org/postgresql/core/Parser.java | 447 ++++++++++++++++++---
org/postgresql/core/v2/QueryExecutorImpl.java | 24 +-
org/postgresql/core/v2/V2Query.java | 82 +---
org/postgresql/core/v3/QueryExecutorImpl.java | 152 +------
org/postgresql/core/v3/SimpleQuery.java | 44 +-
org/postgresql/ds/common/BaseDataSource.java | 34 +-
org/postgresql/jdbc2/AbstractJdbc2Connection.java | 26 +-
org/postgresql/jdbc2/AbstractJdbc2Statement.java | 303 ++------------
org/postgresql/jdbc2/CachedQueryCreateAction.java | 51 +++
org/postgresql/jdbc2/CallableQueryKey.java | 45 +++
org/postgresql/jdbc3/AbstractJdbc3Statement.java | 2 +-
org/postgresql/test/util/LruCacheTest.java | 152 +++++++
org/postgresql/util/CanEstimateSize.java | 12 +
org/postgresql/util/LruCache.java | 114 ++++++
.../benchmark/statement/ParseStatement.java | 7 +
19 files changed, 1091 insertions(+), 584 deletions(-)
diff --cc org/postgresql/jdbc2/AbstractJdbc2Statement.java
index 8975f1be,ea111d6b..3ffec72d
--- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
@@@ -163,18 -160,19 +162,21 @@@ public abstract class AbstractJdbc2Stat
this.connection = connection;
this.lastSimpleQuery = null;
- String parsed_sql = replaceProcessing(sql);
+ CachedQuery cachedQuery = connection.borrowQuery(sql, isCallable);
if (isCallable)
- parsed_sql = modifyJdbcCall(parsed_sql);
+ {
+ this.isFunction = cachedQuery.isFunction;
+ this.outParmBeforeFunc = cachedQuery.outParmBeforeFunc;
+ }
- this.preparedQuery = connection.getQueryExecutor().createParameterizedQuery(parsed_sql);
- this.preparedParameters = preparedQuery.createParameterList();
+ this.preparedQuery = cachedQuery;
+ this.preparedParameters = preparedQuery.query.createParameterList();
- int inParamCount = preparedParameters.getInParameterCount() + 1;
- this.testReturn = new int[inParamCount];
- this.functionReturnType = new int[inParamCount];
+ if (isFunction) {
+ int inParamCount = preparedParameters.getInParameterCount() + 1;
+ this.testReturn = new int[inParamCount];
+ this.functionReturnType = new int[inParamCount];
+ }
forceBinaryTransfers |= connection.getForceBinary();
[parent: 8e3c13cd88d7]