Repository: quarkusio/quarkus
Issue: Reactive datasource config: cache-prepared-statements is not specific to any DB

`cache-prepared-statements` config attribute is duplicated in MySQL and Postgres configs.

It should be a common attribute of any Reactive SQL client.

Changed files:
extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java
extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java
extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java
extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/LegacyDataSourceReactiveMySQLConfig.java
extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java
extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/LegacyDataSourceReactivePostgreSQLConfig.java
extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/DataSourceReactiveMySQLConfig.java

diff --git a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java
index b9092a94050..709d06a23dc 100644
--- a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java
+++ b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java
@@ -17,6 +17,12 @@
 @ConfigRoot(name = "datasource.reactive", phase = ConfigPhase.RUN_TIME)
 public class DataSourceReactiveRuntimeConfig {
 
+    /**
+     * Whether prepared statements should be cached on the client side.
+     */
+    @ConfigItem(defaultValue = "false")
+    public boolean cachePreparedStatements;
+
     /**
      * The datasource URL.
      */
diff --git a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/DataSourceReactiveMySQLConfig.java b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/DataSourceReactiveMySQLConfig.java
index 6f3bd3688a3..e109c2f5818 100644
--- a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/DataSourceReactiveMySQLConfig.java
+++ b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/DataSourceReactiveMySQLConfig.java
@@ -12,8 +12,11 @@ public class DataSourceReactiveMySQLConfig {
 
     /**
      * Whether prepared statements should be cached on the client side.
+     *
+     * @deprecated use {@code datasource.reactive.cache-prepared-statements} instead.
      */
     @ConfigItem
+    @Deprecated
     public Optional<Boolean> cachePreparedStatements;
 
     /**
diff --git a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/LegacyDataSourceReactiveMySQLConfig.java b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/LegacyDataSourceReactiveMySQLConfig.java
index b103aaacd8b..d13c790e97b 100644
--- a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/LegacyDataSourceReactiveMySQLConfig.java
+++ b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/LegacyDataSourceReactiveMySQLConfig.java
@@ -11,21 +11,21 @@
 public class LegacyDataSourceReactiveMySQLConfig {
 
     /**
-     * @deprecated use quarkus.datasource.reactive.mysql.cache-prepared-statements instead.
+     * @deprecated use {@code quarkus.datasource.reactive.cache-prepared-statements} instead.
      */
     @ConfigItem
     @Deprecated
     public Optional<Boolean> cachePreparedStatements;
 
     /**
-     * @deprecated use quarkus.datasource.reactive.mysql.charset instead.
+     * @deprecated use {@code quarkus.datasource.reactive.mysql.charset} instead.
      */
     @ConfigItem
     @Deprecated
     public Optional<String> charset;
 
     /**
-     * @deprecated use quarkus.datasource.reactive.mysql.collation instead.
+     * @deprecated use {@code quarkus.datasource.reactive.mysql.collation} instead.
      */
     @ConfigItem
     @Deprecated
diff --git a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java
index d0926fda274..a9bd9517455 100644
--- a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java
+++ b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java
@@ -11,6 +11,8 @@
 
 import java.util.Map;
 
+import org.jboss.logging.Logger;
+
 import io.quarkus.arc.runtime.BeanContainer;
 import io.quarkus.credentials.CredentialsProvider;
 import io.quarkus.credentials.runtime.CredentialsProviderFinder;
@@ -30,6 +32,9 @@
 @Recorder
 @SuppressWarnings("deprecation")
 public class MySQLPoolRecorder {
+
+    private static final Logger log = Logger.getLogger(MySQLPoolRecorder.class);
+
     public RuntimeValue<MySQLPool> configureMySQLPool(RuntimeValue<Vertx> vertx, BeanContainer container,
             DataSourcesRuntimeConfig dataSourcesRuntimeConfig,
             DataSourceReactiveRuntimeConfig dataSourceReactiveRuntimeConfig,
@@ -119,8 +124,12 @@ private MySQLConnectOptions toMySQLConnectOptions(DataSourceRuntimeConfig dataSo
         }
 
         if (dataSourceReactiveMySQLConfig.cachePreparedStatements.isPresent()) {
+            log.warn("datasource.reactive.mysql.cache-prepared-statements is deprecated, use datasource.reactive.cache-prepared-statements instead");
             mysqlConnectOptions.setCachePreparedStatements(dataSourceReactiveMySQLConfig.cachePreparedStatements.get());
+        } else {
+            mysqlConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements);
         }
+
         if (dataSourceReactiveMySQLConfig.charset.isPresent()) {
             mysqlConnectOptions.setCharset(dataSourceReactiveMySQLConfig.charset.get());
         }
diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java
index a1748ff6ec0..b1dd120d5a8 100644
--- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java
+++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java
@@ -13,8 +13,11 @@ public class DataSourceReactivePostgreSQLConfig {
 
     /**
      * Whether prepared statements should be cached on the client side.
+     * 
+     * @deprecated use {@code datasource.reactive.cache-prepared-statements} instead.
      */
     @ConfigItem
+    @Deprecated
     public Optional<Boolean> cachePreparedStatements;
 
     /**
diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/LegacyDataSourceReactivePostgreSQLConfig.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/LegacyDataSourceReactivePostgreSQLConfig.java
index cbfe8787bcd..e28965a7d64 100644
--- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/LegacyDataSourceReactivePostgreSQLConfig.java
+++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/LegacyDataSourceReactivePostgreSQLConfig.java
@@ -12,14 +12,14 @@
 public class LegacyDataSourceReactivePostgreSQLConfig {
 
     /**
-     * @deprecated use quarkus.datasource.reactive.postgresql.cache-prepared-statements instead.
+     * @deprecated use {@code quarkus.datasource.reactive.cache-prepared-statements} instead.
      */
     @ConfigItem
     @Deprecated
     public Optional<Boolean> cachePreparedStatements;
 
     /**
-     * @deprecated use quarkus.datasource.reactive.postgresql.pipelining-limit instead.
+     * @deprecated use {@code quarkus.datasource.reactive.postgresql.pipelining-limit} instead.
      */
     @ConfigItem
     @Deprecated
diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java
index b6adc5c95c2..6dc0df3e29e 100644
--- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java
+++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java
@@ -11,6 +11,8 @@
 
 import java.util.Map;
 
+import org.jboss.logging.Logger;
+
 import io.quarkus.arc.runtime.BeanContainer;
 import io.quarkus.credentials.CredentialsProvider;
 import io.quarkus.credentials.runtime.CredentialsProviderFinder;
@@ -31,6 +33,8 @@
 @SuppressWarnings("deprecation")
 public class PgPoolRecorder {
 
+    private static final Logger log = Logger.getLogger(PgPoolRecorder.class);
+
     public RuntimeValue<PgPool> configurePgPool(RuntimeValue<Vertx> vertx, BeanContainer container,
             DataSourcesRuntimeConfig dataSourcesRuntimeConfig,
             DataSourceReactiveRuntimeConfig dataSourceReactiveRuntimeConfig,
@@ -121,8 +125,12 @@ private PgConnectOptions toPgConnectOptions(DataSourceRuntimeConfig dataSourceRu
         }
 
         if (dataSourceReactivePostgreSQLConfig.cachePreparedStatements.isPresent()) {
+            log.warn("datasource.reactive.postgresql.cache-prepared-statements is deprecated, use datasource.reactive.cache-prepared-statements instead");
             pgConnectOptions.setCachePreparedStatements(dataSourceReactivePostgreSQLConfig.cachePreparedStatements.get());
+        } else {
+            pgConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements);
         }
+
         if (dataSourceReactivePostgreSQLConfig.pipeliningLimit.isPresent()) {
             pgConnectOptions.setPipeliningLimit(dataSourceReactivePostgreSQLConfig.pipeliningLimit.getAsInt());
         }