Permalink
Browse files

refactor: remove support for postgresql < 8.2 (#661)

  • Loading branch information...
jorsol authored and vlsi committed Nov 14, 2016
1 parent 63ee60e commit 14e64be7dc43feaef210e82fcd9b6089e54e5e4f
Showing with 726 additions and 2,032 deletions.
  1. +2 −8 pgjdbc/src/main/java/org/postgresql/PGProperty.java
  2. +0 −56 pgjdbc/src/main/java/org/postgresql/core/BaseConnection.java
  3. +4 −5 pgjdbc/src/main/java/org/postgresql/core/ConnectionFactory.java
  4. +0 −9 pgjdbc/src/main/java/org/postgresql/core/ServerVersion.java
  5. +0 −16 pgjdbc/src/main/java/org/postgresql/ds/common/BaseDataSource.java
  6. +2 −9 pgjdbc/src/main/java/org/postgresql/jdbc/PgArray.java
  7. +34 −132 pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java
  8. +353 −1,011 pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java
  9. +36 −124 pgjdbc/src/main/java/org/postgresql/jdbc/PgPreparedStatement.java
  10. +42 −96 pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java
  11. +8 −16 pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java
  12. +17 −43 pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java
  13. +0 −7 pgjdbc/src/main/java/org/postgresql/xa/PGXAConnection.java
  14. +4 −23 pgjdbc/src/test/java/org/postgresql/test/TestUtil.java
  15. +2 −12 pgjdbc/src/test/java/org/postgresql/test/jdbc2/ArrayTest.java
  16. +2 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/BlobTest.java
  17. +26 −22 pgjdbc/src/test/java/org/postgresql/test/jdbc2/CallableStmtTest.java
  18. +3 −10 pgjdbc/src/test/java/org/postgresql/test/jdbc2/CopyTest.java
  19. +1 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DatabaseEncodingTest.java
  20. +5 −17 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DatabaseMetaDataPropertiesTest.java
  21. +35 −100 pgjdbc/src/test/java/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
  22. +3 −2 pgjdbc/src/test/java/org/postgresql/test/jdbc2/GeometricTest.java
  23. +3 −7 pgjdbc/src/test/java/org/postgresql/test/jdbc2/IntervalTest.java
  24. +3 −3 pgjdbc/src/test/java/org/postgresql/test/jdbc2/Jdbc2TestSuite.java
  25. +2 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/NotifyTest.java
  26. +0 −78 pgjdbc/src/test/java/org/postgresql/test/jdbc2/OID74Test.java
  27. +57 −79 pgjdbc/src/test/java/org/postgresql/test/jdbc2/PreparedStatementTest.java
  28. +15 −28 pgjdbc/src/test/java/org/postgresql/test/jdbc2/StatementTest.java
  29. +2 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc2/TimestampTest.java
  30. +29 −59 pgjdbc/src/test/java/org/postgresql/test/jdbc2/TimezoneTest.java
  31. +6 −14 pgjdbc/src/test/java/org/postgresql/test/jdbc3/DatabaseMetaDataTest.java
  32. +2 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc3/Jdbc3BlobTest.java
  33. +1 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc3/Jdbc3SavepointTest.java
  34. +2 −6 pgjdbc/src/test/java/org/postgresql/test/jdbc3/Jdbc3TestSuite.java
  35. +1 −5 pgjdbc/src/test/java/org/postgresql/test/jdbc4/ArrayTest.java
  36. +5 −4 pgjdbc/src/test/java/org/postgresql/test/jdbc4/ClientInfoTest.java
  37. +2 −6 pgjdbc/src/test/java/org/postgresql/test/jdbc4/DatabaseMetaDataTest.java
  38. +2 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc4/Jdbc4TestSuite.java
  39. +3 −1 pgjdbc/src/test/java/org/postgresql/test/jdbc4/JsonbTest.java
  40. +2 −5 pgjdbc/src/test/java/org/postgresql/test/sspi/SSPITestSuite.java
  41. +10 −12 pgjdbc/src/test/java/org/postgresql/test/xa/XATestSuite.java
@@ -51,8 +51,8 @@
* fallback.
*/
PROTOCOL_VERSION("protocolVersion", null,
"Force use of a particular protocol version when connecting, if set, disables protocol version fallback.",
false, "2", "3"),
"Force use of a particular protocol version when connecting, currently only version 3 is supported.",
false, "3"),

/**
* The loglevel. Can be one of {@link Driver#DEBUG}, {@link Driver#INFO}, {@link Driver#OFF}.
@@ -105,12 +105,6 @@
BINARY_TRANSFER("binaryTransfer", "true",
"Use binary format for sending and receiving data if possible"),

/**
* Force compatibility of some features with an older version of the driver.
*/
COMPATIBLE("compatible", Driver.MAJORVERSION + "." + Driver.MINORVERSION,
"Force compatibility of some features with an older version of the driver"),

/**
* Puts this connection in read-only mode.
*/
@@ -75,62 +75,6 @@ ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency)

TypeInfo getTypeInfo();

/**
* Check if we should use driver behaviour introduced in a particular driver version. This
* defaults to behaving as the actual driver's version but can be overridden by the "compatible"
* URL parameter.
*
* If possible you should use the integer version of this method instead. It was introduced with
* the 9.4 driver release.
*
* @param ver the driver version to check
* @return true if the driver's behavioural version is at least "ver".
* @deprecated Avoid using this in new code that can require PgJDBC 9.4.
*/
@Deprecated
boolean haveMinimumCompatibleVersion(String ver);

