pg.ddx.io aws/aws-advanced-jdbc-wrapper GitHub issues and pull requests
help / color / mirror / Atom feed[aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection
10+ messages / 2 participants
[nested] [flat]
* [aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection
@ 2026-11-13 21:35 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
0 siblings, 0 replies; 10+ messages in thread
From: sergiyvamz (@sergiyvamz) @ 2026-11-13 21:35 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
## Summary
Replaces the ordered candidate probing in `DialectManager` with a fingerprint-based detector. On the first connection the wrapper now runs one error-free catalog statement per engine family (`pg_catalog` for PostgreSQL; `SHOW VARIABLES` + `information_schema` for MySQL/MariaDB), plus at most one follow-up for Aurora Global Database (region count) or an RDS Multi-AZ DB cluster, and maps the result to a dialect code with a pure decision table (`DialectDetector.resolve`).
## Why
- An Aurora PG cluster endpoint already guessed `AURORA_PG` still ran 7 statements and one server error (`schema "rds_tools" does not exist`) just to keep its guess. Aurora MySQL: 6. Community PG: 6 plus an error. Now 1-3 statements and no errors used as signals.
- The result depended on the endpoint form. `RdsMysqlDialect` listed `AURORA_MYSQL` before `GLOBAL_AURORA_MYSQL` and the Aurora probe is true on a global cluster, so a Global Aurora MySQL cluster via an instance endpoint, RDS Proxy or custom domain resolved to `AURORA_MYSQL`; via its cluster endpoint to `GLOBAL_AURORA_MYSQL`. `MariaDbDialect` had no global candidate at all. The fingerprint is now the single source of truth regardless of URL or protocol.
- Markers were string coincidences (`version_comment = 'Source distribution'`, `rds.extensions LIKE '%aurora_stat_utils%'`). The fingerprint checks for the documented objects (`aurora_version`, `rds.extensions` GUC, `mysql.rds_*` objects, `rds_tools` functions) and keeps the old markers only as fallbacks.
- The endpoint cache was keyed by the full URL string and wrote a second `host:port/` key that was never read. It is now keyed by `host:port`, so the same host with different parameters or database name hits the cache.
## Changes
- New `DialectFingerprint` (immutable observations) and `DialectDetector` (collect + resolve).
- `DialectManager`: phase 2 uses the detector; phase 1 unchanged except the cache key. The provisional dialect is kept when no fingerprint can be collected (logged at `FINE`); `UNKNOWN` still throws.
- `Dialect.isDialect` / `getDialectUpdateCandidates` deprecated, not removed, so custom dialects keep compiling. The per-dialect probe queries stay for them.
- Docs: a short "How the dialect is detected" section.
## Testing
- `DialectDetectorTests`: the decision table row by row, the collectors (which statements run for each deployment, failure handling), family selection from driver metadata.
- `DialectDetectionTests` rewritten end-to-end through `PluginServiceImpl`, pinning the resolved dialect and the round-trip count for every modelled server reached through `localhost`, an instance endpoint and a cluster endpoint, for both the MySQL and MariaDB protocols.
- `checkstyleMain/Test`, `compileJava -PenableCheckerFramework`, and the near-full unit suite (1855 tests) pass locally.
## Open points before leaving draft
Verify against live engines: `rds_tools.multi_az_db_cluster_source_dbi_resource_id()` on Aurora PG; `information_schema.aurora_global_db_status` absence on Aurora MySQL 2.x; `report_host` on a Multi-AZ MySQL cluster during reader replacement; catalog statements through RDS Proxy. Not in this PR: cache invalidation on failover / Blue-Green events, and a per-`Properties` custom dialect resolver to replace the static `Driver.setCustomDialect`.
inline patch 1: docs/using-the-jdbc-driver/DatabaseDialects.md, wrapper/src/main/java/software/amazon/jdbc/dialect/Dialect.java, wrapper/src/main/java/software/amazon/jdbc/dialect/DialectDetector.java and 5 more (+1383/-290 lines) download inline-1.patch
diff --git a/docs/using-the-jdbc-driver/DatabaseDialects.md b/docs/using-the-jdbc-driver/DatabaseDialects.md
index 6ce71c951c..b0b0bb5a1d 100644
--- a/docs/using-the-jdbc-driver/DatabaseDialects.md
+++ b/docs/using-the-jdbc-driver/DatabaseDialects.md
@@ -12,6 +12,15 @@ The AWS Advanced JDBC Wrapper is a wrapper that requires an underlying driver, a
>
> The `wrapperDialect` parameter is not required. When it is not provided by the user, the AWS Advanced JDBC Wrapper will attempt to determine which of the existing dialects to use based on other connection details. However, if the dialect is known by the user, it is preferable to set the `wrapperDialect` parameter because it will take time to resolve the dialect.
+### How the dialect is detected
+
+When `wrapperDialect` is not set, detection happens in two steps.
+
+1. Before connecting, the wrapper picks a provisional dialect from the driver protocol and the shape of the hostname. Aurora Global Database writer endpoints (`.global-`) and Aurora Limitless endpoints (`.shardgrp-`) are definitive; every other hostname only narrows the choice to an engine family. The provisional dialect supplies the default port and connection properties.
+2. On the first connection, the wrapper collects a fingerprint of the server with one catalog statement per engine family (`pg_catalog` for PostgreSQL; `SHOW VARIABLES` and `information_schema` for MySQL and MariaDB), plus at most one follow-up for Aurora Global Database (region count) or an RDS Multi-AZ DB cluster. The fingerprint, not the hostname or the protocol, decides the dialect, so an Aurora cluster behind a custom domain, an RDS Proxy, or an instance endpoint resolves to the same dialect as through its cluster endpoint. Every statement is valid on any server of its family, so detection does not raise errors on the server.
+
+The resolved dialect is cached per host for 24 hours, so later connections to the same host skip step 2. The fingerprint and the resolved dialect are logged at `FINEST` by `software.amazon.jdbc.dialect.DialectManager`.
+
### List of Available Dialect Codes
Dialect codes specify what kind of database any connections will be made to.
diff --git a/wrapper/src/main/java/software/amazon/jdbc/dialect/Dialect.java b/wrapper/src/main/java/software/amazon/jdbc/dialect/Dialect.java
index 20f1854282..295f894fcc 100644
--- a/wrapper/src/main/java/software/amazon/jdbc/dialect/Dialect.java
+++ b/wrapper/src/main/java/software/amazon/jdbc/dialect/Dialect.java
@@ -32,10 +32,24 @@
public interface Dialect {
+ /**
+ * Checks whether the connected server matches this dialect by running probe queries.
+ *
+ * @deprecated Dialect detection no longer probes candidates one by one; it collects a
+ * {@link DialectFingerprint} and resolves it with {@link DialectDetector#resolve}. Kept so
+ * that existing custom dialects keep compiling; the wrapper does not call it.
+ */
+ @Deprecated
boolean isDialect(Connection connection);
int getDefaultPort();
+ /**
+ * Lists the dialects that detection should try after this one.
+ *
+ * @deprecated See {@link #isDialect(Connection)}; the wrapper does not call it.
+ */
+ @Deprecated
@Nullable List</* dialect code */ String> getDialectUpdateCandidates();
ExceptionHandler getExceptionHandler();
diff --git a/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectDetector.java b/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectDetector.java
new file mode 100644
index 0000000000..1c5ca55deb
--- /dev/null
+++ b/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectDetector.java
@@ -0,0 +1,323 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package software.amazon.jdbc.dialect;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.logging.Logger;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import software.amazon.jdbc.dialect.DialectFingerprint.Family;
+import software.amazon.jdbc.util.Messages;
+import software.amazon.jdbc.util.StringUtils;
+
+/**
+ * Identifies the database dialect of a live connection in two steps: collect a
+ * {@link DialectFingerprint} with one error-free statement per engine family (plus at most one
+ * follow-up for data-dependent deployments), then map the fingerprint to a dialect code with a
+ * pure decision table in {@link #resolve(DialectFingerprint)}.
+ *
+ * <p>Every statement is written so that it succeeds on any server of its family, regardless of
+ * deployment. Detection therefore never relies on a server error as a signal and never leaves
+ * error entries in the server log.
+ */
+public class DialectDetector {
+
+ private static final Logger LOGGER = Logger.getLogger(DialectDetector.class.getName());
+
+ // --- PostgreSQL family ---
+
+ private static String pgProcExists(final String schema, final String... names) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("EXISTS (SELECT 1 FROM pg_catalog.pg_proc p")
+ .append(" JOIN pg_catalog.pg_namespace n ON n.oid OPERATOR(pg_catalog.=) p.pronamespace")
+ .append(" WHERE n.nspname OPERATOR(pg_catalog.=) '").append(schema).append("'")
+ .append(" AND (");
+ for (int i = 0; i < names.length; i++) {
+ if (i > 0) {
+ sb.append(" OR ");
+ }
+ sb.append("p.proname OPERATOR(pg_catalog.=) '").append(names[i]).append("'");
+ }
+ sb.append("))");
+ return sb.toString();
+ }
+
+ /**
+ * Single statement that reports the presence of each deployment-specific object. Valid on any
+ * PostgreSQL-compatible server because it only reads {@code pg_catalog}.
+ */
+ protected static final String PG_FINGERPRINT_QUERY = "SELECT "
+ + pgProcExists("pg_catalog", "aurora_version", "aurora_replica_status") + " AS aurora, "
+ + pgProcExists("pg_catalog", "aurora_limitless_router_endpoints") + " AS limitless, "
+ + pgProcExists("pg_catalog", "aurora_global_db_status") + " AS global_db_capable, "
+ + pgProcExists("rds_tools", "multi_az_db_cluster_source_dbi_resource_id") + " AS multi_az_capable, "
+ + "EXISTS (SELECT 1 FROM pg_catalog.pg_settings WHERE name OPERATOR(pg_catalog.=) 'rds.extensions') AS rds, "
+ + "pg_catalog.current_setting('server_version') AS server_version";
+
+ // --- MySQL family ---
+
+ /**
+ * Returns one row per variable that exists; a variable unknown to the server is simply absent,
+ * so the statement never fails on community MySQL, MariaDB, RDS or Aurora.
+ */
+ protected static final String MYSQL_VARIABLES_QUERY =
+ "SHOW VARIABLES WHERE Variable_name IN ('version', 'version_comment', 'aurora_version', 'report_host')";
+
+ /** Presence of RDS- and Aurora-installed catalog objects, from information_schema only. */
+ protected static final String MYSQL_CATALOG_QUERY = "SELECT"
+ + " (SELECT COUNT(*) FROM information_schema.tables"
+ + " WHERE table_schema = 'mysql' AND table_name = 'rds_topology') AS rds_topology,"
+ + " (SELECT COUNT(*) FROM information_schema.routines"
+ + " WHERE routine_schema = 'mysql' AND routine_name = 'rds_set_configuration') AS rds_routines,"
+ + " (SELECT COUNT(*) FROM information_schema.tables"
+ + " WHERE upper(table_schema) = 'INFORMATION_SCHEMA'"
+ + " AND upper(table_name) = 'AURORA_GLOBAL_DB_STATUS') AS global_db_status";
+
+ private static final String RDS_MYSQL_VERSION_COMMENT = "Source distribution";
+
+ /**
+ * Maps a provisional dialect code (derived from the URL before connecting) to the engine family
+ * whose fingerprint statements should be used.
+ */
+ public static Family familyOf(final @Nullable String dialectCode) {
+ if (dialectCode == null) {
+ return Family.UNKNOWN;
+ }
+ switch (dialectCode) {
+ case DialectCodes.PG:
+ case DialectCodes.RDS_PG:
+ case DialectCodes.RDS_MULTI_AZ_PG_CLUSTER:
+ case DialectCodes.AURORA_PG:
+ case DialectCodes.GLOBAL_AURORA_PG:
+ return Family.PG;
+ case DialectCodes.MYSQL:
+ case DialectCodes.RDS_MYSQL:
+ case DialectCodes.RDS_MULTI_AZ_MYSQL_CLUSTER:
+ case DialectCodes.AURORA_MYSQL:
+ case DialectCodes.GLOBAL_AURORA_MYSQL:
+ case DialectCodes.MARIADB:
+ return Family.MYSQL;
+ default:
+ return Family.UNKNOWN;
+ }
+ }
+
+ /**
+ * Determines the engine family without a round trip, from the target driver's product name
+ * (every supported target driver answers from a constant or from handshake data).
+ */
+ public Family familyFromMetadata(final Connection connection) {
+ try {
+ final String product = connection.getMetaData().getDatabaseProductName();
+ if (product == null) {
+ return Family.UNKNOWN;
+ }
+ final String lower = product.toLowerCase(Locale.ROOT);
+ if (lower.contains("postgres")) {
+ return Family.PG;
+ }
+ if (lower.contains("mysql") || lower.contains("mariadb")) {
+ return Family.MYSQL;
+ }
+ } catch (final SQLException | RuntimeException ex) {
+ LOGGER.finest(() -> Messages.get("DialectDetector.productNameUnavailable", new Object[] {ex.getMessage()}));
+ }
+ return Family.UNKNOWN;
+ }
+
+ /**
+ * Collects the fingerprint of the connected server.
+ *
+ * @param connection an open connection to the server
+ * @param familyHint the family suggested by the URL and protocol; {@link Family#UNKNOWN} lets
+ * the detector find out from driver metadata and, failing that, by trying
+ * each family in turn
+ * @return the fingerprint, or null if no family's fingerprint statement could be executed
+ */
+ public @Nullable DialectFingerprint collect(final @NonNull Connection connection, final Family familyHint) {
+ Family family = familyHint;
+ if (family == Family.UNKNOWN) {
+ family = this.familyFromMetadata(connection);
+ }
+
+ switch (family) {
+ case PG:
+ return this.collectPg(connection);
+ case MYSQL:
+ return this.collectMysql(connection);
+ default:
+ final DialectFingerprint pg = this.collectPg(connection);
+ return pg != null ? pg : this.collectMysql(connection);
+ }
+ }
+
+ /**
+ * Pure decision table: maps a fingerprint to a dialect code. Has no side effects and runs no
+ * SQL, so every row of the table can be verified by a unit test without a database.
+ */
+ public static String resolve(final @NonNull DialectFingerprint fp) {
+ switch (fp.getFamily()) {
+ case PG:
+ if (fp.isAurora() || fp.isLimitless()) {
+ return fp.getGlobalDbRegionCount() > 1 ? DialectCodes.GLOBAL_AURORA_PG : DialectCodes.AURORA_PG;
+ }
+ if (fp.isRds()) {
+ return fp.isMultiAzCluster() ? DialectCodes.RDS_MULTI_AZ_PG_CLUSTER : DialectCodes.RDS_PG;
+ }
+ return DialectCodes.PG;
+
+ case MYSQL:
+ if (fp.isMariaDb()) {
+ return DialectCodes.MARIADB;
+ }
+ if (fp.isAurora()) {
+ return fp.getGlobalDbRegionCount() > 1 ? DialectCodes.GLOBAL_AURORA_MYSQL : DialectCodes.AURORA_MYSQL;
+ }
+ if (fp.isRds()) {
+ return fp.isMultiAzCluster() ? DialectCodes.RDS_MULTI_AZ_MYSQL_CLUSTER : DialectCodes.RDS_MYSQL;
+ }
+ return DialectCodes.MYSQL;
+
+ default:
+ return DialectCodes.UNKNOWN;
+ }
+ }
+
+ protected @Nullable DialectFingerprint collectPg(final Connection connection) {
+ final DialectFingerprint.Builder b = DialectFingerprint.builder(Family.PG);
+ final boolean aurora;
+ final boolean rds;
+ final boolean globalDbCapable;
+ final boolean multiAzCapable;
+ try (Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery(PG_FINGERPRINT_QUERY)) {
+ if (!rs.next()) {
+ return null;
+ }
+ aurora = rs.getBoolean("aurora");
+ rds = rs.getBoolean("rds");
+ globalDbCapable = rs.getBoolean("global_db_capable");
+ multiAzCapable = rs.getBoolean("multi_az_capable");
+ b.aurora(aurora)
+ .limitless(rs.getBoolean("limitless"))
+ .globalDbCapable(globalDbCapable)
+ .multiAzClusterCapable(multiAzCapable)
+ .rds(rds)
+ .serverVersion(rs.getString("server_version"));
+ } catch (final SQLException ex) {
+ LOGGER.finest(() -> Messages.get("DialectDetector.fingerprintFailed", new Object[] {Family.PG, ex.getMessage()}));
+ return null;
+ }
+
+ if (aurora && globalDbCapable) {
+ b.globalDbRegionCount(this.queryInt(connection, GlobalAuroraPgDialect.REGION_COUNT_QUERY));
+ }
+ if (!aurora && rds && multiAzCapable) {
+ b.multiAzCluster(this.queryStringIsPresent(connection, MultiAzClusterPgDialect.IS_RDS_CLUSTER_QUERY));
+ }
+ return b.build();
+ }
+
+ protected @Nullable DialectFingerprint collectMysql(final Connection connection) {
+ final Map<String, @Nullable String> vars = new HashMap<>();
+ try (Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery(MYSQL_VARIABLES_QUERY)) {
+ while (rs.next()) {
+ final String name = rs.getString(1);
+ if (name != null) {
+ vars.put(name.toLowerCase(Locale.ROOT), rs.getString(2));
+ }
+ }
+ } catch (final SQLException ex) {
+ LOGGER.finest(() ->
+ Messages.get("DialectDetector.fingerprintFailed", new Object[] {Family.MYSQL, ex.getMessage()}));
+ return null;
+ }
+
+ final String version = vars.get("version");
+ final String versionComment = vars.get("version_comment");
+ final boolean aurora = vars.containsKey("aurora_version");
+ final boolean mariaDb = containsIgnoreCase(version, "mariadb") || containsIgnoreCase(versionComment, "mariadb");
+ final boolean reportHostSet = !StringUtils.isNullOrEmpty(vars.get("report_host"));
+
+ int rdsTopology = 0;
+ int rdsRoutines = 0;
+ int globalDbStatus = 0;
+ try (Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery(MYSQL_CATALOG_QUERY)) {
+ if (rs.next()) {
+ rdsTopology = rs.getInt("rds_topology");
+ rdsRoutines = rs.getInt("rds_routines");
+ globalDbStatus = rs.getInt("global_db_status");
+ }
+ } catch (final SQLException ex) {
+ // The variables alone still identify MariaDB, Aurora and community MySQL; only the RDS
+ // catalog markers are lost, and the version comment below still covers RDS MySQL.
+ LOGGER.finest(() -> Messages.get("DialectDetector.catalogFailed", new Object[] {ex.getMessage()}));
+ }
+
+ final boolean rds = rdsRoutines > 0 || rdsTopology > 0
+ || RDS_MYSQL_VERSION_COMMENT.equalsIgnoreCase(versionComment);
+ final boolean globalDbCapable = globalDbStatus > 0;
+
+ final DialectFingerprint.Builder b = DialectFingerprint.builder(Family.MYSQL)
+ .serverVersion(version)
+ .mariaDb(mariaDb)
+ .aurora(aurora)
+ .globalDbCapable(globalDbCapable)
+ .rds(rds)
+ .multiAzClusterCapable(rdsTopology > 0)
+ .multiAzCluster(!aurora && rdsTopology > 0 && reportHostSet);
+
+ if (aurora && !mariaDb && globalDbCapable) {
+ b.globalDbRegionCount(this.queryInt(connection, GlobalAuroraMysqlDialect.REGION_COUNT_QUERY));
+ }
+ return b.build();
+ }
+
+ private int queryInt(final Connection connection, final String query) {
+ try (Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery(query)) {
+ if (rs.next()) {
+ return rs.getInt(1);
+ }
+ } catch (final SQLException ex) {
+ LOGGER.finest(() -> Messages.get("DialectDetector.followUpFailed", new Object[] {query, ex.getMessage()}));
+ }
+ return DialectFingerprint.REGION_COUNT_NOT_QUERIED;
+ }
+
+ private boolean queryStringIsPresent(final Connection connection, final String query) {
+ try (Statement stmt = connection.createStatement();
+ ResultSet rs = stmt.executeQuery(query)) {
+ return rs.next() && rs.getString(1) != null;
+ } catch (final SQLException ex) {
+ LOGGER.finest(() -> Messages.get("DialectDetector.followUpFailed", new Object[] {query, ex.getMessage()}));
+ return false;
+ }
+ }
+
+ private static boolean containsIgnoreCase(final @Nullable String value, final String needle) {
+ return value != null && value.toLowerCase(Locale.ROOT).contains(needle);
+ }
+}
diff --git a/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectFingerprint.java b/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectFingerprint.java
new file mode 100644
index 0000000000..6790f4cdaf
--- /dev/null
+++ b/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectFingerprint.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package software.amazon.jdbc.dialect;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * Immutable set of server-side facts collected from a single connection, from which the
+ * database dialect is derived. Every field is an observation (an object exists, a variable has a
+ * value), never a conclusion; the conclusion is drawn by {@link DialectDetector#resolve}.
+ */
+public final class DialectFingerprint {
+
+ /** Engine family. Selects which fingerprint queries are run and which decision table applies. */
+ public enum Family {
+ PG,
+ MYSQL,
+ UNKNOWN
+ }
+
+ /** Value of {@link #getGlobalDbRegionCount()} when the region count was not queried. */
+ public static final int REGION_COUNT_NOT_QUERIED = -1;
+
+ private final Family family;
+ private final @Nullable String serverVersion;
+ private final boolean mariaDb;
+ private final boolean aurora;
+ private final boolean limitless;
+ private final boolean globalDbCapable;
+ private final int globalDbRegionCount;
+ private final boolean rds;
+ private final boolean multiAzClusterCapable;
+ private final boolean multiAzCluster;
+
+ private DialectFingerprint(final Builder b) {
+ this.family = b.family;
+ this.serverVersion = b.serverVersion;
+ this.mariaDb = b.mariaDb;
+ this.aurora = b.aurora;
+ this.limitless = b.limitless;
+ this.globalDbCapable = b.globalDbCapable;
+ this.globalDbRegionCount = b.globalDbRegionCount;
+ this.rds = b.rds;
+ this.multiAzClusterCapable = b.multiAzClusterCapable;
+ this.multiAzCluster = b.multiAzCluster;
+ }
+
+ public static Builder builder(final Family family) {
+ return new Builder(family);
+ }
+
+ public Family getFamily() {
+ return this.family;
+ }
+
+ /** Server version string as reported by the engine, or null if not collected. */
+ public @Nullable String getServerVersion() {
+ return this.serverVersion;
+ }
+
+ /** The server version identifies itself as MariaDB. */
+ public boolean isMariaDb() {
+ return this.mariaDb;
+ }
+
+ /** An Aurora-only object exists ({@code aurora_version} variable or function). */
+ public boolean isAurora() {
+ return this.aurora;
+ }
+
+ /** The Aurora Limitless router function exists. */
+ public boolean isLimitless() {
+ return this.limitless;
+ }
+
+ /** The Aurora Global Database status object exists (true on every recent Aurora engine). */
+ public boolean isGlobalDbCapable() {
+ return this.globalDbCapable;
+ }
+
+ /** Number of regions reported by the global database status, or {@link #REGION_COUNT_NOT_QUERIED}. */
+ public int getGlobalDbRegionCount() {
+ return this.globalDbRegionCount;
+ }
+
+ /** An RDS-installed object exists ({@code rds.*} GUC, {@code mysql.rds_*} objects). */
+ public boolean isRds() {
+ return this.rds;
+ }
+
+ /** The object used to confirm a Multi-AZ DB cluster exists, so the confirmation was attempted. */
+ public boolean isMultiAzClusterCapable() {
+ return this.multiAzClusterCapable;
+ }
+
+ /** The Multi-AZ DB cluster confirmation succeeded. */
+ public boolean isMultiAzCluster() {
+ return this.multiAzCluster;
+ }
+
+ @Override
+ public String toString() {
+ return "DialectFingerprint["
+ + "family=" + this.family
+ + ", serverVersion=" + this.serverVersion
+ + ", mariaDb=" + this.mariaDb
+ + ", aurora=" + this.aurora
+ + ", limitless=" + this.limitless
+ + ", globalDbCapable=" + this.globalDbCapable
+ + ", globalDbRegionCount=" + this.globalDbRegionCount
+ + ", rds=" + this.rds
+ + ", multiAzClusterCapable=" + this.multiAzClusterCapable
+ + ", multiAzCluster=" + this.multiAzCluster
+ + "]";
+ }
+
+ public static final class Builder {
+ private final Family family;
+ private @Nullable String serverVersion;
+ private boolean mariaDb;
+ private boolean aurora;
+ private boolean limitless;
+ private boolean globalDbCapable;
+ private int globalDbRegionCount = REGION_COUNT_NOT_QUERIED;
+ private boolean rds;
+ private boolean multiAzClusterCapable;
+ private boolean multiAzCluster;
+
+ private Builder(final Family family) {
+ this.family = family;
+ }
+
+ public Builder serverVersion(final @Nullable String value) {
+ this.serverVersion = value;
+ return this;
+ }
+
+ public Builder mariaDb(final boolean value) {
+ this.mariaDb = value;
+ return this;
+ }
+
+ public Builder aurora(final boolean value) {
+ this.aurora = value;
+ return this;
+ }
+
+ public Builder limitless(final boolean value) {
+ this.limitless = value;
+ return this;
+ }
+
+ public Builder globalDbCapable(final boolean value) {
+ this.globalDbCapable = value;
+ return this;
+ }
+
+ public Builder globalDbRegionCount(final int value) {
+ this.globalDbRegionCount = value;
+ return this;
+ }
+
+ public Builder rds(final boolean value) {
+ this.rds = value;
+ return this;
+ }
+
+ public Builder multiAzClusterCapable(final boolean value) {
+ this.multiAzClusterCapable = value;
+ return this;
+ }
+
+ public Builder multiAzCluster(final boolean value) {
+ this.multiAzCluster = value;
+ return this;
+ }
+
+ public DialectFingerprint build() {
+ return new DialectFingerprint(this);
+ }
+ }
+}
diff --git a/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectManager.java b/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectManager.java
index 3bac1dd8d9..6d959443fc 100644
--- a/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectManager.java
+++ b/wrapper/src/main/java/software/amazon/jdbc/dialect/DialectManager.java
@@ -76,11 +76,12 @@ public class DialectManager implements DialectProvider {
*/
protected static final long ENDPOINT_CACHE_EXPIRATION = TimeUnit.HOURS.toNanos(24);
- // Keys are host names or URLs, values are dialect codes.
+ // Keys are "host" or "host:port" of the endpoint the application connects to; values are dialect codes.
protected static final CacheMap<String, String> knownEndpointDialects = new CacheMap<>();
private final RdsUtils rdsHelper = new RdsUtils();
private final ConnectionUrlParser connectionUrlParser = new ConnectionUrlParser();
+ private final DialectDetector dialectDetector;
private boolean canUpdate = false;
private @Nullable Dialect dialect = null;
private String dialectCode;
@@ -93,7 +94,12 @@ public class DialectManager implements DialectProvider {
}
public DialectManager(PluginService pluginService) {
+ this(pluginService, new DialectDetector());
+ }
+
+ public DialectManager(PluginService pluginService, DialectDetector dialectDetector) {
this.pluginService = pluginService;
+ this.dialectDetector = dialectDetector;
}
public static void resetEndpointCache() {
@@ -125,21 +131,8 @@ public Dialect getDialect(
}
final String userDialectSetting = DIALECT.getString(props);
- final String dialectCode = !StringUtils.isNullOrEmpty(userDialectSetting)
- ? userDialectSetting
- : knownEndpointDialects.get(url);
-
- if (!StringUtils.isNullOrEmpty(dialectCode)) {
- final Dialect userDialect = knownDialectsByCode.get(dialectCode);
- if (userDialect != null) {
- this.dialectCode = dialectCode;
- this.dialect = userDialect;
- this.confirmed = true;
- this.logCurrentDialect();
- return userDialect;
- } else {
- throw new SQLException(Messages.get("DialectManager.unknownDialectCode", new Object[] {dialectCode}));
- }
+ if (!StringUtils.isNullOrEmpty(userDialectSetting)) {
+ return this.useKnownDialect(userDialectSetting);
}
if (StringUtils.isNullOrEmpty(driverProtocol)) {
@@ -147,10 +140,17 @@ public Dialect getDialect(
}
String host = url;
+ String cacheKey = url;
final List<HostSpec> hosts = this.connectionUrlParser.getHostsFromConnectionUrl(
url, true, pluginService::getHostSpecBuilder);
if (!Utils.isNullOrEmpty(hosts)) {
host = hosts.get(0).getHost();
+ cacheKey = hosts.get(0).getHostAndPort();
+ }
+
+ final String cachedDialectCode = knownEndpointDialects.get(cacheKey);
+ if (!StringUtils.isNullOrEmpty(cachedDialectCode)) {
+ return this.useKnownDialect(cachedDialectCode);
}
if (driverProtocol.contains("mysql")) {
@@ -267,41 +267,47 @@ public Dialect getDialect(
throw new SQLException(Messages.get("DialectManager.unknownDialect"));
}
- final @Nullable List<String> dialectCandidates = currentDialect.getDialectUpdateCandidates();
- if (dialectCandidates != null) {
- for (String dialectCandidateCode : dialectCandidates) {
- Dialect dialectCandidate = knownDialectsByCode.get(dialectCandidateCode);
- if (dialectCandidate == null) {
- throw new SQLException(Messages.get(
- "DialectManager.unknownDialectCode", new Object[] {dialectCandidateCode}));
- }
-
- boolean isDialect = dialectCandidate.isDialect(connection);
- if (isDialect) {
- this.canUpdate = false;
- this.dialectCode = dialectCandidateCode;
- this.dialect = dialectCandidate;
-
- knownEndpointDialects.put(originalUrl, dialectCandidateCode, ENDPOINT_CACHE_EXPIRATION);
- knownEndpointDialects.put(hostSpec.getUrl(), dialectCandidateCode, ENDPOINT_CACHE_EXPIRATION);
+ // The provisional dialect only narrows the search to an engine family. The fingerprint of the
+ // connected server is the single source of truth for the deployment type.
+ final String provisionalCode = this.dialectCode;
+ final DialectFingerprint fingerprint =
+ this.dialectDetector.collect(connection, DialectDetector.familyOf(provisionalCode));
- this.logCurrentDialect();
- return dialectCandidate;
- }
- }
+ final String fingerprintCode = fingerprint == null ? null : DialectDetector.resolve(fingerprint);
+ if (fingerprint != null) {
+ LOGGER.finest(() -> Messages.get("DialectManager.fingerprint", new Object[] {fingerprint, fingerprintCode}));
}
- if (DialectCodes.UNKNOWN.equals(this.dialectCode)) {
- throw new SQLException(Messages.get("DialectManager.unknownDialect"));
+ final String resolvedCode;
+ if (fingerprintCode == null || DialectCodes.UNKNOWN.equals(fingerprintCode)) {
+ if (DialectCodes.UNKNOWN.equals(provisionalCode)) {
+ throw new SQLException(Messages.get("DialectManager.unknownDialect"));
+ }
+ LOGGER.fine(() -> Messages.get("DialectManager.fingerprintUnavailable", new Object[] {provisionalCode}));
+ resolvedCode = provisionalCode;
+ } else {
+ resolvedCode = fingerprintCode;
}
+ final Dialect resolved = getDialectByCode(resolvedCode);
this.canUpdate = false;
+ this.confirmed = true;
+ this.dialectCode = resolvedCode;
+ this.dialect = resolved;
+
+ knownEndpointDialects.put(hostSpec.getHostAndPort(), resolvedCode, ENDPOINT_CACHE_EXPIRATION);
- knownEndpointDialects.put(originalUrl, this.dialectCode, ENDPOINT_CACHE_EXPIRATION);
- knownEndpointDialects.put(hostSpec.getUrl(), this.dialectCode, ENDPOINT_CACHE_EXPIRATION);
+ this.logCurrentDialect();
+ return resolved;
+ }
+ private Dialect useKnownDialect(final String dialectCode) throws SQLException {
+ final Dialect known = getDialectByCode(dialectCode);
+ this.dialectCode = dialectCode;
+ this.dialect = known;
+ this.confirmed = true;
this.logCurrentDialect();
- return currentDialect;
+ return known;
}
private static @NonNull Dialect getDialectByCode(final String dialectCode) throws SQLException {
diff --git a/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties b/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties
index 4e2a1c1538..3058239f5e 100644
--- a/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties
+++ b/wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties
@@ -273,7 +273,14 @@ CacheMonitor.telemetryGaugesInitialized=Telemetry gauges initialized: consecutiv
# Default Connection Plugin
DefaultConnectionPlugin.executingMethod=Executing method: ''{0}''
+DialectDetector.productNameUnavailable=Database product name is not available from the driver metadata: {0}
+DialectDetector.fingerprintFailed=Dialect fingerprint statement for the {0} family failed: {1}
+DialectDetector.catalogFailed=Dialect catalog statement failed; continuing with server variables only: {0}
+DialectDetector.followUpFailed=Dialect follow-up query ''{0}'' failed: {1}
+
DialectManager.currentDialect=Current dialect: {0}, {1}, canUpdate: {2}, confirmed: {3}
+DialectManager.fingerprint=Dialect fingerprint {0} resolved to dialect ''{1}''.
+DialectManager.fingerprintUnavailable=Dialect fingerprint could not be collected; keeping the provisional dialect ''{0}''.
Driver.nullUrl=Url is null.
Driver.alreadyRegistered=Driver is already registered. It can only be registered once.
diff --git a/wrapper/src/test/java/software/amazon/jdbc/DialectDetectionTests.java b/wrapper/src/test/java/software/amazon/jdbc/DialectDetectionTests.java
index 805eea14ae..eb077c73ae 100644
--- a/wrapper/src/test/java/software/amazon/jdbc/DialectDetectionTests.java
+++ b/wrapper/src/test/java/software/amazon/jdbc/DialectDetectionTests.java
@@ -17,20 +17,28 @@
package software.amazon.jdbc;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.sql.Connection;
+import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Properties;
import java.util.stream.Stream;
import org.junit.jupiter.api.AfterEach;
@@ -45,6 +53,8 @@
import software.amazon.jdbc.dialect.AuroraPgDialect;
import software.amazon.jdbc.dialect.Dialect;
import software.amazon.jdbc.dialect.DialectManager;
+import software.amazon.jdbc.dialect.GlobalAuroraMysqlDialect;
+import software.amazon.jdbc.dialect.GlobalAuroraPgDialect;
import software.amazon.jdbc.dialect.MariaDbDialect;
import software.amazon.jdbc.dialect.MultiAzClusterMysqlDialect;
import software.amazon.jdbc.dialect.MultiAzClusterPgDialect;
@@ -58,6 +68,12 @@
import software.amazon.jdbc.util.FullServicesContainer;
import software.amazon.jdbc.util.storage.StorageService;
+/**
+ * End-to-end dialect detection through {@link PluginServiceImpl}: the URL-based provisional
+ * dialect, then the fingerprint-based confirmation on the first connection, then the endpoint cache.
+ * The statements the detector runs are stubbed by their text, so these tests also pin the number of
+ * round trips each deployment costs.
+ */
public class DialectDetectionTests {
private static final String LOCALHOST = "localhost";
private static final String RDS_DATABASE = "database-1.xyz.us-east-2.rds.amazonaws.com";
@@ -65,6 +81,7 @@ public class DialectDetectionTests {
private static final String MYSQL_PROTOCOL = "jdbc:mysql://";
private static final String PG_PROTOCOL = "jdbc:postgresql://";
private static final String MARIA_PROTOCOL = "jdbc:mariadb://";
+ private static final String UNKNOWN_PROTOCOL = "jdbc:something://";
private final Properties props = new Properties();
private AutoCloseable closeable;
@Mock private FullServicesContainer mockServicesContainer;
@@ -72,6 +89,7 @@ public class DialectDetectionTests {
@Mock private StorageService mockStorageService;
@Mock private Connection mockConnection;
@Mock private Statement mockStatement;
+ @Mock private DatabaseMetaData mockMetaData;
@Mock private HostSpec mockHost;
@Mock private ConnectionPluginManager mockPluginManager;
@Mock private TargetDriverDialect mockTargetDriverDialect;
@@ -83,8 +101,9 @@ void setUp() throws SQLException {
when(this.mockServicesContainer.getConnectionPluginManager()).thenReturn(mockPluginManager);
when(this.mockServicesContainer.getStorageService()).thenReturn(mockStorageService);
when(this.mockConnection.createStatement()).thenReturn(this.mockStatement);
- when(this.mockHost.getUrl()).thenReturn("url");
+ when(this.mockConnection.getMetaData()).thenReturn(this.mockMetaData);
mockPluginManager.plugins = new ArrayList<>();
+ DialectManager.resetEndpointCache();
}
@AfterEach
@@ -94,12 +113,16 @@ void cleanUp() throws Exception {
}
PluginServiceImpl getPluginService(String host, String protocol) throws SQLException {
+ return getPluginService(host, protocol, "");
+ }
+
+ PluginServiceImpl getPluginService(String host, String protocol, String urlSuffix) throws SQLException {
PluginServiceImpl pluginService = spy(
new PluginServiceImpl(
mockServicesContainer,
new ExceptionManager(),
props,
- protocol + host,
+ protocol + host + urlSuffix,
protocol,
null,
mockTargetDriverDialect,
@@ -107,11 +130,14 @@ PluginServiceImpl getPluginService(String host, String protocol) throws SQLExcep
null));
when(this.mockServicesContainer.getHostListProviderService()).thenReturn(pluginService);
+ when(this.mockServicesContainer.getPluginService()).thenReturn(pluginService);
doNothing().when(pluginService).updateHostListProvider();
+ when(this.mockHost.getHostAndPort()).thenReturn(host);
+ pluginService.setInitialConnectionHostSpec(mockHost);
return pluginService;
}
- // --- Initial dialect detection tests ---
+ // --- Initial (provisional) dialect from protocol + URL ---
@ParameterizedTest
@MethodSource("getInitialDialectArguments")
@@ -135,295 +161,274 @@ static Stream<Arguments> getInitialDialectArguments() {
);
}
- // --- MySQL dialect update tests ---
+ // --- MySQL family: the resolved dialect follows the server, not the URL or the protocol ---
- @Test
- void testUpdateDialectMysqlUnchanged() throws SQLException {
- // All candidate isDialect checks fail -> dialect stays as MysqlDialect.
- // MysqlDialect candidates: GLOBAL_AURORA_MYSQL, AURORA_MYSQL, RDS_MULTI_AZ_MYSQL_CLUSTER, RDS_MYSQL
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
+ @ParameterizedTest(name = "{0} + {1}")
+ @MethodSource("getMysqlFamilyArguments")
+ void testMysqlFamilyDetection(
+ String protocol, String host, MysqlServer server, Class<?> expectedDialect, int expectedRoundTrips)
+ throws SQLException {
+ stubMysqlServer(server);
- final PluginServiceImpl target = getPluginService(LOCALHOST, MYSQL_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
+ final PluginServiceImpl target = getPluginService(host, protocol);
target.updateDialect(mockConnection);
- assertEquals(MysqlDialect.class, target.dialect.getClass());
+
+ assertEquals(expectedDialect, target.dialect.getClass());
+ verify(mockStatement, times(expectedRoundTrips)).executeQuery(anyString());
}
- @Test
- void testUpdateDialectMysqlToAurora() throws SQLException {
- // MysqlDialect candidates: GLOBAL_AURORA_MYSQL, AURORA_MYSQL, RDS_MULTI_AZ_MYSQL_CLUSTER, RDS_MYSQL
- // GlobalAuroraMysqlDialect.isDialect: checkExistenceQueries for global tables -> fails (default).
- // AuroraMysqlDialect.isDialect: checkExistenceQueries("SHOW VARIABLES LIKE 'aurora_version'") -> returns row.
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> createMockResultSet(true)).when(mockStatement)
- .executeQuery(eq("SHOW VARIABLES LIKE 'aurora_version'"));
-
- final PluginServiceImpl target = getPluginService(LOCALHOST, MYSQL_PROTOCOL);
- when(mockServicesContainer.getPluginService()).thenReturn(target);
- target.setInitialConnectionHostSpec(mockHost);
- target.updateDialect(mockConnection);
- assertEquals(AuroraMysqlDialect.class, target.dialect.getClass());
+ static Stream<Arguments> getMysqlFamilyArguments() {
+ final Stream.Builder<Arguments> b = Stream.builder();
+ for (final String protocol : new String[] {MYSQL_PROTOCOL, MARIA_PROTOCOL}) {
+ b.add(Arguments.of(protocol, LOCALHOST, MysqlServer.COMMUNITY, MysqlDialect.class, 2));
+ b.add(Arguments.of(protocol, LOCALHOST, MysqlServer.MARIADB, MariaDbDialect.class, 2));
+ b.add(Arguments.of(protocol, LOCALHOST, MysqlServer.RDS, RdsMysqlDialect.class, 2));
+ b.add(Arguments.of(protocol, LOCALHOST, MysqlServer.MULTI_AZ_CLUSTER, MultiAzClusterMysqlDialect.class, 2));
+ b.add(Arguments.of(protocol, LOCALHOST, MysqlServer.AURORA, AuroraMysqlDialect.class, 3));
+ b.add(Arguments.of(protocol, LOCALHOST, MysqlServer.GLOBAL_AURORA, GlobalAuroraMysqlDialect.class, 3));
+ // Same cluster, reached through an instance endpoint: the result must not change.
+ b.add(Arguments.of(protocol, RDS_DATABASE, MysqlServer.GLOBAL_AURORA, GlobalAuroraMysqlDialect.class, 3));
+ b.add(Arguments.of(protocol, RDS_DATABASE, MysqlServer.AURORA, AuroraMysqlDialect.class, 3));
+ // A cluster endpoint that turns out to be a Multi-AZ DB cluster rather than Aurora.
+ b.add(Arguments.of(
+ protocol, RDS_AURORA_DATABASE, MysqlServer.MULTI_AZ_CLUSTER, MultiAzClusterMysqlDialect.class, 2));
+ }
+ return b.build();
}
- @Test
- void testUpdateDialectMysqlToMultiAz() throws SQLException {
- // MysqlDialect candidates: GLOBAL_AURORA_MYSQL, AURORA_MYSQL, RDS_MULTI_AZ_MYSQL_CLUSTER, RDS_MYSQL
- // GlobalAuroraMysqlDialect and AuroraMysqlDialect fail (default).
- // MultiAzClusterMysqlDialect.isDialect:
- // 1. checkExistenceQueries(TOPOLOGY_TABLE_EXISTS_QUERY, TOPOLOGY_QUERY) -> both return rows
- // 2. SHOW VARIABLES LIKE 'report_host' -> returns non-empty value (IP address)
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> createMockResultSet(true)).when(mockStatement).executeQuery(eq(
- "SELECT 1 AS tmp FROM information_schema.tables WHERE"
- + " table_schema = 'mysql' AND table_name = 'rds_topology'"));
- doAnswer(invocation -> createMockResultSet(true)).when(mockStatement).executeQuery(eq(
- "SELECT id, endpoint, port FROM mysql.rds_topology"));
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getString(2)).thenReturn("10.0.0.1");
- return rs;
- }).when(mockStatement).executeQuery(eq("SHOW VARIABLES LIKE 'report_host'"));
+ // --- PostgreSQL family ---
- final PluginServiceImpl target = getPluginService(LOCALHOST, MYSQL_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("getPgFamilyArguments")
+ void testPgFamilyDetection(String host, PgServer server, Class<?> expectedDialect, int expectedRoundTrips)
+ throws SQLException {
+ stubPgServer(server);
+
+ final PluginServiceImpl target = getPluginService(host, PG_PROTOCOL);
target.updateDialect(mockConnection);
- assertEquals(MultiAzClusterMysqlDialect.class, target.dialect.getClass());
- }
- @Test
- void testUpdateDialectMysqlToRds() throws SQLException {
- // MysqlDialect candidates: GLOBAL_AURORA_MYSQL, AURORA_MYSQL, RDS_MULTI_AZ_MYSQL_CLUSTER, RDS_MYSQL
- // All earlier candidates fail.
- // RdsMysqlDialect.isDialect:
- // 1. super.isDialect (MysqlDialect): VERSION_QUERY -> "Source distribution" (not "mysql") -> returns false
- // 2. RdsMysqlDialect's own check: VERSION_QUERY -> "Source distribution" -> matches
- // 3. REPORT_HOST_EXISTS_QUERY -> returns a row with empty string for column 2
- // Note: VERSION_QUERY is called twice (by super and by RdsMysqlDialect), so we use doAnswer.
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getString(2)).thenReturn("Source distribution");
- return rs;
- }).when(mockStatement).executeQuery(eq("SHOW VARIABLES LIKE 'version_comment'"));
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getString(2)).thenReturn("");
- return rs;
- }).when(mockStatement).executeQuery(eq("SHOW VARIABLES LIKE 'report_host'"));
+ assertEquals(expectedDialect, target.dialect.getClass());
+ verify(mockStatement, times(expectedRoundTrips)).executeQuery(anyString());
+ }
- final PluginServiceImpl target = getPluginService(LOCALHOST, MYSQL_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
- target.updateDialect(mockConnection);
- assertEquals(RdsMysqlDialect.class, target.dialect.getClass());
+ static Stream<Arguments> getPgFamilyArguments() {
+ return Stream.of(
+ Arguments.of(LOCALHOST, PgServer.COMMUNITY, PgDialect.class, 1),
+ Arguments.of(LOCALHOST, PgServer.RDS, RdsPgDialect.class, 2),
+ Arguments.of(LOCALHOST, PgServer.MULTI_AZ_CLUSTER, MultiAzClusterPgDialect.class, 2),
+ Arguments.of(LOCALHOST, PgServer.AURORA, AuroraPgDialect.class, 2),
+ Arguments.of(LOCALHOST, PgServer.GLOBAL_AURORA, GlobalAuroraPgDialect.class, 2),
+ Arguments.of(RDS_DATABASE, PgServer.GLOBAL_AURORA, GlobalAuroraPgDialect.class, 2),
+ Arguments.of(RDS_AURORA_DATABASE, PgServer.AURORA, AuroraPgDialect.class, 2),
+ Arguments.of(RDS_AURORA_DATABASE, PgServer.MULTI_AZ_CLUSTER, MultiAzClusterPgDialect.class, 2),
+ Arguments.of(RDS_AURORA_DATABASE, PgServer.RDS, RdsPgDialect.class, 2)
+ );
}
- // --- PostgreSQL dialect update tests ---
+ // --- Unknown protocol ---
@Test
- void testUpdateDialectPgUnchanged() throws SQLException {
- // All candidate isDialect checks fail -> dialect stays as PgDialect.
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
+ void testUnknownProtocolResolvesFromDriverMetadata() throws SQLException {
+ when(mockMetaData.getDatabaseProductName()).thenReturn("PostgreSQL");
+ stubPgServer(PgServer.AURORA);
- final PluginServiceImpl target = getPluginService(LOCALHOST, PG_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
+ final PluginServiceImpl target = getPluginService(LOCALHOST, UNKNOWN_PROTOCOL);
target.updateDialect(mockConnection);
- assertEquals(PgDialect.class, target.dialect.getClass());
- }
- @Test
- void testUpdateDialectPgToAurora() throws SQLException {
- // PgDialect candidates: GLOBAL_AURORA_PG, AURORA_PG, RDS_MULTI_AZ_PG_CLUSTER, RDS_PG
- // GlobalAuroraPgDialect.isDialect: checks aurora_stat_utils (succeeds), then global funcs -> fails.
- // AuroraPgDialect.isDialect:
- // 1. super.isDialect (PgDialect): SELECT 1 FROM pg_catalog.pg_proc LIMIT 1 -> returns row
- // 2. AURORA_UTILS_EXIST_QUERY -> returns row with aurora_stat_utils = true
- // 3. TOPOLOGY_EXISTS_QUERY -> returns row
- // Note: Both GlobalAuroraPgDialect and AuroraPgDialect query AURORA_UTILS_EXIST_QUERY,
- // so we need to return fresh ResultSets each time.
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> createMockResultSet(true)).when(mockStatement).executeQuery(eq(
- "SELECT 1 FROM pg_catalog.pg_proc LIMIT 1"));
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getBoolean("aurora_stat_utils")).thenReturn(true);
- return rs;
- }).when(mockStatement).executeQuery(eq(
- "SELECT (setting OPERATOR(pg_catalog.~~) '%aurora_stat_utils%') AS aurora_stat_utils "
- + "FROM pg_catalog.pg_settings "
- + "WHERE name OPERATOR(pg_catalog.=) 'rds.extensions'"));
- doAnswer(invocation -> createMockResultSet(true)).when(mockStatement).executeQuery(eq(
- "SELECT 1 FROM pg_catalog.aurora_replica_status() LIMIT 1"));
-
- final PluginServiceImpl target = getPluginService(LOCALHOST, PG_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
- target.updateDialect(mockConnection);
assertEquals(AuroraPgDialect.class, target.dialect.getClass());
}
@Test
- void testUpdateDialectPgToMultiAz() throws SQLException {
- // PgDialect candidates: GLOBAL_AURORA_PG, AURORA_PG, RDS_MULTI_AZ_PG_CLUSTER, RDS_PG
- // GlobalAuroraPgDialect and AuroraPgDialect fail.
- // MultiAzClusterPgDialect.isDialect:
- // SELECT multi_az_db_cluster_source_dbi_resource_id FROM
- // rds_tools.multi_az_db_cluster_source_dbi_resource_id()
- // -> returns a row with non-null string
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getString(1)).thenReturn("db-ABCDEF123456");
- return rs;
- }).when(mockStatement).executeQuery(eq(
- "SELECT multi_az_db_cluster_source_dbi_resource_id FROM "
- + "rds_tools.multi_az_db_cluster_source_dbi_resource_id()"));
-
- final PluginServiceImpl target = getPluginService(LOCALHOST, PG_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
- target.updateDialect(mockConnection);
- assertEquals(MultiAzClusterPgDialect.class, target.dialect.getClass());
- }
+ void testUnknownProtocolWithoutFingerprintThrows() throws SQLException {
+ doThrow(new SQLException("not supported")).when(mockStatement).executeQuery(anyString());
- @Test
- void testUpdateDialectPgToRds() throws SQLException {
- // PgDialect candidates: GLOBAL_AURORA_PG, AURORA_PG, RDS_MULTI_AZ_PG_CLUSTER, RDS_PG
- // GlobalAuroraPgDialect and AuroraPgDialect fail (aurora_stat_utils query throws for Global,
- // and for Aurora the pg_proc check may succeed but aurora_utils or topology fails).
- // RdsPgDialect.isDialect:
- // 1. super.isDialect (PgDialect): SELECT 1 FROM pg_catalog.pg_proc LIMIT 1 -> returns row
- // 2. EXTENSIONS_EXIST_SQL -> returns row with rds_tools=true, aurora_stat_utils=false
- // Note: pg_proc query may be called multiple times by different candidates.
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> createMockResultSet(true)).when(mockStatement).executeQuery(eq(
- "SELECT 1 FROM pg_catalog.pg_proc LIMIT 1"));
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getBoolean("rds_tools")).thenReturn(true);
- when(rs.getBoolean("aurora_stat_utils")).thenReturn(false);
- return rs;
- }).when(mockStatement).executeQuery(eq(
- "SELECT (setting OPERATOR(pg_catalog.~~) '%rds_tools%') AS rds_tools, "
- + "(setting OPERATOR(pg_catalog.~~) '%aurora_stat_utils%') AS aurora_stat_utils "
- + "FROM pg_catalog.pg_settings "
- + "WHERE name OPERATOR(pg_catalog.=) 'rds.extensions'"));
-
- final PluginServiceImpl target = getPluginService(LOCALHOST, PG_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
- target.updateDialect(mockConnection);
- assertEquals(RdsPgDialect.class, target.dialect.getClass());
+ final PluginServiceImpl target = getPluginService(LOCALHOST, UNKNOWN_PROTOCOL);
+ assertThrows(SQLException.class, () -> target.updateDialect(mockConnection));
}
- // --- MariaDB dialect update tests ---
+ // --- Fingerprint unavailable: the provisional dialect is kept ---
@Test
- void testUpdateDialectMariaUnchanged() throws SQLException {
- // All candidate isDialect checks fail -> dialect stays as MariaDbDialect.
- // MariaDbDialect candidates: AURORA_MYSQL, RDS_MULTI_AZ_MYSQL_CLUSTER, RDS_MYSQL, MYSQL
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
+ void testFingerprintFailureKeepsProvisionalDialect() throws SQLException {
+ doThrow(new SQLException("permission denied")).when(mockStatement).executeQuery(anyString());
- final PluginServiceImpl target = getPluginService(LOCALHOST, MARIA_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
+ final PluginServiceImpl target = getPluginService(RDS_AURORA_DATABASE, PG_PROTOCOL);
target.updateDialect(mockConnection);
- assertEquals(MariaDbDialect.class, target.dialect.getClass());
- }
- @Test
- void testUpdateDialectMariaToMysqlAurora() throws SQLException {
- // MariaDbDialect candidates: AURORA_MYSQL, RDS_MULTI_AZ_MYSQL_CLUSTER, RDS_MYSQL, MYSQL
- // AuroraMysqlDialect.isDialect: SHOW VARIABLES LIKE 'aurora_version' -> returns a row.
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> createMockResultSet(true)).when(mockStatement)
- .executeQuery(eq("SHOW VARIABLES LIKE 'aurora_version'"));
-
- final PluginServiceImpl target = getPluginService(LOCALHOST, MARIA_PROTOCOL);
- when(mockServicesContainer.getPluginService()).thenReturn(target);
- target.setInitialConnectionHostSpec(mockHost);
- target.updateDialect(mockConnection);
- assertEquals(AuroraMysqlDialect.class, target.dialect.getClass());
+ assertEquals(AuroraPgDialect.class, target.dialect.getClass());
+ assertTrue(target.isDialectConfirmed());
}
- @Test
- void testUpdateDialectMariaToMysqlMultiAz() throws SQLException {
- // MariaDbDialect candidates: AURORA_MYSQL, RDS_MULTI_AZ_MYSQL_CLUSTER, RDS_MYSQL, MYSQL
- // AuroraMysqlDialect.isDialect fails.
- // MultiAzClusterMysqlDialect.isDialect:
- // 1. checkExistenceQueries(TOPOLOGY_TABLE_EXISTS_QUERY, TOPOLOGY_QUERY) -> both return rows
- // 2. SHOW VARIABLES LIKE 'report_host' -> returns non-empty value
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> createMockResultSet(true)).when(mockStatement).executeQuery(eq(
- "SELECT 1 AS tmp FROM information_schema.tables WHERE"
- + " table_schema = 'mysql' AND table_name = 'rds_topology'"));
- doAnswer(invocation -> createMockResultSet(true)).when(mockStatement).executeQuery(eq(
- "SELECT id, endpoint, port FROM mysql.rds_topology"));
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getString(2)).thenReturn("10.0.0.1");
- return rs;
- }).when(mockStatement).executeQuery(eq("SHOW VARIABLES LIKE 'report_host'"));
+ // --- Endpoint cache ---
- final PluginServiceImpl target = getPluginService(LOCALHOST, MARIA_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
- target.updateDialect(mockConnection);
- assertEquals(MultiAzClusterMysqlDialect.class, target.dialect.getClass());
+ @Test
+ void testResolvedDialectIsCachedByHost() throws SQLException {
+ stubMysqlServer(MysqlServer.AURORA);
+ final PluginServiceImpl first = getPluginService(LOCALHOST, MYSQL_PROTOCOL);
+ first.updateDialect(mockConnection);
+ assertEquals(AuroraMysqlDialect.class, first.dialect.getClass());
+
+ // Same host, different URL parameters: no further statements, dialect confirmed up front.
+ final Connection unusedConnection = mock(Connection.class);
+ final PluginServiceImpl second = getPluginService(LOCALHOST, MYSQL_PROTOCOL, "/other_db?param=1");
+ assertEquals(AuroraMysqlDialect.class, second.dialect.getClass());
+ assertTrue(second.isDialectConfirmed());
+ second.updateDialect(unusedConnection);
+ verify(unusedConnection, never()).createStatement();
}
@Test
- void testUpdateDialectMariaToMysqlRds() throws SQLException {
- // MariaDbDialect candidates: AURORA_MYSQL, RDS_MULTI_AZ_MYSQL_CLUSTER, RDS_MYSQL, MYSQL
- // AuroraMysqlDialect and MultiAzClusterMysqlDialect fail.
- // RdsMysqlDialect.isDialect:
- // 1. super.isDialect (MysqlDialect) must return false
- // 2. VERSION_QUERY returns "Source distribution"
- // 3. REPORT_HOST_EXISTS_QUERY returns a row with empty string
- // Note: VERSION_QUERY is called twice (by super and by RdsMysqlDialect).
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getString(2)).thenReturn("Source distribution");
- return rs;
- }).when(mockStatement).executeQuery(eq("SHOW VARIABLES LIKE 'version_comment'"));
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getString(2)).thenReturn("");
- return rs;
- }).when(mockStatement).executeQuery(eq("SHOW VARIABLES LIKE 'report_host'"));
+ void testCacheIsPerHost() throws SQLException {
+ stubMysqlServer(MysqlServer.AURORA);
+ getPluginService(LOCALHOST, MYSQL_PROTOCOL).updateDialect(mockConnection);
- final PluginServiceImpl target = getPluginService(LOCALHOST, MARIA_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
- target.updateDialect(mockConnection);
- assertEquals(RdsMysqlDialect.class, target.dialect.getClass());
+ final PluginServiceImpl other = getPluginService(RDS_DATABASE, MYSQL_PROTOCOL);
+ assertEquals(RdsMysqlDialect.class, other.dialect.getClass());
}
- @Test
- void testUpdateDialectMariaToMysql() throws SQLException {
- // MariaDbDialect candidates: AURORA_MYSQL, RDS_MULTI_AZ_MYSQL_CLUSTER, RDS_MYSQL, MYSQL
- // All earlier candidates fail.
- // MysqlDialect.isDialect: SHOW VARIABLES LIKE 'version_comment' -> returns "MySQL Community Server (GPL)"
- doThrow(new SQLException("not found")).when(mockStatement).executeQuery(any());
- doAnswer(invocation -> {
- ResultSet rs = createMockResultSet(true);
- when(rs.getString(2)).thenReturn("MySQL Community Server (GPL)");
- return rs;
- }).when(mockStatement).executeQuery(eq("SHOW VARIABLES LIKE 'version_comment'"));
+ // --- Server models and statement stubs ---
- final PluginServiceImpl target = getPluginService(LOCALHOST, MARIA_PROTOCOL);
- target.setInitialConnectionHostSpec(mockHost);
- target.updateDialect(mockConnection);
- assertEquals(MysqlDialect.class, target.dialect.getClass());
- }
+ enum MysqlServer { COMMUNITY, MARIADB, RDS, MULTI_AZ_CLUSTER, AURORA, GLOBAL_AURORA }
- // --- Helper methods ---
+ enum PgServer { COMMUNITY, RDS, MULTI_AZ_CLUSTER, AURORA, GLOBAL_AURORA }
/**
- * Creates a mock ResultSet that returns the specified value on the first call to next(),
- * then returns false on subsequent calls.
+ * Routes each statement the detector may run to the answer the modelled server would give.
+ * Anything else fails, as it would on a real server of the other family.
*/
- private ResultSet createMockResultSet(boolean hasRows) throws SQLException {
- ResultSet rs = mock(ResultSet.class);
- if (hasRows) {
- when(rs.next()).thenReturn(true, false);
- } else {
- when(rs.next()).thenReturn(false);
+ private void stubMysqlServer(final MysqlServer server) throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ final int topology;
+ final int routines;
+ final int globalTable;
+ final int regions;
+ switch (server) {
+ case MARIADB:
+ vars.put("version", "10.11.6-MariaDB-log");
+ vars.put("version_comment", "mariadb.org binary distribution");
+ topology = 0;
+ routines = 0;
+ globalTable = 0;
+ regions = 0;
+ break;
+ case RDS:
+ vars.put("version", "8.0.35");
+ vars.put("version_comment", "Source distribution");
+ vars.put("report_host", "");
+ topology = 1;
+ routines = 1;
+ globalTable = 0;
+ regions = 0;
+ break;
+ case MULTI_AZ_CLUSTER:
+ vars.put("version", "8.0.35");
+ vars.put("version_comment", "Source distribution");
+ vars.put("report_host", "10.0.0.1");
+ topology = 1;
+ routines = 1;
+ globalTable = 0;
+ regions = 0;
+ break;
+ case AURORA:
+ vars.put("version", "8.0.32");
+ vars.put("version_comment", "Source distribution");
+ vars.put("aurora_version", "3.05.2");
+ vars.put("report_host", "");
+ topology = 1;
+ routines = 1;
+ globalTable = 1;
+ regions = 1;
+ break;
+ case GLOBAL_AURORA:
+ vars.put("version", "8.0.32");
+ vars.put("version_comment", "Source distribution");
+ vars.put("aurora_version", "3.05.2");
+ vars.put("report_host", "");
+ topology = 1;
+ routines = 1;
+ globalTable = 1;
+ regions = 2;
+ break;
+ case COMMUNITY:
+ default:
+ vars.put("version", "8.0.36");
+ vars.put("version_comment", "MySQL Community Server - GPL");
+ vars.put("report_host", "");
+ topology = 0;
+ routines = 0;
+ globalTable = 0;
+ regions = 0;
+ break;
}
+
+ doAnswer(invocation -> {
+ final String sql = invocation.getArgument(0);
+ if (sql.startsWith("SHOW VARIABLES")) {
+ return variablesResultSet(vars);
+ }
+ if (sql.contains("information_schema.routines")) {
+ final ResultSet rs = singleRow();
+ when(rs.getInt("rds_topology")).thenReturn(topology);
+ when(rs.getInt("rds_routines")).thenReturn(routines);
+ when(rs.getInt("global_db_status")).thenReturn(globalTable);
+ return rs;
+ }
+ if (sql.contains("information_schema.aurora_global_db_status") && globalTable > 0) {
+ final ResultSet rs = singleRow();
+ when(rs.getInt(1)).thenReturn(regions);
+ return rs;
+ }
+ throw new SQLException("You have an error in your SQL syntax: " + sql);
+ }).when(mockStatement).executeQuery(any());
+ }
+
+ private void stubPgServer(final PgServer server) throws SQLException {
+ final boolean aurora = server == PgServer.AURORA || server == PgServer.GLOBAL_AURORA;
+ final boolean rds = server != PgServer.COMMUNITY;
+ final boolean multiAzCapable = server == PgServer.RDS || server == PgServer.MULTI_AZ_CLUSTER;
+ final String multiAzId = server == PgServer.MULTI_AZ_CLUSTER ? "db-ABCDEF123456" : null;
+ final int regions = server == PgServer.GLOBAL_AURORA ? 2 : 1;
+
+ doAnswer(invocation -> {
+ final String sql = invocation.getArgument(0);
+ if (sql.contains("pg_catalog.pg_proc")) {
+ final ResultSet rs = singleRow();
+ when(rs.getBoolean("aurora")).thenReturn(aurora);
+ when(rs.getBoolean("limitless")).thenReturn(false);
+ when(rs.getBoolean("global_db_capable")).thenReturn(aurora);
+ when(rs.getBoolean("multi_az_capable")).thenReturn(multiAzCapable);
+ when(rs.getBoolean("rds")).thenReturn(rds);
+ when(rs.getString("server_version")).thenReturn("15.4");
+ return rs;
+ }
+ if (sql.contains("aurora_global_db_status()") && aurora) {
+ final ResultSet rs = singleRow();
+ when(rs.getInt(1)).thenReturn(regions);
+ return rs;
+ }
+ if (sql.contains("rds_tools.multi_az_db_cluster_source_dbi_resource_id()") && multiAzCapable) {
+ final ResultSet rs = singleRow();
+ when(rs.getString(1)).thenReturn(multiAzId);
+ return rs;
+ }
+ throw new SQLException("ERROR: syntax error: " + sql);
+ }).when(mockStatement).executeQuery(any());
+ }
+
+ private static ResultSet singleRow() throws SQLException {
+ final ResultSet rs = mock(ResultSet.class);
+ when(rs.next()).thenReturn(true, false);
+ return rs;
+ }
+
+ private static ResultSet variablesResultSet(final Map<String, String> vars) throws SQLException {
+ final ResultSet rs = mock(ResultSet.class);
+ final String[] names = vars.keySet().toArray(new String[0]);
+ final String[] values = vars.values().toArray(new String[0]);
+ final int[] cursor = {-1};
+ when(rs.next()).thenAnswer(inv -> ++cursor[0] < names.length);
+ when(rs.getString(1)).thenAnswer(inv -> names[cursor[0]]);
+ when(rs.getString(2)).thenAnswer(inv -> values[cursor[0]]);
return rs;
}
}
diff --git a/wrapper/src/test/java/software/amazon/jdbc/dialect/DialectDetectorTests.java b/wrapper/src/test/java/software/amazon/jdbc/dialect/DialectDetectorTests.java
new file mode 100644
index 0000000000..93c51b955c
--- /dev/null
+++ b/wrapper/src/test/java/software/amazon/jdbc/dialect/DialectDetectorTests.java
@@ -0,0 +1,533 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package software.amazon.jdbc.dialect;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.stream.Stream;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import software.amazon.jdbc.dialect.DialectFingerprint.Family;
+
+public class DialectDetectorTests {
+
+ @Mock private Connection mockConnection;
+ @Mock private Statement mockStatement;
+ @Mock private DatabaseMetaData mockMetaData;
+ private AutoCloseable closeable;
+ private final DialectDetector detector = new DialectDetector();
+
+ @BeforeEach
+ void setUp() throws SQLException {
+ closeable = MockitoAnnotations.openMocks(this);
+ when(mockConnection.createStatement()).thenReturn(mockStatement);
+ when(mockConnection.getMetaData()).thenReturn(mockMetaData);
+ }
+
+ @AfterEach
+ void cleanUp() throws Exception {
+ closeable.close();
+ }
+
+ // --- resolve(): the decision table, one row per deployment ---
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("resolveArguments")
+ void testResolve(final String name, final DialectFingerprint fingerprint, final String expectedCode) {
+ assertEquals(expectedCode, DialectDetector.resolve(fingerprint));
+ }
+
+ static Stream<Arguments> resolveArguments() {
+ return Stream.of(
+ Arguments.of("community pg",
+ DialectFingerprint.builder(Family.PG).build(), DialectCodes.PG),
+ Arguments.of("rds pg",
+ DialectFingerprint.builder(Family.PG).rds(true).build(), DialectCodes.RDS_PG),
+ Arguments.of("rds pg, multi-az function present but single instance",
+ DialectFingerprint.builder(Family.PG).rds(true).multiAzClusterCapable(true).build(),
+ DialectCodes.RDS_PG),
+ Arguments.of("rds multi-az pg cluster",
+ DialectFingerprint.builder(Family.PG).rds(true).multiAzClusterCapable(true).multiAzCluster(true).build(),
+ DialectCodes.RDS_MULTI_AZ_PG_CLUSTER),
+ Arguments.of("aurora pg, single region",
+ DialectFingerprint.builder(Family.PG).rds(true).aurora(true).globalDbCapable(true)
+ .globalDbRegionCount(1).build(),
+ DialectCodes.AURORA_PG),
+ Arguments.of("aurora pg, region count unknown",
+ DialectFingerprint.builder(Family.PG).rds(true).aurora(true).globalDbCapable(true).build(),
+ DialectCodes.AURORA_PG),
+ Arguments.of("global aurora pg",
+ DialectFingerprint.builder(Family.PG).rds(true).aurora(true).globalDbCapable(true)
+ .globalDbRegionCount(2).build(),
+ DialectCodes.GLOBAL_AURORA_PG),
+ Arguments.of("aurora limitless pg",
+ DialectFingerprint.builder(Family.PG).rds(true).limitless(true).build(), DialectCodes.AURORA_PG),
+ Arguments.of("community mysql",
+ DialectFingerprint.builder(Family.MYSQL).build(), DialectCodes.MYSQL),
+ Arguments.of("mariadb",
+ DialectFingerprint.builder(Family.MYSQL).mariaDb(true).build(), DialectCodes.MARIADB),
+ Arguments.of("rds mariadb is still mariadb",
+ DialectFingerprint.builder(Family.MYSQL).mariaDb(true).rds(true).build(), DialectCodes.MARIADB),
+ Arguments.of("rds mysql",
+ DialectFingerprint.builder(Family.MYSQL).rds(true).multiAzClusterCapable(true).build(),
+ DialectCodes.RDS_MYSQL),
+ Arguments.of("rds multi-az mysql cluster",
+ DialectFingerprint.builder(Family.MYSQL).rds(true).multiAzClusterCapable(true).multiAzCluster(true).build(),
+ DialectCodes.RDS_MULTI_AZ_MYSQL_CLUSTER),
+ Arguments.of("aurora mysql, single region",
+ DialectFingerprint.builder(Family.MYSQL).rds(true).aurora(true).globalDbCapable(true)
+ .globalDbRegionCount(1).build(),
+ DialectCodes.AURORA_MYSQL),
+ Arguments.of("aurora mysql 2.x, no global status table",
+ DialectFingerprint.builder(Family.MYSQL).rds(true).aurora(true).build(), DialectCodes.AURORA_MYSQL),
+ Arguments.of("global aurora mysql",
+ DialectFingerprint.builder(Family.MYSQL).rds(true).aurora(true).globalDbCapable(true)
+ .globalDbRegionCount(3).build(),
+ DialectCodes.GLOBAL_AURORA_MYSQL),
+ Arguments.of("unknown family",
+ DialectFingerprint.builder(Family.UNKNOWN).build(), DialectCodes.UNKNOWN)
+ );
+ }
+
+ // --- familyOf(code) ---
+
+ @Test
+ void testFamilyOfCode() {
+ assertEquals(Family.PG, DialectDetector.familyOf(DialectCodes.PG));
+ assertEquals(Family.PG, DialectDetector.familyOf(DialectCodes.RDS_PG));
+ assertEquals(Family.PG, DialectDetector.familyOf(DialectCodes.RDS_MULTI_AZ_PG_CLUSTER));
+ assertEquals(Family.PG, DialectDetector.familyOf(DialectCodes.AURORA_PG));
+ assertEquals(Family.PG, DialectDetector.familyOf(DialectCodes.GLOBAL_AURORA_PG));
+ assertEquals(Family.MYSQL, DialectDetector.familyOf(DialectCodes.MYSQL));
+ assertEquals(Family.MYSQL, DialectDetector.familyOf(DialectCodes.RDS_MYSQL));
+ assertEquals(Family.MYSQL, DialectDetector.familyOf(DialectCodes.RDS_MULTI_AZ_MYSQL_CLUSTER));
+ assertEquals(Family.MYSQL, DialectDetector.familyOf(DialectCodes.AURORA_MYSQL));
+ assertEquals(Family.MYSQL, DialectDetector.familyOf(DialectCodes.GLOBAL_AURORA_MYSQL));
+ assertEquals(Family.MYSQL, DialectDetector.familyOf(DialectCodes.MARIADB));
+ assertEquals(Family.UNKNOWN, DialectDetector.familyOf(DialectCodes.UNKNOWN));
+ assertEquals(Family.UNKNOWN, DialectDetector.familyOf(DialectCodes.CUSTOM));
+ assertEquals(Family.UNKNOWN, DialectDetector.familyOf(null));
+ }
+
+ @Test
+ void testFamilyFromMetadataUsesProductName() throws SQLException {
+ when(mockMetaData.getDatabaseProductName()).thenReturn("PostgreSQL");
+ assertEquals(Family.PG, detector.familyFromMetadata(mockConnection));
+ when(mockMetaData.getDatabaseProductName()).thenReturn("MySQL");
+ assertEquals(Family.MYSQL, detector.familyFromMetadata(mockConnection));
+ when(mockMetaData.getDatabaseProductName()).thenReturn("MariaDB");
+ assertEquals(Family.MYSQL, detector.familyFromMetadata(mockConnection));
+ when(mockMetaData.getDatabaseProductName()).thenReturn("Oracle");
+ assertEquals(Family.UNKNOWN, detector.familyFromMetadata(mockConnection));
+ when(mockConnection.getMetaData()).thenThrow(new SQLException("no metadata"));
+ assertEquals(Family.UNKNOWN, detector.familyFromMetadata(mockConnection));
+ }
+
+ // --- collectPg(): one statement, follow-ups only when the fingerprint calls for them ---
+
+ @Test
+ void testCollectPgCommunityRunsSingleStatement() throws SQLException {
+ stubPgFingerprint(false, false, false, false, false, "16.2");
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.PG);
+
+ assertNotNull(fp);
+ assertEquals(Family.PG, fp.getFamily());
+ assertFalse(fp.isAurora());
+ assertFalse(fp.isRds());
+ assertEquals("16.2", fp.getServerVersion());
+ assertEquals(DialectFingerprint.REGION_COUNT_NOT_QUERIED, fp.getGlobalDbRegionCount());
+ verify(mockStatement, times(1)).executeQuery(anyString());
+ assertEquals(DialectCodes.PG, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectPgAuroraQueriesRegionCountOnly() throws SQLException {
+ stubPgFingerprint(true, false, true, true, true, "15.4");
+ stubCount(GlobalAuroraPgDialect.REGION_COUNT_QUERY, 1);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.PG);
+
+ assertNotNull(fp);
+ assertTrue(fp.isAurora());
+ assertEquals(1, fp.getGlobalDbRegionCount());
+ assertFalse(fp.isMultiAzCluster());
+ verify(mockStatement, times(2)).executeQuery(anyString());
+ verify(mockStatement, never()).executeQuery(eq(MultiAzClusterPgDialect.IS_RDS_CLUSTER_QUERY));
+ assertEquals(DialectCodes.AURORA_PG, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectPgGlobalAurora() throws SQLException {
+ stubPgFingerprint(true, false, true, true, true, "15.4");
+ stubCount(GlobalAuroraPgDialect.REGION_COUNT_QUERY, 2);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.PG);
+
+ assertNotNull(fp);
+ assertEquals(DialectCodes.GLOBAL_AURORA_PG, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectPgMultiAzClusterQueriesResourceIdOnly() throws SQLException {
+ stubPgFingerprint(false, false, false, true, true, "15.4");
+ stubString(MultiAzClusterPgDialect.IS_RDS_CLUSTER_QUERY, "db-ABCDEF123456");
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.PG);
+
+ assertNotNull(fp);
+ assertTrue(fp.isRds());
+ assertTrue(fp.isMultiAzCluster());
+ verify(mockStatement, times(2)).executeQuery(anyString());
+ verify(mockStatement, never()).executeQuery(eq(GlobalAuroraPgDialect.REGION_COUNT_QUERY));
+ assertEquals(DialectCodes.RDS_MULTI_AZ_PG_CLUSTER, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectPgRdsSingleInstanceWithNullResourceId() throws SQLException {
+ stubPgFingerprint(false, false, false, true, true, "15.4");
+ stubString(MultiAzClusterPgDialect.IS_RDS_CLUSTER_QUERY, null);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.PG);
+
+ assertNotNull(fp);
+ assertFalse(fp.isMultiAzCluster());
+ assertEquals(DialectCodes.RDS_PG, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectPgRdsWithoutMultiAzFunctionRunsSingleStatement() throws SQLException {
+ stubPgFingerprint(false, false, false, false, true, "15.4");
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.PG);
+
+ assertNotNull(fp);
+ verify(mockStatement, times(1)).executeQuery(anyString());
+ assertEquals(DialectCodes.RDS_PG, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectPgFingerprintFailureReturnsNull() throws SQLException {
+ doThrow(new SQLException("permission denied")).when(mockStatement).executeQuery(anyString());
+
+ assertNull(detector.collect(mockConnection, Family.PG));
+ }
+
+ // --- collectMysql(): variables + catalog, region count only for Aurora ---
+
+ @Test
+ void testCollectMysqlCommunity() throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "8.0.36");
+ vars.put("version_comment", "MySQL Community Server - GPL");
+ vars.put("report_host", "");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(0, 0, 0);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ assertFalse(fp.isAurora());
+ assertFalse(fp.isRds());
+ assertFalse(fp.isMariaDb());
+ assertEquals("8.0.36", fp.getServerVersion());
+ verify(mockStatement, times(2)).executeQuery(anyString());
+ assertEquals(DialectCodes.MYSQL, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlMariaDb() throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "10.11.6-MariaDB-log");
+ vars.put("version_comment", "mariadb.org binary distribution");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(0, 0, 0);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ assertTrue(fp.isMariaDb());
+ assertEquals(DialectCodes.MARIADB, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlRdsMariaDbStaysMariaDb() throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "10.11.6-MariaDB-log");
+ vars.put("version_comment", "Source distribution");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(0, 1, 0);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ assertTrue(fp.isMariaDb());
+ assertTrue(fp.isRds());
+ assertEquals(DialectCodes.MARIADB, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlRdsSingleInstance() throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "8.0.35");
+ vars.put("version_comment", "Source distribution");
+ vars.put("report_host", "");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(1, 1, 0);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ assertTrue(fp.isRds());
+ assertTrue(fp.isMultiAzClusterCapable());
+ assertFalse(fp.isMultiAzCluster());
+ verify(mockStatement, times(2)).executeQuery(anyString());
+ assertEquals(DialectCodes.RDS_MYSQL, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlRdsFromVersionCommentWhenCatalogHidden() throws SQLException {
+ // A user without privileges on mysql.rds_* objects sees none of them in information_schema.
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "8.0.35");
+ vars.put("version_comment", "Source distribution");
+ vars.put("report_host", "");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(0, 0, 0);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ assertTrue(fp.isRds());
+ assertEquals(DialectCodes.RDS_MYSQL, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlMultiAzCluster() throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "8.0.35");
+ vars.put("version_comment", "Source distribution");
+ vars.put("report_host", "10.0.0.1");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(1, 1, 0);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ assertTrue(fp.isMultiAzCluster());
+ assertEquals(DialectCodes.RDS_MULTI_AZ_MYSQL_CLUSTER, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlAuroraSingleRegion() throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "8.0.32");
+ vars.put("version_comment", "Source distribution");
+ vars.put("aurora_version", "3.05.2");
+ vars.put("report_host", "");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(1, 1, 1);
+ stubCount(GlobalAuroraMysqlDialect.REGION_COUNT_QUERY, 1);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ assertTrue(fp.isAurora());
+ assertEquals(1, fp.getGlobalDbRegionCount());
+ assertFalse(fp.isMultiAzCluster());
+ verify(mockStatement, times(3)).executeQuery(anyString());
+ assertEquals(DialectCodes.AURORA_MYSQL, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlAuroraWithoutGlobalTableSkipsRegionCount() throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "5.7.12");
+ vars.put("aurora_version", "2.11.2");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(1, 1, 0);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ verify(mockStatement, times(2)).executeQuery(anyString());
+ verify(mockStatement, never()).executeQuery(eq(GlobalAuroraMysqlDialect.REGION_COUNT_QUERY));
+ assertEquals(DialectCodes.AURORA_MYSQL, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlGlobalAurora() throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "8.0.32");
+ vars.put("aurora_version", "3.05.2");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(1, 1, 1);
+ stubCount(GlobalAuroraMysqlDialect.REGION_COUNT_QUERY, 2);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ assertEquals(DialectCodes.GLOBAL_AURORA_MYSQL, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlCatalogFailureStillResolves() throws SQLException {
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "8.0.32");
+ vars.put("aurora_version", "3.05.2");
+ stubMysqlVariables(vars);
+ doThrow(new SQLException("denied")).when(mockStatement).executeQuery(eq(DialectDetector.MYSQL_CATALOG_QUERY));
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.MYSQL);
+
+ assertNotNull(fp);
+ assertTrue(fp.isAurora());
+ assertEquals(DialectCodes.AURORA_MYSQL, DialectDetector.resolve(fp));
+ }
+
+ @Test
+ void testCollectMysqlVariablesFailureReturnsNull() throws SQLException {
+ doThrow(new SQLException("syntax error")).when(mockStatement).executeQuery(anyString());
+
+ assertNull(detector.collect(mockConnection, Family.MYSQL));
+ }
+
+ // --- collect() with an unknown family ---
+
+ @Test
+ void testCollectUnknownFamilyUsesDriverMetadata() throws SQLException {
+ when(mockMetaData.getDatabaseProductName()).thenReturn("MySQL");
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "8.0.36");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(0, 0, 0);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.UNKNOWN);
+
+ assertNotNull(fp);
+ assertEquals(Family.MYSQL, fp.getFamily());
+ verify(mockStatement, never()).executeQuery(eq(DialectDetector.PG_FINGERPRINT_QUERY));
+ }
+
+ @Test
+ void testCollectUnknownFamilyWithoutMetadataTriesPgThenMysql() throws SQLException {
+ when(mockMetaData.getDatabaseProductName()).thenReturn("Something");
+ doThrow(new SQLException("syntax error"))
+ .when(mockStatement).executeQuery(eq(DialectDetector.PG_FINGERPRINT_QUERY));
+ final Map<String, String> vars = new LinkedHashMap<>();
+ vars.put("version", "8.0.36");
+ stubMysqlVariables(vars);
+ stubMysqlCatalog(0, 0, 0);
+
+ final DialectFingerprint fp = detector.collect(mockConnection, Family.UNKNOWN);
+
+ assertNotNull(fp);
+ assertEquals(Family.MYSQL, fp.getFamily());
+ verify(mockStatement, times(1)).executeQuery(eq(DialectDetector.PG_FINGERPRINT_QUERY));
+ }
+
+ // --- helpers ---
+
+ private void stubPgFingerprint(
+ final boolean aurora,
+ final boolean limitless,
+ final boolean globalDbCapable,
+ final boolean multiAzCapable,
+ final boolean rds,
+ final String version) throws SQLException {
+ doAnswer(invocation -> {
+ final ResultSet rs = mock(ResultSet.class);
+ when(rs.next()).thenReturn(true, false);
+ when(rs.getBoolean("aurora")).thenReturn(aurora);
+ when(rs.getBoolean("limitless")).thenReturn(limitless);
+ when(rs.getBoolean("global_db_capable")).thenReturn(globalDbCapable);
+ when(rs.getBoolean("multi_az_capable")).thenReturn(multiAzCapable);
+ when(rs.getBoolean("rds")).thenReturn(rds);
+ when(rs.getString("server_version")).thenReturn(version);
+ return rs;
+ }).when(mockStatement).executeQuery(eq(DialectDetector.PG_FINGERPRINT_QUERY));
+ }
+
+ private void stubMysqlVariables(final Map<String, String> vars) throws SQLException {
+ doAnswer(invocation -> {
+ final ResultSet rs = mock(ResultSet.class);
+ final String[] names = vars.keySet().toArray(new String[0]);
+ final String[] values = vars.values().toArray(new String[0]);
+ final int[] cursor = {-1};
+ when(rs.next()).thenAnswer(inv -> ++cursor[0] < names.length);
+ when(rs.getString(1)).thenAnswer(inv -> names[cursor[0]]);
+ when(rs.getString(2)).thenAnswer(inv -> values[cursor[0]]);
+ return rs;
+ }).when(mockStatement).executeQuery(eq(DialectDetector.MYSQL_VARIABLES_QUERY));
+ }
+
+ private void stubMysqlCatalog(final int rdsTopology, final int rdsRoutines, final int globalDbStatus)
+ throws SQLException {
+ doAnswer(invocation -> {
+ final ResultSet rs = mock(ResultSet.class);
+ when(rs.next()).thenReturn(true, false);
+ when(rs.getInt("rds_topology")).thenReturn(rdsTopology);
+ when(rs.getInt("rds_routines")).thenReturn(rdsRoutines);
+ when(rs.getInt("global_db_status")).thenReturn(globalDbStatus);
+ return rs;
+ }).when(mockStatement).executeQuery(eq(DialectDetector.MYSQL_CATALOG_QUERY));
+ }
+
+ private void stubCount(final String query, final int count) throws SQLException {
+ doAnswer(invocation -> {
+ final ResultSet rs = mock(ResultSet.class);
+ when(rs.next()).thenReturn(true, false);
+ when(rs.getInt(1)).thenReturn(count);
+ return rs;
+ }).when(mockStatement).executeQuery(eq(query));
+ }
+
+ private void stubString(final String query, final String value) throws SQLException {
+ doAnswer(invocation -> {
+ final ResultSet rs = mock(ResultSet.class);
+ when(rs.next()).thenReturn(true, false);
+ when(rs.getString(1)).thenReturn(value);
+ return rs;
+ }).when(mockStatement).executeQuery(eq(query));
+ }
+}
^ permalink raw [nested|flat] 10+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2238: [WIP] feat: fingerprint-based dialect detection
@ 2026-11-13 22:06 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
8 siblings, 0 replies; 10+ messages in thread
From: sergiyvamz (@sergiyvamz) @ 2026-11-13 22:06 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
@sergiyvamz renamed this.
^ permalink raw [nested|flat] 10+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection
@ 2026-11-16 17:34 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
8 siblings, 0 replies; 10+ messages in thread
From: sergiyvamz (@sergiyvamz) @ 2026-11-16 17:34 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
@sergiyvamz renamed this.
^ permalink raw [nested|flat] 10+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection
@ 2026-11-18 19:18 "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com>
8 siblings, 0 replies; 10+ messages in thread
From: sophia-bq (@sophia-bq) @ 2026-11-18 19:18 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
(on wrapper/src/main/java/software/amazon/jdbc/dialect/DialectDetector.java:226)
Should there also be a collection of the limitless information here?
`final boolean limitless = rs.getBoolean("limitless");`
^ permalink raw [nested|flat] 10+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection
@ 2026-11-18 19:27 "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com>
8 siblings, 0 replies; 10+ messages in thread
From: sophia-bq (@sophia-bq) @ 2026-11-18 19:27 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
(on docs/using-the-jdbc-driver/DatabaseDialects.md:43)
I think since some of the methods for Dialect are deprecated this should be updated with correct instructions for users to set up custom dialects?
^ permalink raw [nested|flat] 10+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2238 (approved): feat: fingerprint-based dialect detection
@ 2026-11-18 19:28 "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com>
8 siblings, 0 replies; 10+ messages in thread
From: sophia-bq (@sophia-bq) @ 2026-11-18 19:28 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
^ permalink raw [nested|flat] 10+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection
@ 2026-11-18 21:52 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
8 siblings, 0 replies; 10+ messages in thread
From: sergiyvamz (@sergiyvamz) @ 2026-11-18 21:52 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
(on wrapper/src/main/java/software/amazon/jdbc/dialect/DialectDetector.java:226)
Good catch. Thank you
^ permalink raw [nested|flat] 10+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection
@ 2026-11-18 21:52 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
8 siblings, 0 replies; 10+ messages in thread
From: sergiyvamz (@sergiyvamz) @ 2026-11-18 21:52 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
(on docs/using-the-jdbc-driver/DatabaseDialects.md:43)
Added a piece about custom dialect.
^ permalink raw [nested|flat] 10+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection
@ 2026-11-18 22:05 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
8 siblings, 0 replies; 10+ messages in thread
From: sergiyvamz (@sergiyvamz) @ 2026-11-18 22:05 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
@sergiyvamz closed this.
^ permalink raw [nested|flat] 10+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection
@ 2026-11-18 22:05 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
8 siblings, 0 replies; 10+ messages in thread
From: sergiyvamz (@sergiyvamz) @ 2026-11-18 22:05 UTC (permalink / raw)
To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com>
@sergiyvamz merged this (commit c034dd217853).
^ permalink raw [nested|flat] 10+ messages in thread
end of thread, other threads:[~2026-11-18 22:05 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 21:35 [aws/aws-advanced-jdbc-wrapper] PR #2238: feat: fingerprint-based dialect detection "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
2026-11-13 22:06 ` Re: [aws/aws-advanced-jdbc-wrapper] PR #2238: [WIP] feat: fingerprint-based dialect detection "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
2026-11-16 17:34 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
2026-11-18 19:18 ` "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com>
2026-11-18 19:27 ` "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com>
2026-11-18 19:28 ` Re: [aws/aws-advanced-jdbc-wrapper] PR #2238 (approved): feat: fingerprint-based dialect detection "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com>
2026-11-18 21:52 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
2026-11-18 21:52 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
2026-11-18 22:05 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
2026-11-18 22:05 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox