Skip to content

Commit

Permalink
refactor: remove support for postgresql < 8.2 (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorsol authored and vlsi committed Nov 14, 2016
1 parent 63ee60e commit 14e64be
Show file tree
Hide file tree
Showing 41 changed files with 726 additions and 2,032 deletions.
10 changes: 2 additions & 8 deletions pgjdbc/src/main/java/org/postgresql/PGProperty.java
Expand Up @@ -51,8 +51,8 @@ public enum PGProperty {
* fallback. * fallback.
*/ */
PROTOCOL_VERSION("protocolVersion", null, PROTOCOL_VERSION("protocolVersion", null,
"Force use of a particular protocol version when connecting, if set, disables protocol version fallback.", "Force use of a particular protocol version when connecting, currently only version 3 is supported.",
false, "2", "3"), false, "3"),


/** /**
* The loglevel. Can be one of {@link Driver#DEBUG}, {@link Driver#INFO}, {@link Driver#OFF}. * The loglevel. Can be one of {@link Driver#DEBUG}, {@link Driver#INFO}, {@link Driver#OFF}.
Expand Down Expand Up @@ -105,12 +105,6 @@ public enum PGProperty {
BINARY_TRANSFER("binaryTransfer", "true", BINARY_TRANSFER("binaryTransfer", "true",
"Use binary format for sending and receiving data if possible"), "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. * Puts this connection in read-only mode.
*/ */
Expand Down
56 changes: 0 additions & 56 deletions pgjdbc/src/main/java/org/postgresql/core/BaseConnection.java
Expand Up @@ -75,62 +75,6 @@ ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency)


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


if (protoName == null || "".equals(protoName) if (protoName == null || protoName.isEmpty() || "3".equals(protoName)) {
|| "2".equals(protoName) || "3".equals(protoName)) {
ConnectionFactory connectionFactory = new ConnectionFactoryImpl(); ConnectionFactory connectionFactory = new ConnectionFactoryImpl();
QueryExecutor queryExecutor = QueryExecutor queryExecutor = connectionFactory.openConnectionImpl(
connectionFactory.openConnectionImpl(hostSpecs, user, database, info, logger); hostSpecs, user, database, info, logger);
if (queryExecutor != null) { if (queryExecutor != null) {
return queryExecutor; return queryExecutor;
} }
Expand Down
9 changes: 0 additions & 9 deletions pgjdbc/src/main/java/org/postgresql/core/ServerVersion.java
Expand Up @@ -14,15 +14,6 @@
public enum ServerVersion implements Version { public enum ServerVersion implements Version {


INVALID("0.0.0"), 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_2("8.2.0"),
v8_3("8.3.0"), v8_3("8.3.0"),
v8_4("8.4.0"), v8_4("8.4.0"),
Expand Down
16 changes: 0 additions & 16 deletions pgjdbc/src/main/java/org/postgresql/ds/common/BaseDataSource.java
Expand Up @@ -216,22 +216,6 @@ public void setPortNumber(int portNumber) {
this.portNumber = 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 * @return login timeout
* @see PGProperty#LOGIN_TIMEOUT * @see PGProperty#LOGIN_TIMEOUT
Expand Down
11 changes: 2 additions & 9 deletions pgjdbc/src/main/java/org/postgresql/jdbc/PgArray.java
Expand Up @@ -10,7 +10,6 @@
import org.postgresql.core.Encoding; import org.postgresql.core.Encoding;
import org.postgresql.core.Field; import org.postgresql.core.Field;
import org.postgresql.core.Oid; import org.postgresql.core.Oid;
import org.postgresql.core.ServerVersion;
import org.postgresql.jdbc2.ArrayAssistant; import org.postgresql.jdbc2.ArrayAssistant;
import org.postgresql.jdbc2.ArrayAssistantRegistry; import org.postgresql.jdbc2.ArrayAssistantRegistry;
import org.postgresql.util.ByteConverter; import org.postgresql.util.ByteConverter;
Expand Down Expand Up @@ -85,11 +84,6 @@ private static class PgArrayList extends ArrayList<Object> {
*/ */
private final boolean useObjects; 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 * Value of field as {@link PgArrayList}. Will be initialized only once within
* {@link #buildArrayList()}. * {@link #buildArrayList()}.
Expand All @@ -101,8 +95,7 @@ private static class PgArrayList extends ArrayList<Object> {
private PgArray(BaseConnection connection, int oid) throws SQLException { private PgArray(BaseConnection connection, int oid) throws SQLException {
this.connection = connection; this.connection = connection;
this.oid = oid; this.oid = oid;
this.useObjects = connection.haveMinimumCompatibleVersion(ServerVersion.v8_3); this.useObjects = true;
this.haveMinServer82 = connection.haveMinimumServerVersion(ServerVersion.v8_2);
} }


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


// add element to current array // add element to current array
if (b != null && (!b.isEmpty() || wasInsideString)) { 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; wasInsideString = false;
Expand Down

0 comments on commit 14e64be

Please sign in to comment.