Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove support for postgresql < 8.2 #661

Merged
merged 1 commit into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions pgjdbc/src/main/java/org/postgresql/PGProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public enum PGProperty {
* 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}.
Expand Down Expand Up @@ -105,12 +105,6 @@ public enum PGProperty {
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.
*/
Expand Down
56 changes: 0 additions & 56 deletions pgjdbc/src/main/java/org/postgresql/core/BaseConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class ConnectionFactory {
* 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
Expand All @@ -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;
}
Expand Down
9 changes: 0 additions & 9 deletions pgjdbc/src/main/java/org/postgresql/core/ServerVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
16 changes: 0 additions & 16 deletions pgjdbc/src/main/java/org/postgresql/ds/common/BaseDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 2 additions & 9 deletions pgjdbc/src/main/java/org/postgresql/jdbc/PgArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,11 +84,6 @@ private static class PgArrayList extends ArrayList<Object> {
*/
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()}.
Expand All @@ -101,8 +95,7 @@ private static class PgArrayList extends ArrayList<Object> {
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;
}

/**
Expand Down Expand Up @@ -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;
Expand Down
Loading