Skip to content

Commit

Permalink
Merge branch 'release/1.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Mar 16, 2023
2 parents ce68aed + 75ecaa2 commit 4f9385f
Show file tree
Hide file tree
Showing 61 changed files with 734 additions and 231 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
fast_finish: true
allow_failures:
- env: srv=build
- env: srv=xpand
include:
- stage: Minimal
env: srv=mariadb v=10.6 local=1
Expand All @@ -55,6 +56,8 @@ jobs:
name: "SkySQL"
- env: srv=skysql-ha
name: "SkySQL with replication"
- env: srv=xpand
name: "Xpand"

- stage: Community
env: srv=mariadb v=10.6
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Change Log

## [1.1.4](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/tree/1.1.4) (16 Mar 2023)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/compare/1.1.3...1.1.4)

Bugs Fixed:

* [R2DBC-76] Wrong MEDIUM field binary decoding
* [R2DBC-77] Metadata is null when using returnGeneratedValues on server before 10.5
* [R2DBC-79] Wrong client side parsing for named parameter when using user variable
* [R2DBC-80] add option to disable hostname verification for SslMode.TUNNEL. thanks to @shubha-rajan
* [R2DBC-81] missing parsing/builder variables for option restrictedAuth,rsaPublicKey,cachingRsaPublicKey and allowPublicKeyRetrievalString
* [R2DBC-82] wrong transactionIsolation level set/get with server without session tracking
* [R2DBC-85] adding hint in order to execute text command when useServerPrepStmts option is set
* [R2DBC-83] support xpand 0000-00-00 timestamp/date encoding



## [1.1.3](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/tree/1.1.3) (22 Dec 2022)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-r2dbc/compare/1.1.2...1.1.3)

Expand Down
69 changes: 35 additions & 34 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.mariadb</groupId>
<artifactId>r2dbc-mariadb</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
<packaging>jar</packaging>
<url>https://github.com/mariadb-corporation/mariadb-connector-r2dbc</url>

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/mariadb/r2dbc/MariadbConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public MariadbStatement createStatement(String sql) {
throw new IllegalArgumentException("Statement cannot be empty.");
}

if (this.configuration.useServerPrepStmts() || sql.contains("call")) {
if ((this.configuration.useServerPrepStmts() || sql.contains("call")) && !sql.startsWith("/*text*/")) {
return new MariadbServerParameterizedQueryStatement(this.client, sql, this.configuration);
}
return new MariadbClientParameterizedQueryStatement(this.client, sql, this.configuration);
Expand All @@ -112,7 +112,7 @@ public MariadbConnectionMetadata getMetadata() {
@Override
public IsolationLevel getTransactionIsolationLevel() {
if (isolationLevel != null) return isolationLevel;
if ((client.getContext().getClientCapabilities() | Capabilities.CLIENT_SESSION_TRACK) > 0
if ((client.getContext().getClientCapabilities() & Capabilities.CLIENT_SESSION_TRACK) > 0
&& client.getContext().getIsolationLevel() != null)
return client.getContext().getIsolationLevel();
return this.sessionIsolationLevel;
Expand Down Expand Up @@ -221,7 +221,7 @@ public Mono<Void> setStatementTimeout(Duration timeout) {
public Mono<Void> setTransactionIsolationLevel(IsolationLevel isolationLevel) {
Assert.requireNonNull(isolationLevel, "isolationLevel must not be null");

if ((client.getContext().getClientCapabilities() | Capabilities.CLIENT_SESSION_TRACK) > 0
if ((client.getContext().getClientCapabilities() & Capabilities.CLIENT_SESSION_TRACK) > 0
&& client.getContext().getIsolationLevel() != null
&& client.getContext().getIsolationLevel().equals(isolationLevel)) return Mono.empty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ private MariadbConnectionConfiguration(
boolean tinyInt1isBit,
String restrictedAuth,
@Nullable LoopResources loopResources,
@Nullable UnaryOperator<SslContextBuilder> sslContextBuilderCustomizer) {
@Nullable UnaryOperator<SslContextBuilder> sslContextBuilderCustomizer,
boolean sslTunnelDisableHostVerification) {
this.haMode = haMode == null ? HaMode.NONE : HaMode.from(haMode);
this.connectTimeout = connectTimeout == null ? Duration.ofSeconds(10) : connectTimeout;
this.tcpKeepAlive = tcpKeepAlive == null ? Boolean.FALSE : tcpKeepAlive;
Expand Down Expand Up @@ -128,6 +129,7 @@ private MariadbConnectionConfiguration(
clientSslKey,
clientSslPassword,
tlsProtocol,
sslTunnelDisableHostVerification,
sslContextBuilderCustomizer);
}
this.rsaPublicKey = rsaPublicKey;
Expand Down Expand Up @@ -195,6 +197,28 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti
connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.TCP_KEEP_ALIVE)));
}

if (connectionFactoryOptions.hasOption(
MariadbConnectionFactoryProvider.ALLOW_PUBLIC_KEY_RETRIEVAL)) {
builder.allowPublicKeyRetrieval(
boolValue(
connectionFactoryOptions.getValue(
MariadbConnectionFactoryProvider.ALLOW_PUBLIC_KEY_RETRIEVAL)));
}

if (connectionFactoryOptions.hasOption(
MariadbConnectionFactoryProvider.CACHING_RSA_PUBLIC_KEY)) {
builder.cachingRsaPublicKey(
(String)
connectionFactoryOptions.getValue(
MariadbConnectionFactoryProvider.CACHING_RSA_PUBLIC_KEY));
}

if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.RSA_PUBLIC_KEY)) {
builder.rsaPublicKey(
(String)
connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.RSA_PUBLIC_KEY));
}

