Skip to content

Commit

Permalink
Merge branch 'release/3.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Aug 1, 2023
2 parents 745ef7b + 964a2c4 commit c81d451
Show file tree
Hide file tree
Showing 330 changed files with 2,663 additions and 786 deletions.
33 changes: 24 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
os: linux
dist: bionic
dist: jammy
language: java
services:
- docker
Expand Down Expand Up @@ -47,19 +47,30 @@ jobs:
allow_failures:
- env: srv=build
- env: srv=xpand TEST_DB_OTHER="&initSql=SET NAMES UTF8"
- env: srv=mariadb-es local=1
- env: srv=skysql
- env: srv=skysql-ha
include:
- stage: Minimal
env: srv=mariadb v=10.6 packet=8
name: "CS 10.6"
- env: srv=mariadb-es v=10.6
name: "ES 10.6"
- env: srv=mariadb-es
name: "ES latest"
if: type = push AND fork = false

- stage: Enterprise
env: srv=mariadb-es v=10.4
dist: bionic
name: "ES 10.4"
- env: srv=mariadb-es v=10.5
dist: bionic
name: "ES 10.5"
- env: srv=mariadb-es v=10.6
name: "ES 10.6"
if: type = push AND fork = false
- env: srv=mariadb-es-test v=23.06
name: "ES 23.06"
if: type = push AND fork = false
- env: srv=maxscale
name: "Maxscale"
- env: srv=xpand TEST_DB_OTHER="&initSql=SET NAMES UTF8"
Expand All @@ -74,18 +85,22 @@ jobs:
os: windows
language: shell
name: "CS 10.6 - Windows"
- env: srv=mariadb v=10.3 local=1
name: "CS 10.3"
- env: srv=mariadb v=10.4 local=1
dist: bionic
name: "CS 10.4"
- env: srv=mariadb v=10.5 local=1
dist: bionic
name: "CS 10.5"
- env: srv=mariadb v=10.7 local=1
name: "CS 10.7"
- env: srv=mariadb v=10.8 local=1
name: "CS 10.8"
- env: srv=mariadb v=10.9 local=1
name: "CS 10.9"
- env: srv=mariadb v=10.10 local=1
name: "CS 10.10"
- env: srv=mariadb v=10.11 local=1
name: "CS 10.11"
- env: srv=mariadb v=11.0 local=1
name: "CS 11.0"
- env: srv=mariadb v=11.1-rc local=1
name: "CS 11.1"
- env: srv=mariadb v=10.6 packet=40
jdk: openjdk17
name: "CS 10.6 - openjdk 17"
Expand Down
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Change Log


## [3.2.0](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.2.0) (Aug 2023)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.1.4...3.2.0)

##### Notable Changes
* CONJ-920 Java batched statements with optimistic locking failing. the option `useBulkStmts` is now disable by default, a new option `useBulkStmtsForInserts` is enable by default, permetting using bulk for INSERT commands only. This permits optimistic behavior working by default.
* CONJ-1084 When using maxscale 23.08.0+, and a maxscale node fails, connector will now priorize reconnection to the maxscale node having less connection, to ensure repartition after failover
* CONJ-1088 Implement `databaseTerm` option for mysql compatibility
* CONJ-1096 adding option `useLocalSessionState` to permit avoiding queries when application only use JDBC methods.

##### Bugs Fixed
* CONJ-1075 LOAD DATA INFILE is broken on windows
* CONJ-1079 getGeneratedKeys after batch will not return all generated id's if first batch command return no generated id.
* CONJ-1080 maridb Java connector sslMode=verify-ca complaining unable to find trust certificate.
* CONJ-1082 Multiple session system variables parsing fails
* CONJ-1083 Using /*client prepare*/ prefix to force client side prepared statement
* CONJ-1091 can't make a connection when the Read Replica DB is in a hang state when SocketTimeout=0 set
* CONJ-1092 ensure respecting server collation
* CONJ-1094 Missing mariadb/mysql collation


## [3.0.11](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.0.11) (Aug 2023)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.0.10...3.0.11)

* CONJ-1089 correcting 3.0.10 incompatibility with in java 8

## [2.7.10](https://github.com/mariadb-corporation/mariadb-connector-j/tree/2.7.10) (Aug 2023)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/2.7.9...2.7.10)

* CONJ-1091 Ensure setting connectTimeout as timeout for socket timeout until connection is done. This permit to set a connectTimeout, while socketTimeout can still be set to 0