/**
* Check if we should use driver behaviour introduced in a particular driver version.
*
* This defaults to behaving as the actual driver's version but can be overridden by the
* "compatible" URL parameter.
*
* The version is of the form xxyyzz, e.g. 90401 for PgJDBC 9.4.1.
*
* This is used to toggle between different functionality as it changes across different releases
* of the jdbc driver code. The values here are versions of the jdbc client and not server
* versions. For example in 7.1 get/setBytes worked on LargeObject values, in 7.2 these methods
* were changed to work on bytea values. This change in functionality could be disabled by setting
* the "compatible" level to be 7.1, in which case the driver will revert to the 7.1
* functionality.
*
* @param ver the driver version to check, eg 90401 for 9.4.1
* @return true if the driver's behavioural version is at least "ver".
*/
boolean haveMinimumCompatibleVersion(int ver);

/**
* Check if we should use driver behaviour introduced in a particular driver version.
*
* This defaults to behaving as the actual driver's version but can be overridden by the
* "compatible" URL parameter.
*
* @param ver the driver version to check
* @return true if the driver's behavioural version is at least "ver".
*/
boolean haveMinimumCompatibleVersion(Version ver);

/**
* Check if we have at least a particular server version.
*
* @param ver the server version to check
* @return true if the server version is at least "ver".
* @deprecated Use haveMinimumServerVersion(int) instead
*/
@Deprecated
boolean haveMinimumServerVersion(String ver);

/**
* Check if we have at least a particular server version.
*
@@ -29,7 +29,7 @@
* If the "protocolVersion" property is specified, only that protocol version is tried. Otherwise,
* all protocols are tried in order, falling back to older protocols as necessary.
* <p>
* Currently, protocol versions 3 (7.4+) and 2 (pre-7.4) are supported.
* Currently, protocol versions 3 (7.4+) is supported.
*
* @param hostSpecs at least one host and port to connect to; multiple elements for round-robin
* failover
@@ -45,11 +45,10 @@ public static QueryExecutor openConnection(HostSpec[] hostSpecs, String user,
String database, Properties info, Logger logger) throws SQLException {
String protoName = PGProperty.PROTOCOL_VERSION.get(info);

if (protoName == null || "".equals(protoName)
|| "2".equals(protoName) || "3".equals(protoName)) {
if (protoName == null || protoName.isEmpty() || "3".equals(protoName)) {
ConnectionFactory connectionFactory = new ConnectionFactoryImpl();
QueryExecutor queryExecutor =
connectionFactory.openConnectionImpl(hostSpecs, user, database, info, logger);
QueryExecutor queryExecutor = connectionFactory.openConnectionImpl(
hostSpecs, user, database, info, logger);
if (queryExecutor != null) {
return queryExecutor;
}
@@ -14,15 +14,6 @@
public enum ServerVersion implements Version {

INVALID("0.0.0"),
v6_4("6.4.0"),
v6_5("6.5.0"),
v7_0("7.0.0"),
v7_1("7.1.0"),
v7_2("7.2.0"),
v7_3("7.3.0"),
v7_4("7.4.0"),
v8_0("8.0.0"),
v8_1("8.1.0"),
v8_2("8.2.0"),
v8_3("8.3.0"),
v8_4("8.4.0"),
@@ -216,22 +216,6 @@ public void setPortNumber(int portNumber) {
this.portNumber = portNumber;
}

/**
* @return value of compatible parameter
* @see PGProperty#COMPATIBLE
*/
public String getCompatible() {
return PGProperty.COMPATIBLE.get(properties);
}

/**
* @param compatible value of compatible parameter
* @see PGProperty#COMPATIBLE
*/
public void setCompatible(String compatible) {
PGProperty.COMPATIBLE.set(properties, compatible);
}

/**
* @return login timeout
* @see PGProperty#LOGIN_TIMEOUT
@@ -10,7 +10,6 @@
import org.postgresql.core.Encoding;
import org.postgresql.core.Field;
import org.postgresql.core.Oid;
import org.postgresql.core.ServerVersion;
import org.postgresql.jdbc2.ArrayAssistant;
import org.postgresql.jdbc2.ArrayAssistantRegistry;
import org.postgresql.util.ByteConverter;
@@ -85,11 +84,6 @@
*/
private final boolean useObjects;

/**
* Are we connected to an 8.2 or higher server? Only 8.2 or higher supports null array elements.
*/
private final boolean haveMinServer82;

/**
* Value of field as {@link PgArrayList}. Will be initialized only once within
* {@link #buildArrayList()}.
@@ -101,8 +95,7 @@
private PgArray(BaseConnection connection, int oid) throws SQLException {
this.connection = connection;
this.oid = oid;
this.useObjects = connection.haveMinimumCompatibleVersion(ServerVersion.v8_3);
this.haveMinServer82 = connection.haveMinimumServerVersion(ServerVersion.v8_2);
this.useObjects = true;
}

/**
@@ -504,7 +497,7 @@ private synchronized void buildArrayList() throws SQLException {

// add element to current array
if (b != null && (!b.isEmpty() || wasInsideString)) {
curArray.add(!wasInsideString && haveMinServer82 && b.equals("NULL") ? null : b);
curArray.add(!wasInsideString && b.equals("NULL") ? null : b);
}

wasInsideString = false;
Oops, something went wrong.

0 comments on commit 14e64be

Please sign in to comment.