Skip to content

Commit e44df55

Browse files
authored
Merge pull request #50049 from joonseolee/feature/mod-prepared-statement-value
Make cachePreparedStatements Optional<Boolean> with database-specific defaults
2 parents de98066 + dab7399 commit e44df55

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public interface DataSourceReactiveRuntimeConfig {
2323
/**
2424
* Whether prepared statements should be cached on the client side.
2525
*/
26-
@WithDefault("false")
27-
boolean cachePreparedStatements();
26+
@ConfigDocDefault("true for PostgreSQL/MySQL/MariaDB/Db2, false otherwise")
27+
Optional<Boolean> cachePreparedStatements();
2828

2929
/**
3030
* The datasource URLs.

extensions/reactive-db2-client/runtime/src/main/java/io/quarkus/reactive/db2/client/runtime/DB2PoolRecorder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
@Recorder
5050
public class DB2PoolRecorder {
5151

52+
private static final boolean SUPPORTS_CACHE_PREPARED_STATEMENTS = true;
53+
5254
private static final Logger log = Logger.getLogger(DB2PoolRecorder.class);
5355
private static final TypeLiteral<Instance<DB2PoolCreator>> POOL_CREATOR_TYPE_LITERAL = new TypeLiteral<>() {
5456
};
@@ -221,7 +223,8 @@ private DB2ConnectOptions toConnectOptions(String dataSourceName, DataSourceRunt
221223
}
222224
}
223225

224-
connectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements());
226+
connectOptions.setCachePreparedStatements(
227+
dataSourceReactiveRuntimeConfig.cachePreparedStatements().orElse(SUPPORTS_CACHE_PREPARED_STATEMENTS));
225228

226229
connectOptions.setSsl(dataSourceReactiveDB2Config.ssl());
227230

extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
@Recorder
5151
public class MySQLPoolRecorder {
5252

53+
private static final boolean SUPPORTS_CACHE_PREPARED_STATEMENTS = true;
54+
5355
private static final TypeLiteral<Instance<MySQLPoolCreator>> POOL_CREATOR_TYPE_LITERAL = new TypeLiteral<>() {
5456
};
5557

@@ -224,7 +226,9 @@ private List<MySQLConnectOptions> toMySQLConnectOptions(String dataSourceName,
224226
}
225227
}
226228

227-
mysqlConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements());
229+
mysqlConnectOptions
230+
.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements()
231+
.orElse(SUPPORTS_CACHE_PREPARED_STATEMENTS));
228232

229233
dataSourceReactiveMySQLConfig.charset().ifPresent(mysqlConnectOptions::setCharset);
230234
dataSourceReactiveMySQLConfig.collation().ifPresent(mysqlConnectOptions::setCollation);

extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
@Recorder
5050
public class PgPoolRecorder {
5151

52+
private static final boolean SUPPORTS_CACHE_PREPARED_STATEMENTS = true;
53+
5254
private static final TypeLiteral<Instance<PgPoolCreator>> PG_POOL_CREATOR_TYPE_LITERAL = new TypeLiteral<>() {
5355
};
5456

@@ -215,7 +217,8 @@ private List<PgConnectOptions> toPgConnectOptions(String dataSourceName, DataSou
215217
}
216218
}
217219

218-
pgConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements());
220+
pgConnectOptions.setCachePreparedStatements(
221+
dataSourceReactiveRuntimeConfig.cachePreparedStatements().orElse(SUPPORTS_CACHE_PREPARED_STATEMENTS));
219222

220223
if (dataSourceReactivePostgreSQLConfig.pipeliningLimit().isPresent()) {
221224
pgConnectOptions.setPipeliningLimit(dataSourceReactivePostgreSQLConfig.pipeliningLimit().getAsInt());

0 commit comments

Comments
 (0)