postgresql-jdbc.git / summary / log / commit / refs
commit f61adb51bba9da2f49e833fe475b218eeeccb83d
Author: TomonariKatsumata <katsumata@localhost.localdomain>
Date: Thu Mar 06 08:24:16 2014 +0000
revised prepareThreshold and ForceBinaryTransfers
doc/pgjdbc.xml | 3 +++
org/postgresql/jdbc2/AbstractJdbc2Connection.java | 5 +----
org/postgresql/jdbc2/AbstractJdbc2Statement.java | 14 +++++---------
3 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/doc/pgjdbc.xml b/doc/pgjdbc.xml
index 5f6f04e1..efdd311e 100644
--- a/doc/pgjdbc.xml
+++ b/doc/pgjdbc.xml
@@ -711,6 +711,9 @@ openssl pkcs8 -topk8 -in client.key -out client.pk8 -outform DER -v1 PBE-SHA1-3D
<classname>PreparedStatement</classname> object. More
information on server side prepared
statements is available in <xref linkend="server-prepare" />.
+ Negative number is regarded as zero, but -1 has special meaning
+ that allows the first query of a<classname>PreparedStatement</classname>
+ to use binary encoding.
</para>
</listitem>
</varlistentry>
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Connection.java b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
index 592e6d9a..d9ef7c3b 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Connection.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
@@ -120,10 +120,7 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
{
prepareThreshold = Integer.parseInt(info.getProperty("prepareThreshold", "5"));
if (prepareThreshold < 0)
- {
forcebinary = true;
- prepareThreshold = 0;
- }
}
catch (Exception e)
{
@@ -1204,7 +1201,7 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
}
public void setPrepareThreshold(int newThreshold) {
- this.prepareThreshold = (newThreshold <= 0 ? 0 : newThreshold);
+ this.prepareThreshold = newThreshold;
}
public boolean getForceBinary() {
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
index 553e705b..3580257a 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
@@ -532,7 +532,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
if (preparedQuery != null)
{
++m_useCount; // We used this statement once more.
- if (m_prepareThreshold == 0 || m_useCount < m_prepareThreshold)
+ if ((m_prepareThreshold == 0 || m_useCount < m_prepareThreshold) && !ForceBinaryTransfers)
flags |= QueryExecutor.QUERY_ONESHOT;
}
@@ -543,7 +543,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
if (concurrency != ResultSet.CONCUR_READ_ONLY)
flags |= QueryExecutor.QUERY_NO_BINARY_TRANSFER;
- if (ForceBinaryTransfers) {
+ if (!queryToExecute.isStatementDescribed() && ForceBinaryTransfers) {
int flags2 = flags | QueryExecutor.QUERY_DESCRIBE_ONLY;
StatementResultHandler handler2 = new StatementResultHandler();
connection.getQueryExecutor().execute(queryToExecute, queryParameters, handler2, 0, 0, flags2);
@@ -2606,16 +2606,12 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
public void setPrepareThreshold(int newThreshold) throws SQLException {
checkClosed();
- if (newThreshold < 0)
+ if (newThreshold < 0) {
ForceBinaryTransfers = true;
+ newThreshold = 1;
+ }
else
ForceBinaryTransfers = false;
-
- if (ForceBinaryTransfers)
- newThreshold = 1;
-
- if (newThreshold < 0)
- newThreshold = 0;
this.m_prepareThreshold = newThreshold;
}
[parent: 8623ac4cfa50]