if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.TCP_ABORTIVE_CLOSE)) {
builder.tcpAbortiveClose(
boolValue(
Expand Down Expand Up @@ -316,13 +340,28 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti
}
builder.pamOtherPwd(pairs);
}

if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.RESTRICTED_AUTH)) {
builder.restrictedAuth(
(String)
connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.RESTRICTED_AUTH));
}

if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.LOOP_RESOURCES)) {
LoopResources loopResources =
(LoopResources)
connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.LOOP_RESOURCES);
builder.loopResources(loopResources);
}

if (connectionFactoryOptions.hasOption(
MariadbConnectionFactoryProvider.SSL_TUNNEL_DISABLE_HOST_VERIFICATION)) {
builder.sslTunnelDisableHostVerification(
boolValue(
connectionFactoryOptions.getValue(
MariadbConnectionFactoryProvider.SSL_TUNNEL_DISABLE_HOST_VERIFICATION)));
}

if (connectionFactoryOptions.hasOption(
MariadbConnectionFactoryProvider.SSL_CONTEXT_BUILDER_CUSTOMIZER)) {
builder.sslContextBuilderCustomizer(
Expand Down Expand Up @@ -539,7 +578,7 @@ public String toString() {
+ ", pamOtherPwd="
+ hiddenPamPwd
+ ", restrictedAuth="
+ restrictedAuth
+ (restrictedAuth == null ? "" : Arrays.toString(restrictedAuth))
+ '}';
}

Expand Down Expand Up @@ -587,6 +626,8 @@ public static final class Builder implements Cloneable {

private Builder() {}

private boolean sslTunnelDisableHostVerification;

/**
* Returns a configured {@link MariadbConnectionConfiguration}.
*
Expand Down Expand Up @@ -641,7 +682,8 @@ public MariadbConnectionConfiguration build() {
this.tinyInt1isBit,
this.restrictedAuth,
this.loopResources,
this.sslContextBuilderCustomizer);
this.sslContextBuilderCustomizer,
this.sslTunnelDisableHostVerification);
}

/**
Expand Down Expand Up @@ -976,6 +1018,11 @@ public Builder sslContextBuilderCustomizer(
return this;
}

public Builder sslTunnelDisableHostVerification(boolean sslTunnelDisableHostVerification) {
this.sslTunnelDisableHostVerification = sslTunnelDisableHostVerification;
return this;
}

@Override
public Builder clone() throws CloneNotSupportedException {
return (Builder) super.clone();
Expand Down Expand Up @@ -1054,6 +1101,8 @@ public String toString() {
+ clientSslPassword
+ ", sslMode="
+ sslMode
+ ", sslTunnelDisableHostVerification="
+ sslTunnelDisableHostVerification
+ ", pamOtherPwd="
+ hiddenPamPwd
+ ", tinyInt1isBit="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class MariadbConnectionFactoryProvider implements ConnectionFactory
public static final Option<Boolean> ALLOW_PIPELINING = Option.valueOf("allowPipelining");
public static final Option<Boolean> USE_SERVER_PREPARE = Option.valueOf("useServerPrepStmts");
public static final Option<String> ISOLATION_LEVEL = Option.valueOf("isolationLevel");
public static final Option<Boolean> AUTO_COMMIT = Option.valueOf("autoCommit");
public static final Option<Boolean> AUTO_COMMIT = Option.valueOf("autocommit");
public static final Option<Boolean> TINY_IS_BIT = Option.valueOf("tinyInt1isBit");
public static final Option<Integer> PREPARE_CACHE_SIZE = Option.valueOf("prepareCacheSize");
public static final Option<String> SSL_MODE = Option.valueOf("sslMode");
Expand All @@ -38,8 +38,18 @@ public final class MariadbConnectionFactoryProvider implements ConnectionFactory
public static final Option<Boolean> TCP_ABORTIVE_CLOSE = Option.valueOf("tcpAbortiveClose");
public static final Option<String> SESSION_VARIABLES = Option.valueOf("sessionVariables");
public static final Option<LoopResources> LOOP_RESOURCES = Option.valueOf("loopResources");
public static final Option<Boolean> ALLOW_PUBLIC_KEY_RETRIEVAL =
Option.valueOf("allowPublicKeyRetrieval");

public static final Option<String> CACHING_RSA_PUBLIC_KEY = Option.valueOf("cachingRsaPublicKey");
public static final Option<String> RSA_PUBLIC_KEY = Option.valueOf("rsaPublicKey");

public static final Option<String> RESTRICTED_AUTH = Option.valueOf("restrictedAuth");

public static final Option<UnaryOperator<SslContextBuilder>> SSL_CONTEXT_BUILDER_CUSTOMIZER =
Option.valueOf("sslContextBuilderCustomizer");
public static final Option<Boolean> SSL_TUNNEL_DISABLE_HOST_VERIFICATION =
Option.valueOf("sslTunnelDisableHostVerification");

static MariadbConnectionConfiguration createConfiguration(
ConnectionFactoryOptions connectionFactoryOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public ClientMessage next(
} else {
if (!configuration.allowPublicKeyRetrieval()) {
throw new R2dbcNonTransientResourceException(
"RSA public key is not available client side (option " + "serverRsaPublicKeyFile)",
"RSA public key is not available client side (option serverRsaPublicKeyFile)",
"S1009");
}
state = State.REQUEST_SERVER_KEY;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/mariadb/r2dbc/client/SimpleClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ protected SimpleClient(
sslContext.newEngine(
connection.channel().alloc(), hostAddress.getHost(), hostAddress.getPort());
SSLParameters sslParameters = engine.getSSLParameters();
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
if (!configuration.getSslConfig().tunnelHostVerificationDisabled()) {
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
}
engine.setSSLParameters(sslParameters);
} else {
engine = sslContext.newEngine(connection.channel().alloc());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public BigDecimal decodeBinary(
return BigDecimal.valueOf((int) buf.readShortLE());

case MEDIUMINT:
if (!column.isSigned()) {
return BigDecimal.valueOf((buf.readUnsignedMediumLE()));
}
return BigDecimal.valueOf(buf.readMediumLE());
BigDecimal v =
BigDecimal.valueOf(column.isSigned() ? buf.readMediumLE() : buf.readUnsignedMediumLE());
buf.readByte(); // needed since binary protocol exchange for medium are on 4 bytes
return v;

case INTEGER:
if (!column.isSigned()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ public BigInteger decodeBinary(
return BigInteger.valueOf((int) buf.readShortLE());

case MEDIUMINT:
if (!column.isSigned()) {
return BigInteger.valueOf((buf.readUnsignedMediumLE()));
}
return BigInteger.valueOf(buf.readMediumLE());
BigInteger v =
BigInteger.valueOf(column.isSigned() ? buf.readMediumLE() : buf.readUnsignedMediumLE());
buf.readByte(); // needed since binary protocol exchange for medium are on 4 bytes
return v;

case INTEGER:
if (!column.isSigned()) {
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/mariadb/r2dbc/codec/list/BooleanCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ public Boolean decodeBinary(
return buf.readShortLE() != 0;

case MEDIUMINT:
return buf.readMediumLE() != 0;
boolean b = buf.readMediumLE() != 0;
buf.readByte(); // needed since binary protocol exchange for medium are on 4 bytes
return b;

case INTEGER:
return buf.readIntLE() != 0;
case BIGINT:
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/mariadb/r2dbc/codec/list/ByteCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public Byte decodeBinary(

case MEDIUMINT:
result = column.isSigned() ? buf.readMediumLE() : buf.readUnsignedMediumLE();
buf.readByte(); // needed since binary protocol exchange for medium are on 4 bytes
break;

case INTEGER:
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/mariadb/r2dbc/codec/list/DoubleCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ public Double decodeBinary(
return (double) buf.readShortLE();

case MEDIUMINT:
if (!column.isSigned()) {
return (double) buf.readUnsignedMediumLE();
}
return (double) buf.readMediumLE();
double v = column.isSigned() ? buf.readMediumLE() : buf.readUnsignedMediumLE();
buf.readByte(); // needed since binary protocol exchange for medium are on 4 bytes
return v;

case INTEGER:
if (!column.isSigned()) {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/mariadb/r2dbc/codec/list/FloatCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ public Float decodeBinary(
return (float) buf.readShortLE();

case MEDIUMINT:
if (!column.isSigned()) {
return (float) buf.readUnsignedMediumLE();
}
return (float) buf.readMediumLE();
float v = column.isSigned() ? buf.readMediumLE() : buf.readUnsignedMediumLE();
buf.readByte(); // needed since binary protocol exchange for medium are on 4 bytes
return v;

case INTEGER:
if (!column.isSigned()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/mariadb/r2dbc/codec/list/IntCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public Integer decodeBinary(

case MEDIUMINT:
result = column.isSigned() ? buf.readMediumLE() : buf.readUnsignedMediumLE();
buf.readByte(); // needed since binary protocol exchange for medium are on 4 bytes
break;

case BIGINT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public LocalDate decodeBinary(
if (length > 4) {
buf.skipBytes(length - 4);
}
if (year == 0 && month == 0 && dayOfMonth == 0) return null;
return LocalDate.of(year, month, dayOfMonth);
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ public LocalDateTime decodeBinary(
microseconds = buf.readUnsignedIntLE();
}
}
if (year == 0
&& month == 0
&& dayOfMonth == 0
&& hour == 0
&& minutes == 0
&& seconds == 0) return null;
} else return null;
break;

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/mariadb/r2dbc/codec/list/LongCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,9 @@ public Long decodeBinary(
return (long) buf.readShortLE();

case MEDIUMINT:
if (!column.isSigned()) {
return (long) buf.readUnsignedMediumLE();
}
return (long) buf.readMediumLE();
long v = column.isSigned() ? buf.readMediumLE() : buf.readUnsignedMediumLE();
buf.readByte(); // needed since binary protocol exchange for medium are on 4 bytes
return v;

case INTEGER:
if (!column.isSigned()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/mariadb/r2dbc/codec/list/ShortCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public Short decodeBinary(

case MEDIUMINT:
result = column.isSigned() ? buf.readMediumLE() : buf.readUnsignedMediumLE();
buf.readByte(); // needed since binary protocol exchange for medium are on 4 bytes
break;

case INTEGER:
Expand Down
Loading

0 comments on commit 4f9385f

Please sign in to comment.