Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ Basic example:
| **`prepareCacheSize`** | if useServerPrepStmts = true, cache the prepared informations in a LRU cache to avoid re-preparation of command. Next use of that command, only prepared identifier and parameters (if any) will be sent to server. This mainly permit for server to avoid reparsing query. | *int* | 256 |
| **`pamOtherPwd`** | Permit to provide additional password for PAM authentication with multiple authentication step. If multiple passwords, value must be URL encoded. | *string* | |
| **`autocommit`** | Set default autocommit value on connection initialization" | *Boolean* | true |
| **`tinyInt1isBit`** | Convert Bit(1)/TINYINT(1) default to boolean type | *boolean* | true |
| **`restrictedAuth`** | if set, restrict authentication plugin to secure list. Default provided plugins are mysql_native_password, mysql_clear_password, client_ed25519, dialog, sha256_password and caching_sha2_password | *string* | |
| **`loopResources`** | permits to share netty EventLoopGroup among multiple async libraries/framework | *LoopResources* | |
| **`sslContextBuilderCustomizer`** | Permits to customized SSL context builder. | *UnaryOperator<SslContextBuilder>* | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public final class MariadbConnectionConfiguration {
private final boolean useServerPrepStmts;
private final Boolean autocommit;
private final boolean permitRedirect;
private final boolean tinyInt1isBit;
private final String[] restrictedAuth;
private final LoopResources loopResources;
private final UnaryOperator<SslContextBuilder> sslContextBuilderCustomizer;
Expand Down Expand Up @@ -89,7 +88,6 @@ private MariadbConnectionConfiguration(
boolean skipPostCommands,
@Nullable Integer prepareCacheSize,
@Nullable CharSequence[] pamOtherPwd,
boolean tinyInt1isBit,
String restrictedAuth,
@Nullable LoopResources loopResources,
@Nullable UnaryOperator<SslContextBuilder> sslContextBuilderCustomizer,
Expand Down Expand Up @@ -137,7 +135,6 @@ private MariadbConnectionConfiguration(
this.autocommit = (autocommit != null) ? autocommit : Boolean.TRUE;
this.permitRedirect = permitRedirect;
this.skipPostCommands = skipPostCommands;
this.tinyInt1isBit = tinyInt1isBit;
this.loopResources = loopResources != null ? loopResources : TcpResources.get();
this.useServerPrepStmts = !this.allowMultiQueries && useServerPrepStmts;
this.sslContextBuilderCustomizer = sslContextBuilderCustomizer;
Expand Down Expand Up @@ -170,7 +167,6 @@ private MariadbConnectionConfiguration(
Boolean autocommit,
boolean permitRedirect,
boolean skipPostCommands,
boolean tinyInt1isBit,
String[] restrictedAuth,
LoopResources loopResources,
UnaryOperator<SslContextBuilder> sslContextBuilderCustomizer) {
Expand Down Expand Up @@ -200,7 +196,6 @@ private MariadbConnectionConfiguration(
this.autocommit = (autocommit != null) ? autocommit : Boolean.TRUE;
this.permitRedirect = permitRedirect;
this.skipPostCommands = skipPostCommands;
this.tinyInt1isBit = tinyInt1isBit;
this.restrictedAuth = restrictedAuth;
this.loopResources = loopResources;
this.sslContextBuilderCustomizer = sslContextBuilderCustomizer;
Expand Down Expand Up @@ -237,7 +232,6 @@ public MariadbConnectionConfiguration redirectConf(
this.autocommit,
this.skipPostCommands,
false,
this.tinyInt1isBit,
this.restrictedAuth,
this.loopResources,
this.sslContextBuilderCustomizer);
Expand Down Expand Up @@ -383,12 +377,6 @@ public static Builder fromOptions(ConnectionFactoryOptions connectionFactoryOpti
MariadbConnectionFactoryProvider.SKIP_POST_COMMANDS)));
}

if (connectionFactoryOptions.hasOption(MariadbConnectionFactoryProvider.TINY_IS_BIT)) {
builder.tinyInt1isBit(
boolValue(
connectionFactoryOptions.getValue(MariadbConnectionFactoryProvider.TINY_IS_BIT)));
}

if (connectionFactoryOptions.hasOption(
MariadbConnectionFactoryProvider.CONNECTION_ATTRIBUTES)) {
String connAttributes =
Expand Down Expand Up @@ -601,10 +589,6 @@ public boolean skipPostCommands() {
return skipPostCommands;
}

public boolean tinyInt1isBit() {
return tinyInt1isBit;
}

public int getPrepareCacheSize() {
return prepareCacheSize;
}
Expand Down Expand Up @@ -816,7 +800,6 @@ public static final class Builder implements Cloneable {
private Boolean autocommit = Boolean.TRUE;
private boolean permitRedirect = true;
private boolean skipPostCommands = false;
private boolean tinyInt1isBit = true;
@Nullable private List<String> tlsProtocol;
@Nullable private String serverSslCert;
@Nullable private String clientSslCert;
Expand Down Expand Up @@ -888,7 +871,6 @@ private MariadbConnectionConfiguration build(boolean checkMandatory) {
this.skipPostCommands,
this.prepareCacheSize,
this.pamOtherPwd,
this.tinyInt1isBit,
this.restrictedAuth,
this.loopResources,
this.sslContextBuilderCustomizer,
Expand Down Expand Up @@ -1199,18 +1181,6 @@ public Builder skipPostCommands(boolean skipPostCommands) {
return this;
}

/**
* Permit to indicate how BIT(1) must return as boolean or byte . Default value True (returns
* boolean).
*
* @param tinyInt1isBit return boolean for BIT(1)
* @return this {@link Builder}
*/
public Builder tinyInt1isBit(boolean tinyInt1isBit) {
this.tinyInt1isBit = tinyInt1isBit;
return this;
}

/**
* Permit pipelining (sending request before resolution of previous one).
*
Expand Down Expand Up @@ -1361,8 +1331,6 @@ public String toString() {
+ sslTunnelDisableHostVerification
+ ", pamOtherPwd="
+ hiddenPamPwd
+ ", tinyInt1isBit="
+ tinyInt1isBit
+ ", autoCommit="
+ autocommit
+ ", permitRedirect="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public final class MariadbConnectionFactoryProvider implements ConnectionFactory
public static final Option<Boolean> AUTO_COMMIT = Option.valueOf("autocommit");
public static final Option<Boolean> PERMIT_REDIRECT = Option.valueOf("permitRedirect");
public static final Option<Boolean> SKIP_POST_COMMANDS = Option.valueOf("skipPostCommands");
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");
public static final Option<Boolean> TRANSACTION_REPLAY = Option.valueOf("transactionReplay");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ public boolean isBinary() {
public MariadbType getType() {
switch (dataType) {
case TINYINT:
// TINYINT(1) are considered as boolean
if (length == 1 && conf.tinyInt1isBit()) return MariadbType.BOOLEAN;
return isSigned() ? MariadbType.TINYINT : MariadbType.UNSIGNED_TINYINT;
case YEAR:
return MariadbType.SMALLINT;
Expand Down Expand Up @@ -235,8 +233,6 @@ public MariadbType getType() {
case DECIMAL:
return MariadbType.DECIMAL;
case BIT:
// BIT(1) are considered as boolean
if (length == 1 && conf.tinyInt1isBit()) return MariadbType.BOOLEAN;
return MariadbType.BIT;
case TINYBLOB:
case MEDIUMBLOB:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void sessionVariablesParsing() {
@Test
void confStringValue() {
String connectionUrl =
"r2dbc:mariadb://admin:pass@localhost:3306/dbname?allowMultiQueries=blabla&autoCommit=1&tinyInt1isBit=0";
"r2dbc:mariadb://admin:pass@localhost:3306/dbname?allowMultiQueries=blabla&autoCommit=1";
ConnectionFactoryOptions options = ConnectionFactoryOptions.parse(connectionUrl);
MariadbConnectionConfiguration.Builder builder =
MariadbConnectionConfiguration.fromOptions(options);
Expand All @@ -357,7 +357,7 @@ void confStringValue() {
+ " allowPipelining=true, useServerPrepStmts=false, timezone=null,"
+ " prepareCacheSize=null, tlsProtocol=null, serverSslCert=null,"
+ " clientSslCert=null, clientSslKey=null, clientSslPassword=null, sslMode=TRUST,"
+ " sslTunnelDisableHostVerification=false, pamOtherPwd=*,*, tinyInt1isBit=false,"
+ " sslTunnelDisableHostVerification=false, pamOtherPwd=*,*,"
+ " autoCommit=true, permitRedirect=true}",
builder.toString());
builder.tlsProtocol((String) null);
Expand All @@ -370,7 +370,7 @@ void confStringValue() {
+ " allowPipelining=true, useServerPrepStmts=false, timezone=null,"
+ " prepareCacheSize=null, tlsProtocol=null, serverSslCert=null,"
+ " clientSslCert=null, clientSslKey=null, clientSslPassword=null, sslMode=TRUST,"
+ " sslTunnelDisableHostVerification=false, pamOtherPwd=*,*, tinyInt1isBit=false,"
+ " sslTunnelDisableHostVerification=false, pamOtherPwd=*,*,"
+ " autoCommit=true, permitRedirect=true}",
builder.toString());
MariadbConnectionConfiguration conf = builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ void defaultValuePrepare() {
}

@Test
void defaultValueNoTiny() throws Throwable {
MariadbConnectionConfiguration conf =
TestConfiguration.defaultBuilder.clone().tinyInt1isBit(false).build();
MariadbConnection connection = new MariadbConnectionFactory(conf).create().block();
void defaultValueNoTiny() {
MariadbConnection connection = new MariadbConnectionFactory(TestConfiguration.defaultBuilder.build()).create().block();
try {
connection
.createStatement("SELECT t1 FROM BitTable2 WHERE 1 = ? ORDER BY t4")
Expand Down Expand Up @@ -109,7 +107,7 @@ private void defaultValue(MariadbConnection connection) {
.execute()
.flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0))))
.as(StepVerifier::create)
.expectNext(Optional.of(Boolean.FALSE), Optional.of(Boolean.TRUE), Optional.empty())
.expectNext(Optional.of(BitSet.valueOf(new byte[] {(byte) 0})), Optional.of(BitSet.valueOf(new byte[] {(byte) 1})), Optional.empty())
.verifyComplete();
}

Expand Down Expand Up @@ -512,7 +510,7 @@ private void meta(MariadbConnection connection) {
.execute()
.flatMap(r -> r.map((row, metadata) -> metadata.getColumnMetadata(0).getType()))
.as(StepVerifier::create)
.expectNextMatches(c -> c.equals(MariadbType.BOOLEAN))
.expectNextMatches(c -> c.equals(MariadbType.BIT))
.verifyComplete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,6 @@ void defaultValuePrepare() {
defaultValue(sharedConnPrepare);
}

@Test
void defaultValueNoTiny() throws Throwable {
MariadbConnectionConfiguration conf =
TestConfiguration.defaultBuilder.clone().tinyInt1isBit(false).build();
MariadbConnection connection = new MariadbConnectionFactory(conf).create().block();
try {
connection
.createStatement("SELECT t1 FROM tinyIntTable1 WHERE 1 = ? ORDER BY t2")
.bind(0, 1)
.execute()
.flatMap(r -> r.map((row, metadata) -> Optional.ofNullable(row.get(0))))
.as(StepVerifier::create)
.expectNext(Optional.of((byte) 0), Optional.of((byte) 1), Optional.empty())
.verifyComplete();
} finally {
connection.close().block();
}
}

private void defaultValue(MariadbConnection connection) {
connection
.createStatement("SELECT t1 FROM tinyIntTable WHERE 1 = ? ORDER BY t2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void builder() {
.allowPublicKeyRetrieval(true)
.useServerPrepStmts(true)
.autocommit(false)
.tinyInt1isBit(false)
.allowPipelining(false)
.allowMultiQueries(false)
.socket("/path/to/mysocket")
Expand All @@ -58,7 +57,7 @@ public void builder() {
.timezone("auto")
.build();
Assertions.assertEquals(
"r2dbc:mariadb:loadbalance://localhost/MyDB?connectTimeout=PT0.15S&tcpKeepAlive=true&tcpAbortiveClose=true&transactionReplay=true&password=***&timezone=auto&pamOtherPwd=otherPwd&prepareCacheSize=125&socket=/path/to/mysocket&username=MyUSer&allowPipelining=false&connectionAttributes=entry1=val1,entry2=val2&sessionVariables=timezone=Europe/Paris&sslMode=trust&serverSslCert=/path/to/serverCert&tlsProtocol=TLSv1.2,TLSv1.3&clientSslKey=clientSecretKey&clientSslPassword=***&sslTunnelDisableHostVerification=true&rsaPublicKey=/path/to/publicRSAKey&cachingRsaPublicKey=cachingRSAPublicKey&allowPublicKeyRetrieval=true&useServerPrepStmts=true&autocommit=false&tinyInt1isBit=false&restrictedAuth=mysql_native_password,client_ed25519",
"r2dbc:mariadb:loadbalance://localhost/MyDB?connectTimeout=PT0.15S&tcpKeepAlive=true&tcpAbortiveClose=true&transactionReplay=true&password=***&timezone=auto&pamOtherPwd=otherPwd&prepareCacheSize=125&socket=/path/to/mysocket&username=MyUSer&allowPipelining=false&connectionAttributes=entry1=val1,entry2=val2&sessionVariables=timezone=Europe/Paris&sslMode=trust&serverSslCert=/path/to/serverCert&tlsProtocol=TLSv1.2,TLSv1.3&clientSslKey=clientSecretKey&clientSslPassword=***&sslTunnelDisableHostVerification=true&rsaPublicKey=/path/to/publicRSAKey&cachingRsaPublicKey=cachingRSAPublicKey&allowPublicKeyRetrieval=true&useServerPrepStmts=true&autocommit=false&restrictedAuth=mysql_native_password,client_ed25519",
conf.toString());
}

Expand Down Expand Up @@ -103,7 +102,6 @@ public void connectionString() {
+ "&allowPublicKeyRetrieval=true"
+ "&useServerPrepStmts=true"
+ "&autocommit=false"
+ "&tinyInt1isBit=false"
+ "&allowPipelining=false"
+ "&allowMultiQueries=true"
+ "&socket=/path/to/mysocket"
Expand Down Expand Up @@ -136,7 +134,6 @@ public void connectionString() {
+ "&cachingRsaPublicKey=cachingRSAPublicKey"
+ "&allowPublicKeyRetrieval=true"
+ "&autocommit=false"
+ "&tinyInt1isBit=false"
+ "&restrictedAuth=mysql_native_password,client_ed25519",
conf.toString());
}
Expand Down Expand Up @@ -176,15 +173,14 @@ public void connectionStringLoadBalance() {
+ "&allowPublicKeyRetrieval=true"
+ "&useServerPrepStmts=true"
+ "&autocommit=false"
+ "&tinyInt1isBit=false"
+ "&allowPipelining=false"
+ "&allowMultiQueries=true"
+ "&socket=/path/to/mysocket"
+ "&sslTunnelDisableHostVerification=true");
MariadbConnectionConfiguration conf =
MariadbConnectionConfiguration.fromOptions(options).build();
Assertions.assertEquals(
"r2dbc:mariadb:loadbalance://localhost/db?connectTimeout=PT0.15S&tcpKeepAlive=true&tcpAbortiveClose=true&transactionReplay=true&password=***&pamOtherPwd=otherPwd&prepareCacheSize=125&socket=/path/to/mysocket&username=ro:ot&allowMultiQueries=true&allowPipelining=false&connectionAttributes=entry1=val1,entry2=val2&sessionVariables=timezone='Europe/Paris'&sslMode=trust&serverSslCert=/path/to/serverCert&tlsProtocol=TLSv1.2,TLSv1.3&clientSslKey=clientSecretKey&clientSslPassword=***&sslTunnelDisableHostVerification=true&rsaPublicKey=/path/to/publicRSAKey&cachingRsaPublicKey=cachingRSAPublicKey&allowPublicKeyRetrieval=true&autocommit=false&tinyInt1isBit=false&restrictedAuth=mysql_native_password,client_ed25519",
"r2dbc:mariadb:loadbalance://localhost/db?connectTimeout=PT0.15S&tcpKeepAlive=true&tcpAbortiveClose=true&transactionReplay=true&password=***&pamOtherPwd=otherPwd&prepareCacheSize=125&socket=/path/to/mysocket&username=ro:ot&allowMultiQueries=true&allowPipelining=false&connectionAttributes=entry1=val1,entry2=val2&sessionVariables=timezone='Europe/Paris'&sslMode=trust&serverSslCert=/path/to/serverCert&tlsProtocol=TLSv1.2,TLSv1.3&clientSslKey=clientSecretKey&clientSslPassword=***&sslTunnelDisableHostVerification=true&rsaPublicKey=/path/to/publicRSAKey&cachingRsaPublicKey=cachingRSAPublicKey&allowPublicKeyRetrieval=true&autocommit=false&restrictedAuth=mysql_native_password,client_ed25519",
conf.toString());
}

Expand Down