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

fix: Parsing server version with more than 3 parts #741

Merged
merged 2 commits into from Feb 2, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion pgjdbc/src/main/java/org/postgresql/core/ServerVersion.java
Expand Up @@ -138,7 +138,13 @@ static int parseServerVersionStr(String serverVersion) throws NumberFormatExcept
}
}

if (versionParts == 3) {
/* #667 - Allow for versions with greater than 3 parts.
For versions with more than 3 parts, still return 3 parts (4th part ignored for now
as no functionality is dependent on the 4th part .
Allows for future versions of the server to utilize more than 3 part version numbers
without upgrading the jdbc driver */

if (versionParts >= 3) {
if (parts[1] > 99) {
throw new NumberFormatException(
"Unsupported second part of major version > 99 in invalid version string: "
Expand Down
Expand Up @@ -31,6 +31,11 @@ public ServerVersionParseTest(String versionString, int versionNum, String rejec
@Parameterized.Parameters(name = "str = {0}, expected = {1}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][]{
/* 4 part version tests */
{"7.4.0.0", 70400, null},
{"9.0.0.0", 90000, null},
{"9.0.1.0", 90001, null},
{"9.2.1.0", 90201, null},
{"7.4.0", 70400, null},
{"9.0.0", 90000, null},
{"9.0.1", 90001, null},
Expand Down