Skip to content

Commit

Permalink
Merge branch 'release/3.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Mar 18, 2022
2 parents 886f90f + de7d850 commit 452d9e5
Show file tree
Hide file tree
Showing 95 changed files with 2,160 additions and 661 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cache:
- $HOME/docker
- $HOME/.m2

env: local=0
env: local=0 RUN_LONG_TEST=true

install:
- |-
Expand All @@ -37,6 +37,7 @@ install:
jobs:
allow_failures:
- env: srv=build v=10.6
- env: srv=xpand TEST_DB_OTHER="initSql=SET NAMES UTF8"
include:
- env: srv=mariadb v=10.6
os: windows
Expand All @@ -52,6 +53,8 @@ jobs:
- env: srv=mariadb v=10.6 local=1 BENCH=1
- if: type = push AND fork = false
env: srv=maxscale
- if: type = push AND fork = false
env: srv=xpand TEST_DB_OTHER="initSql=SET NAMES UTF8"
- if: type = push AND fork = false
env: srv=build v=10.6
- if: type = push AND fork = false
Expand All @@ -73,4 +76,4 @@ script:
- if [ -z "$BENCH" ] ; then MAVEN_SKIP_RC=true MAVEN_OPTS="-Xmx2g" mvn clean test -DjobId=${TRAVIS_JOB_ID}; fi

after_script:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
# Change Log
## [3.0.4](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.0.4) (Mar 2022)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.0.3...3.0.4)

* [CONJ-915] javadoc addition
* [CONJ-921] DatabaseMetadata#getTables with null value for tableNamePattern throws Syntax error
* [CONJ-922] DECIMAL overflow for long/int/short not throwing exception
* [CONJ-924] NULL column type might result in java.lang.IllegalArgumentException: Unexpected datatype NULL
* [CONJ-926] Client restrict authentication to 'mysql_native_password,client_ed25519,auth_gssapi_client' if restrictedAuth parameter is not set
* [CONJ-924] NULL column test correction
* [CONJ-923] correctly return 64 bits generated id / updated rows
* [CONJ-933] load-balancing failover doesn't timeout
* [CONJ-935] Connection.getMetaData() returns MariaDbClob instead of String
* [CONJ-937] metadata getColumnTypeName wrong return type
* [CONJ-934] MariaDbDataSource is sensitive to the order of setting of username and password
* [CONJ-932] Login packet now use recommended length encoded value for connection attributes
* [CONJ-925] missing OSGI infos
* [CONJ-945] ensure retry is limited by retriesAllDown
* [CONJ-940] Permit updating rows when not having primary info on metadata (Xpand)
* [CONJ-939] add Xpand testing


