Skip to content

Commit

Permalink
Merge branch 'release/2.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Jun 27, 2017
2 parents 11897e6 + bb70ae1 commit 62a79ed
Show file tree
Hide file tree
Showing 20 changed files with 273 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cache:
directories:
- $HOME/.m2
jdk:
- oraclejdk9
# - oraclejdk9 temporary disabled, because travis issue https://github.com/travis-ci/travis-ci/issues/7944
- oraclejdk8
env:
- AURORA=true
Expand Down
18 changes: 9 additions & 9 deletions .travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ set -e

case "$TYPE" in
"MAXSCALE" )
urlString=-DdbUrl='jdbc:mariadb://localhost:4006/testj?user=root&killFetchStmtOnClose=false'
urlString=-DdbUrl='jdbc:mariadb://localhost:4006/testj?user=root&killFetchStmtOnClose=false&enablePacketDebug=true'
;;
"REWRITE" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&rewriteBatchedStatements=true'
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&rewriteBatchedStatements=true&enablePacketDebug=true'
;;
"PREPARE" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useServerPrepStmts=true'
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useServerPrepStmts=true&enablePacketDebug=true'
;;
"MULTI" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&allowMultiQueries=true'
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&allowMultiQueries=true&enablePacketDebug=true'
;;
"BULK_SERVER" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=true&useServerPrepStmts=true'
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=true&useServerPrepStmts=true&enablePacketDebug=true'
;;
"NO_BULK_CLIENT" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=false'
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=false&enablePacketDebug=true'
;;
"NO_BULK_SERVER" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=false&useServerPrepStmts=true'
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=false&useServerPrepStmts=true&enablePacketDebug=true'
;;
"COMPRESSION" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useCompression=true'
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useCompression=true&enablePacketDebug=true'
;;
*)
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root'
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&enablePacketDebug=true'
;;
esac;

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Tracker link <a href="https://jira.mariadb.org/projects/CONJ/issues/">https://ji

| Java version | driver compatible version |
|:------------:|:-------------------------:|
| 6 | up to 1.1.10 |
| 7 | up to 1.6.1 |
| 6 | < 2.0 version |
| 7 | < 2.0 version |
| 8 | all version |