## [3.1.4](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.1.4) (Apr 2023)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.1.3...3.1.4)

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>mariadb-java-client</artifactId>
<packaging>jar</packaging>
<name>mariadb-java-client</name>
<version>3.1.4</version>
<version>3.2.0</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>

Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/java/org/mariadb/jdbc/Common.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/java/org/mariadb/jdbc/Do_1.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/java/org/mariadb/jdbc/Do_1000_params.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/java/org/mariadb/jdbc/Insert_batch.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/java/org/mariadb/jdbc/Select_1.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/java/org/mariadb/jdbc/Select_1000_Rows.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/java/org/mariadb/jdbc/Select_100_cols.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/mariadb/jdbc/BaseCallableStatement.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/mariadb/jdbc/BasePreparedStatement.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand All @@ -13,6 +13,7 @@
import java.sql.ParameterMetaData;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;
import org.mariadb.jdbc.client.ColumnDecoder;
import org.mariadb.jdbc.client.util.Parameters;
import org.mariadb.jdbc.codec.*;
Expand All @@ -24,6 +25,8 @@

/** Common methods for prepare statement, for client and server prepare statement. */
public abstract class BasePreparedStatement extends Statement implements PreparedStatement {
private static final Pattern INSERT_STATEMENT_PATTERN =
Pattern.compile("^(\\s*\\/\\*([^*]|\\*[^/])*\\*\\/)*\\s*(INSERT)", Pattern.CASE_INSENSITIVE);

/** parameters */
protected Parameters parameters;
Expand All @@ -37,6 +40,8 @@ public abstract class BasePreparedStatement extends Statement implements Prepare
/** PREPARE command result */
protected Prepare prepareResult = null;

protected Boolean isCommandInsert = null;

/**
* Constructor
*
Expand Down Expand Up @@ -91,6 +96,11 @@ public String toString() {
return sb.toString();
}

protected void checkIfInsertCommand() {
if (isCommandInsert == null)
isCommandInsert = (sql == null) ? false : INSERT_STATEMENT_PATTERN.matcher(sql).find();
}

/**
* Set PREPARE result
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

Expand Down
53 changes: 43 additions & 10 deletions src/main/java/org/mariadb/jdbc/ClientPreparedStatement.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2021 MariaDB Corporation Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab

package org.mariadb.jdbc;

import static org.mariadb.jdbc.util.constants.Capabilities.*;

import java.sql.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import org.mariadb.jdbc.client.ColumnDecoder;
import org.mariadb.jdbc.client.Completion;
Expand Down Expand Up @@ -107,12 +104,16 @@ private void executeInternal() throws SQLException {
}
}

private void executeInternalPreparedBatch() throws SQLException {
private boolean executeInternalPreparedBatch() throws SQLException {
checkNotClosed();
if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS
checkIfInsertCommand();
Configuration conf = con.getContext().getConf();
if (((isCommandInsert && (conf.useBulkStmts() || conf.useBulkStmtsForInserts()))
|| (!isCommandInsert && conf.useBulkStmts()))
&& batchParameters.size() > 1
&& con.getContext().hasClientCapability(STMT_BULK_OPERATIONS)) {
&& autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS) {
executeBatchBulk();
return isCommandInsert;
} else {
boolean possibleLoadLocal = con.getContext().hasClientCapability(LOCAL_FILES);
if (possibleLoadLocal) {
Expand All @@ -128,6 +129,7 @@ private void executeInternalPreparedBatch() throws SQLException {
executeBatchPipeline();
}
}
return false;
}

/**
Expand Down Expand Up @@ -463,8 +465,24 @@ public int[] executeBatch() throws SQLException {
if (batchParameters == null || batchParameters.isEmpty()) return new int[0];
lock.lock();
try {
executeInternalPreparedBatch();
boolean wasBulkInsert = executeInternalPreparedBatch();

int[] updates = new int[batchParameters.size()];

// specific case for BULK INSERT
// return not Statement.SUCCESS_NO_INFO, but 1
if (wasBulkInsert) {
int numberOfResult = 0;
for (int i = 0; i < results.size(); i++) {
numberOfResult += (int) ((OkPacket) results.get(i)).getAffectedRows();
}
if (numberOfResult == updates.length) {
Arrays.fill(updates, 1);
currResult = results.remove(0);
return updates;
}
}

if (results.size() != batchParameters.size()) {
for (int i = 0; i < batchParameters.size(); i++) {
updates[i] = Statement.SUCCESS_NO_INFO;
Expand Down Expand Up @@ -492,8 +510,23 @@ public long[] executeLargeBatch() throws SQLException {
if (batchParameters == null || batchParameters.isEmpty()) return new long[0];
lock.lock();
try {
executeInternalPreparedBatch();
boolean wasBulkInsert = executeInternalPreparedBatch();
long[] updates = new long[results.size()];

// specific case for BULK INSERT
// return not Statement.SUCCESS_NO_INFO, but 1
if (wasBulkInsert) {
int numberOfResult = 0;
for (int i = 0; i < results.size(); i++) {
numberOfResult += (int) ((OkPacket) results.get(i)).getAffectedRows();
}
if (numberOfResult == updates.length) {
Arrays.fill(updates, 1);
currResult = results.remove(0);
return updates;
}
}

for (int i = 0; i < results.size(); i++) {
updates[i] = ((OkPacket) results.get(i)).getAffectedRows();
}
Expand Down
Loading

0 comments on commit c81d451

Please sign in to comment.