## [3.0.3](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.0.3) (Jan 2022)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.0.2-rc...3.0.3)

Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,30 @@ or maven :
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
</dependency>
```


Development snapshot are available on sonatype nexus repository
```script
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.0.5-SNAPSHOT</version>
</dependency>
</dependencies>
```

## Documentation

For a Getting started guide, API docs, recipes, etc. see the
Expand Down
6 changes: 5 additions & 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.0.3</version>
<version>3.0.4</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>

Expand Down Expand Up @@ -176,6 +176,10 @@
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
<Export-Package>org.mariadb.jdbc</Export-Package>
<Import-Package>
javax.naming,javax.naming.ldap,javax.management,javax.sql,javax.net;resolution:=optional,javax.net.ssl;resolution:=optional,javax.transaction.xa;resolution:=optional,waffle.windows.auth;resolution:=optional,waffle.windows.auth.impl;resolution:=optional,org.ietf.jgss;resolution:=optional,javax.security.auth.login;resolution:=optional,javax.security.auth.x500;resolution:=optional,software.amazon.awssdk.*;resolution:=optional,org.slf4j;resolution:=optional
</Import-Package>
</manifestEntries>
</archive>
</configuration>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/mariadb/jdbc/DatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,9 @@ public ResultSet getTables(

if (types != null && types.length > 0) {
boolean mustAddType = false;
StringBuilder sqlType = new StringBuilder(" AND TABLE_TYPE IN (");

StringBuilder sqlType =
new StringBuilder(((firstCondition) ? " WHERE " : " AND ") + " TABLE_TYPE IN (");
for (String s : types) {
if (mustAddType) sqlType.append(",");
mustAddType = true;
Expand Down Expand Up @@ -791,7 +793,6 @@ public ResultSet getColumns(
firstCondition = patternCond(firstCondition, sb, "TABLE_NAME", tableNamePattern);
firstCondition = patternCond(firstCondition, sb, "COLUMN_NAME", columnNamePattern);
sb.append(" ORDER BY TABLE_CAT, TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION");

return executeQuery(sb.toString());
}

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/mariadb/jdbc/FunctionStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,17 @@ public void registerOutParameter(int index, int sqlType) throws SQLException {
}

@Override
protected void validParameters() throws SQLException {
protected void executeInternal() throws SQLException {
preValidParameters();
super.executeInternal();
}

/**
* Ensures that returning value is not taken as a parameter.
*
* @throws SQLException if any exception
*/
protected void preValidParameters() throws SQLException {
// remove first parameter, as it's an output param only
Parameters newParameters = new ParameterList(parameters.size() - 1);
for (int i = 0; i < parameters.size() - 1; i++) {
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/mariadb/jdbc/MariaDbDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ private void config() throws SQLException {
if (url == null) throw new SQLException("url not set");
conf = Configuration.parse(url);
if (loginTimeout != null) conf.connectTimeout(loginTimeout * 1000);
if (user != null) {
if (user != null || password != null) {
conf = conf.clone(user, password);
} else {
}
if (user != null) {
user = conf.user();
}
if (password != null) {
password = conf.password();
}
}
Expand Down
17 changes: 6 additions & 11 deletions src/main/java/org/mariadb/jdbc/MariaDbPoolDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ private void config() throws SQLException {
if (url == null) throw new SQLException("url not set");
conf = Configuration.parse(url);
if (loginTimeout != null) conf.connectTimeout(loginTimeout * 1000);
if (user != null) {
if (user != null || password != null) {
conf = conf.clone(user, password);
} else {
}
if (user != null) {
user = conf.user();
}
if (password != null) {
password = conf.password();
}

pool = Pools.retrievePool(conf);
}

Expand Down Expand Up @@ -268,15 +272,6 @@ public void setUser(String user) throws SQLException {
if (conf != null) config();
}

/**
* get password
*
* @return password
*/
public String getPassword() {
return password;
}

/**
* set password
*
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/mariadb/jdbc/ParameterMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.sql.SQLException;
import org.mariadb.jdbc.client.Column;
import org.mariadb.jdbc.client.DataType;
import org.mariadb.jdbc.export.ExceptionFactory;

/** Parameter metadata */
Expand Down Expand Up @@ -132,7 +133,9 @@ public int getParameterType(int idx) throws SQLException {
@Override
public String getParameterTypeName(int idx) throws SQLException {
checkIndex(idx);
return params[idx - 1].getType().name();
// https://jira.mariadb.org/browse/XPT-279 Xpand can return wrong datatype for parameters
DataType type = params[idx - 1].getType();
return type == null ? null : type.name();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void executeStandard(String cmd) throws SQLException {
con.getClient().execute(new PreparePacket(cmd), this, true);
}
}

validParameters();
// send COM_STMT_EXECUTE
ExecutePacket execute = new ExecutePacket(prepareResult, parameters, cmd, this);
results =
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/mariadb/jdbc/client/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ public interface Column {
*/
int getColumnType(Configuration conf);

/**
* Retrieves the designated column's MariaDB/MySQL type name
*
* @param conf configuration
* @return type name used by the database
*/
String getColumnTypeName(Configuration conf);

/**
* return column codec from column server type
*
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/mariadb/jdbc/client/ReadableByteBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ public interface ReadableByteBuf {
*
* @return encoded length
*/
int readLengthNotNull();
long readLongLengthEncodedNotNull();

/**
* Read encoded length value that cannot be null see
* https://mariadb.com/kb/en/protocol-data-types/#length-encoded-integers
*
* <p>this is readLongLengthEncodedNotNull limited to 32 bits
*
* @return encoded length
*/
int readIntLengthEncodedNotNull();

/**
* Utility to skip length encoded string, returning initial position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ public static void authenticationHandler(
// see https://mariadb.com/kb/en/library/ok_packet/
// *************************************************************************************
buf.skip(); // 0x00 OkPacket Header
buf.skip(buf.readLengthNotNull()); // affectedRows
buf.skip(buf.readLengthNotNull());
buf.readLongLengthEncodedNotNull(); // skip affectedRows
buf.readLongLengthEncodedNotNull(); // skip insert id
// insertId
context.setServerStatus(buf.readShort());
break authentication_loop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
public class MultiPrimaryClient implements Client {
private static final Logger logger = Loggers.getLogger(MultiPrimaryClient.class);

/** is socket close */
/** temporary blacklisted hosts */
protected static final ConcurrentMap<HostAddress, Long> denyList = new ConcurrentHashMap<>();

/** denied timeout */
Expand Down Expand Up @@ -89,7 +89,9 @@ protected Client connectHost(boolean readOnly, boolean failFast) throws SQLExcep
int maxRetries = conf.retriesAllDown();

while ((host = conf.haMode().getAvailableHost(conf.addresses(), denyList, !readOnly))
.isPresent()) {
.isPresent()
&& maxRetries > 0) {

try {
return conf.transactionReplay()
? new ReplayClient(conf, host.get(), lock, false)
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/org/mariadb/jdbc/client/impl/StandardClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLNonTransientConnectionException;
import java.time.DateTimeException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.zone.ZoneRulesException;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.locks.ReentrantLock;
Expand Down Expand Up @@ -325,6 +325,13 @@ private void postConnectionQueries() throws SQLException {
commands.add(String.format("CREATE DATABASE IF NOT EXISTS `%s`", escapedDb));
commands.add(String.format("USE `%s`", escapedDb));
}
if (conf.nonMappedOptions().containsKey("initSql")) {
String[] initialCommands = conf.nonMappedOptions().get("initSql").toString().split(";");
for (String cmd : initialCommands) {
commands.add(cmd);
}
}

if (!commands.isEmpty()) {
try {
List<Completion> res;
Expand Down Expand Up @@ -399,11 +406,12 @@ public String createSessionVariableQuery(String serverTz) {

// try to avoid timezone consideration if server use the same one
try {
if (ZoneId.of(serverTz).normalized().equals(clientZoneId)
ZoneId serverZoneId = ZoneId.of(serverTz);
if (serverZoneId.normalized().equals(clientZoneId)
|| ZoneId.of(serverTz, ZoneId.SHORT_IDS).equals(clientZoneId)) {
mustSetTimezone = false;
}
} catch (ZoneRulesException e) {
} catch (DateTimeException e) {
// eat
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,21 @@ public short getUnsignedByte() {
return (short) (buf[pos] & 0xff);
}

public int readLengthNotNull() {
public long readLongLengthEncodedNotNull() {
int type = (buf[pos++] & 0xff);
switch (type) {
case 252: // 0xfc
return readUnsignedShort();
case 253: // 0xfd
return readUnsignedMedium();
case 254: // 0xfe
return readLong();
default:
return type;
}
}

public int readIntLengthEncodedNotNull() {
int type = (buf[pos++] & 0xff);
switch (type) {
case 252:
Expand Down Expand Up @@ -204,7 +218,7 @@ public byte[] readBytesNullEnd() {
}

public StandardReadableByteBuf readLengthBuffer() {
int len = readLengthNotNull();
int len = this.readIntLengthEncodedNotNull();
byte[] tmp = new byte[len];
readBytes(tmp);
return new StandardReadableByteBuf(tmp, len);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/mariadb/jdbc/client/result/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ protected boolean readNext() throws IOException, SQLException {
serverStatus = readBuf.readUnsignedShort();
} else {
// OK_Packet with a 0xFE header
readBuf.skip(readBuf.readLengthNotNull()); // skip update count
readBuf.skip(readBuf.readLengthNotNull()); // skip insert id
readBuf.readLongLengthEncodedNotNull(); // skip update count
readBuf.readLongLengthEncodedNotNull(); // skip insert id
serverStatus = readBuf.readUnsignedShort();
warnings = readBuf.readUnsignedShort();
}
Expand Down Expand Up @@ -230,8 +230,8 @@ protected void skipRemaining() throws IOException, SQLException {
serverStatus = buf.readUnsignedShort();
} else {
// OK_Packet with a 0xFE header
buf.skip(buf.readLengthNotNull()); // skip update count
buf.skip(buf.readLengthNotNull()); // skip insert id
buf.readLongLengthEncodedNotNull(); // skip update count
buf.readLongLengthEncodedNotNull(); // skip insert id
serverStatus = buf.readUnsignedShort();
warnings = buf.readUnsignedShort();
}
Expand Down
Loading

0 comments on commit 452d9e5

Please sign in to comment.