The driver (jar) can be downloaded from [mariadb connector download](https://mariadb.com/products/connectors-plugins)
Expand All @@ -31,7 +31,7 @@ or maven :
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
</dependency>
```

Expand Down
8 changes: 8 additions & 0 deletions documentation/changelog.creole
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
= Changelog
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#203|2.0.3]] Released on 27 Jun. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#202|2.0.2]] Released on 05 Jun. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#161|1.6.1]] Released on 05 Jun. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#201|2.0.1]] Released on 10 May 2017
Expand All @@ -23,6 +24,13 @@
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#140|1.4.0]] Released on 31 march 2016
---

== 2.0.3
Bug
*[CONJ-473] when useServerPrepStmts is not set, the PREPARE statement must not be cached.
*[CONJ-494] Handle PrepareStatement.getParameterMetaData() if query cannot be PREPAREd
*[CONJ-497] escape string correction for big query

== 1.6.1
report of 2.0.2 corrections for jre 1.7 compatible version.

Expand Down
16 changes: 10 additions & 6 deletions mariadb-java-client.iml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
Expand All @@ -12,19 +12,23 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.22" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-classic:1.1.7" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-core:1.1.7" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: commons-dbcp:commons-dbcp:1.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: commons-pool:commons-pool:1.5.4" level="project" />
<orderEntry type="library" name="Maven: com.github.dblock.waffle:waffle-jna:1.8.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.14" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.zaxxer:HikariCP:2.4.7" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.threadly:threadly:4.4.3" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna:4.2.1" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna-platform:4.2.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.22" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-classic:1.1.7" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-core:1.1.7" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: commons-dbcp:commons-dbcp:1.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: commons-pool:commons-pool:1.5.4" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.amazonaws:aws-java-sdk:1.10.76" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.amazonaws:aws-java-sdk-support:1.10.76" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.amazonaws:aws-java-sdk-simpledb:1.10.76" level="project" />
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<artifactId>mariadb-java-client</artifactId>
<packaging>jar</packaging>
<name>mariadb-java-client</name>
<version>2.0.2</version>
<version>2.0.3</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>

Expand All @@ -71,7 +71,7 @@
<checkstyle.plugin.version>2.16</checkstyle.plugin.version>
<driver.version.major>2</driver.version.major>
<driver.version.minor>0</driver.version.minor>
<driver.version.patch>2</driver.version.patch>
<driver.version.patch>3</driver.version.patch>
<driver.version.qualifier></driver.version.qualifier>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public CallableProcedureStatement clone(MariaDbConnection connection) throws Clo
CallableProcedureStatement clone = (CallableProcedureStatement) super.clone(connection);
clone.params = params;
clone.parameterMetadata = parameterMetadata;
clone.hasInOutParameters = hasInOutParameters;
clone.outputParameterMapper = outputParameterMapper;
return clone;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public MariaDbParameterMetaData(ColumnInformation[] parametersInformation) {
}

private void checkAvailable() throws SQLException {
if(this.parametersInformation == null) {
if (this.parametersInformation == null) {
throw new SQLException("Parameter metadata not available for these statement", "S1C00");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,12 @@ public void write(Reader reader, long length, boolean escape, boolean noBackslas
public void writeBytesEscaped(byte[] bytes, int len, boolean noBackslashEscapes)
throws IOException {
if (len * 2 > buf.length - pos) {

//makes buffer bigger (up to 16M)
if (buf.length != getMaxPacketLength()) growBuffer(len * 2);

//max buffer size
//data may be bigger than buffer.
//must flush buffer when full (and reset position to 0)
if (len * 2 > buf.length - pos) {
if (noBackslashEscapes) {
for (int i = 0; i < len; i++) {
Expand All @@ -658,7 +661,6 @@ public void writeBytesEscaped(byte[] bytes, int len, boolean noBackslashEscapes)
|| bytes[i] == SLASH
|| bytes[i] == DBL_QUOTE
|| bytes[i] == ZERO_BYTE) {
len -= 1;
buf[pos++] = '\\';
if (buf.length <= pos) flushBuffer(false);
}
Expand All @@ -670,7 +672,7 @@ public void writeBytesEscaped(byte[] bytes, int len, boolean noBackslashEscapes)
}
}

//sure to have enough place
//sure to have enough place filling buffer directly
if (noBackslashEscapes) {
for (int i = 0; i < len; i++) {
if (QUOTE == bytes[i]) buf[pos++] = QUOTE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public abstract class AbstractConnectProtocol implements Protocol {
private int patchVersion;
private Map<String, String> serverData;
private TimeZone timeZone;
private LruTraceCache traceCache;
private LruTraceCache traceCache = new LruTraceCache();

/**
* Get a protocol instance.
Expand Down Expand Up @@ -220,8 +220,7 @@ public void close() {
}

if (options.enablePacketDebug) {
if (traceCache != null) traceCache.clearMemory();
traceCache = null;
traceCache.clearMemory();
}
}

Expand Down Expand Up @@ -368,7 +367,8 @@ public void connect() throws SQLException {
} catch (SQLException sqle) {
throw sqle;
} catch (IOException e) {
throw new SQLException("Could not connect to " + currentHost + ". " + e.getMessage(), CONNECTION_EXCEPTION.getSqlState(), e);
throw new SQLException("Could not connect to " + currentHost + ". " + e.getMessage() + getTraces(),
CONNECTION_EXCEPTION.getSqlState(), e);
}
}

Expand Down Expand Up @@ -411,6 +411,10 @@ private void connect(String host, int port) throws SQLException, IOException {
if (options.useCompression) {
writer = new CompressPacketOutputStream(writer.getOutputStream(), options.maxQuerySizeToLog);
reader = new DecompressPacketInputStream(((StandardPacketInputStream) reader).getBufferedInputStream(), options.maxQuerySizeToLog);
if (options.enablePacketDebug) {
writer.setTraceCache(traceCache);
reader.setTraceCache(traceCache);
}
}

if (options.usePipelineAuth && !options.createDatabaseIfNotExist) {
Expand All @@ -432,12 +436,6 @@ private void connect(String host, int port) throws SQLException, IOException {
// Extract socketTimeout URL parameter
if (options.socketTimeout != null) socket.setSoTimeout(options.socketTimeout);

if (options.enablePacketDebug) {
traceCache = new LruTraceCache();
writer.setTraceCache(traceCache);
reader.setTraceCache(traceCache);
}

reader.setServerThreadId(this.serverThreadId, isMasterConnection());
writer.setServerThreadId(this.serverThreadId, isMasterConnection());

Expand Down Expand Up @@ -485,8 +483,8 @@ private void sendSessionInfos() throws IOException {
sessionOption.append(", sql_mode = concat(@@sql_mode,',STRICT_TRANS_TABLES')");
}

if (options.sessionVariables != null) {
sessionOption.append("," + options.sessionVariables);
if (options.sessionVariables != null && !options.sessionVariables.isEmpty()) {
sessionOption.append("," + Utils.parseSessionVariables(options.sessionVariables));
}

writer.startPacket(0);
Expand Down Expand Up @@ -654,6 +652,11 @@ private void handleConnectionPhases() throws SQLException {
reader = new StandardPacketInputStream(socket.getInputStream(), options.maxQuerySizeToLog);
writer = new StandardPacketOutputStream(socket.getOutputStream(), options.maxQuerySizeToLog);

if (options.enablePacketDebug) {
writer.setTraceCache(traceCache);
reader.setTraceCache(traceCache);
}

final ReadInitialHandShakePacket greetingPacket = new ReadInitialHandShakePacket(reader);
this.serverThreadId = greetingPacket.getServerThreadId();
reader.setServerThreadId(this.serverThreadId, null);
Expand Down Expand Up @@ -686,6 +689,10 @@ private void handleConnectionPhases() throws SQLException {
writer = new StandardPacketOutputStream(socket.getOutputStream(), options.maxQuerySizeToLog);
reader = new StandardPacketInputStream(socket.getInputStream(), options.maxQuerySizeToLog);

if (options.enablePacketDebug) {
writer.setTraceCache(traceCache);
reader.setTraceCache(traceCache);
}
packetSeq++;
} else if (options.useSsl) {
throw new SQLException("Trying to connect with ssl, but ssl not enabled in the server");
Expand Down Expand Up @@ -1003,7 +1010,7 @@ public void connectWithoutProxy() throws SQLException {
} catch (IOException e) {
if (hosts.isEmpty()) {
throw new SQLException("Could not connect to named pipe '" + options.pipe + "' : "
+ e.getMessage(), CONNECTION_EXCEPTION.getSqlState(), e);
+ e.getMessage() + getTraces(), CONNECTION_EXCEPTION.getSqlState(), e);
}
}
}
Expand All @@ -1025,7 +1032,7 @@ public void connectWithoutProxy() throws SQLException {
throw sqle;
} catch (IOException e) {
if (hosts.isEmpty()) {
throw new SQLException("Could not connect to " + HostAddress.toString(addrs) + " : " + e.getMessage(),
throw new SQLException("Could not connect to " + HostAddress.toString(addrs) + " : " + e.getMessage() + getTraces(),
CONNECTION_EXCEPTION.getSqlState(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1303,8 +1303,9 @@ public void readResultSet(Buffer buffer, Results results) throws SQLException {
// - after a callable resultSet, a OK packet is send, but mysql does send the a bad "more result flag"
Buffer bufferEof = reader.getPacket(true);
if (bufferEof.readByte() != EOF) {
throw new SQLException("Packets out of order when reading field packets, expected was EOF stream. "
+ "Packet contents (hex) = " + Utils.hexdump(options.maxQuerySizeToLog, 0, bufferEof.position, bufferEof.buf));
throw new SQLException("Packets out of order when reading field packets, expected was EOF stream."
+ ((options.enablePacketDebug) ? getTraces() : "Packet contents (hex) = "
+ Utils.hexdump(options.maxQuerySizeToLog, 0, bufferEof.position, bufferEof.buf)));
}
bufferEof.skipBytes(2); //Skip warningCount
callableResult = (bufferEof.readShort() & ServerStatus.PS_OUT_PARAMETERS) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,9 @@ private static Options parse(HaMode haMode, Properties properties, Options optio
//disable use server prepare id using client rewrite
if (options.rewriteBatchedStatements) {
options.useServerPrepStmts = false;
}

if (!options.useServerPrepStmts) {
options.cachePrepStmts = false;
}

Expand Down
Loading

0 comments on commit 62a79ed

Please sign in to comment.