This is an automated email from the ASF dual-hosted git repository.
CalvinKirs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 63494e39506 [fix](jdbc) Validate MySQL connection options in catalog
DDL (#71221)
63494e39506 is described below
commit 63494e39506892ed1df78e7275c16db7b77fe5bc
Author: Calvin Kirs <[email protected]>
AuthorDate: Fri Dec 4 09:37:06 2026 +0800
[fix](jdbc) Validate MySQL connection options in catalog DDL (#71221)
### Background
Doris uses the JDBC URL supplied in catalog DDL to configure the
connector and, when enabled, test connectivity. MySQL Connector/J reads
connection options from the query string and host definitions.
### What problem does this PR solve?
Issue Number: None
Related PR: None
PR Type: Bugfix
Problem Summary:
The FE previously passed MySQL JDBC catalog connection options through
without applying an operator-configured restriction list. The FE now
prepares the effective URL before constructing the connector on CREATE
or applying an ALTER that supplies that URL. The regression framework
derives a separate catalog URL so client sessions can still exercise
LOAD DATA.
### Details
- **Change map:** 346 additions and 22 deletions in production code,
plus 530 additions and 35 deletions in tests and fixtures. The
production changes cover URL policy and configuration in Foundation and
Common, provider declarations in the Connector SPI and JDBC plugin, and
CREATE and ALTER routing in FE Core. Tests cover parsing, configuration,
routing, replay and the provider declaration. Catalog fixtures use the
derived URL.
- **Frequency:** Applies on CREATE with a MySQL JDBC URL and on ALTER
that supplies the effective URL key.
- **Root cause:** Connector URL normalization handles driver
compatibility options. The FE lacked a statement-time restriction policy
for MySQL connection options.
- **Why existing tests missed it:** Catalog routing tests covered
connector selection and storage context. JDBC regression suites covered
connectivity and driver versions without checking DDL preparation of
literal hashes.
- **Fix:** Use provider-declared URL key precedence. Validate host
options and the MySQL query options each supported driver can read.
Preserve literal hash data in query values and insert an explicit
`allowLoadLocalInfile=false` in the shared query segment when needed.
ALTER applies and journals the same prepared update after rechecking the
catalog snapshot.
- **Other paths and branches:** Unrelated ALTERs skip preparation, and
replay uses the recorded value directly. Iceberg and Paimon metastore
settings and other JDBC URL types keep their existing handling. The
implementation targets master.
- **Configs and defaults:** Set the comma-separated
`jdbc_mysql_restricted_url_parameters` list in the FE startup
configuration and restart the FE. The standard `fe_custom.conf` overlay
takes precedence over `fe.conf`. The setting is read-only at runtime.
The defaults are `allowLoadLocalInfile`, `allowUrlInLocalInfile`, and
`allowLoadLocalInfileInPath`. The flags accept disabled values, the path
accepts an empty value, and additional listed names are blocked.
- **Behavior change:** CREATE and effective-URL ALTER reject MySQL
options that violate the FE's configured restrictions. A query
containing a literal hash must satisfy the policy under both the legacy
query and modern fragment rules.
- **Driver compatibility:** Connector/J 8.x URL syntax is the
compatibility target for this DDL validation. CREATE and ALTER that
supply a JDBC URL can reject legacy Connector/J 5.1 URLs when a quoted
`address=` host-property value contains a literal `#`. That legacy-only
syntax is outside this change's compatibility scope. The existing
Connector/J 5.1.49 regression fixtures remain in the test suite.
### Testing
- The two new Foundation tests failed on the earlier PR revision because
a raw hash value was truncated and a configured option in the legacy
query was missed. Both passed after the fix.
- The local FE unit-test runner passed 13 Foundation, 29 Common, 19 JDBC
plugin, and 83 FE Core tests. The Core total includes 13 catalog
routing, 7 migration, 19 driver URL gate, and 44 SSRF gate tests.
Routing exercises CREATE, effective ALTER, journaling, alias precedence,
and replay.
- The local Connector SPI reactor passed 176 tests.
- Connector/J 5.1.49 and 8.4.0 parsed six dummy URLs without opening
database connections. Groovy parsed the five updated suites and checked
their six catalog URL inputs.
### Notes for Reviewers
This PR preserves the target branch's Connector SPI version. Upgrade or
roll back each node's FE and JDBC plugin as a pair. Mixing packages can
leave the URL policy unavailable or cause the plugin loader to reject an
incompatible provider.
### Release note
MySQL-backed JDBC catalogs enforce the FE's restricted connection-option
policy at creation and when an ALTER supplies the effective connection
URL. Operators can set the restrictions in `fe.conf`. Use matching FE
and JDBC plugin packages for upgrades and rollbacks.
### Check List (For Author)
- Behavior changed: Yes (see Details)
- Does this need documentation: Yes (document the setting and its CREATE
and ALTER scope in the JDBC Catalog and FE configuration references)
- Pre-submission status: Partially verified: live JDBC, Cloud, and
Ranger regression suites were not run.
### AI Disclosure
- Tool: OpenAI Codex
- Generated: Code, tests, and PR description
- Human review: not stated
---
.../main/java/org/apache/doris/common/Config.java | 9 +
.../common/security/JdbcCatalogUrlSecurity.java | 31 +++
.../java/org/apache/doris/common/ConfigTest.java | 30 ++-
.../security/JdbcCatalogUrlSecurityTest.java | 144 ++++++++++++
.../connector/jdbc/JdbcConnectorProvider.java | 2 +
.../JdbcConnectorProviderSecuritySurfaceTest.java | 7 +
.../connector/spi/ConnectorSecuritySurface.java | 44 ++--
.../spi/ConnectorSecuritySurfaceTest.java | 23 ++
.../test/resources/connector-plugin-surface.txt | 2 +
.../apache/doris/connector/ConnectorFactory.java | 10 +
.../doris/connector/ConnectorPluginManager.java | 11 +-
.../apache/doris/datasource/CatalogFactory.java | 37 ++-
.../org/apache/doris/datasource/CatalogMgr.java | 13 +-
.../CatalogFactoryPluginRoutingTest.java | 256 ++++++++++++++++++++-
.../foundation/security/JdbcDriverUrlSecurity.java | 214 +++++++++++++++++
.../security/JdbcDriverUrlSecurityTest.java | 64 ++++++
.../org/apache/doris/regression/Config.groovy | 13 ++
.../create_view_nereids_fix_null.groovy | 2 +-
.../jdbc/test_doris_jdbc_catalog.groovy | 2 +-
.../test_doris_jdbc_catalog_query_bitmap.groovy | 2 +-
...st_doris_jdbc_catalog_query_hll_quantile.groovy | 2 +-
.../jdbc/test_doris_jdbc_catalog_varbinary.groovy | 2 +-
.../jdbc/test_jdbc_array_literal_predicate.groovy | 2 +-
.../external_table_p0/jdbc/test_jdbc_call.groovy | 2 +-
.../jdbc/test_jni_complex_type.groovy | 2 +-
.../test_mysql_jdbc_catalog_table_comment.groovy | 2 +-
.../jdbc/test_non_nullable_jdbc_mtmv.groovy | 2 +-
.../jdbc/test_query_tvf_cross_catalog.groovy | 2 +-
.../select/test_doris_all_types_select.groovy | 2 +-
.../lower_case/test_conflict_name.groovy | 2 +-
.../lower_case/test_lower_case_meta_include.groovy | 2 +-
.../test_lower_case_meta_show_and_select.groovy | 2 +-
...er_case_meta_with_lower_table_conf_grant.groovy | 2 +-
...ta_with_lower_table_conf_show_and_select.groovy | 2 +-
.../lower_case/test_lower_case_mtmv.groovy | 2 +-
.../test_meta_cache_select_without_refresh.groovy | 2 +-
.../lower_case/test_meta_names_mapping.groovy | 2 +-
.../lower_case/test_timing_refresh_catalog.groovy | 2 +-
.../lower_case/upgrade/load.groovy | 2 +-
.../suites/nereids_syntax_p0/alias_conflict.groovy | 2 +-
.../test_cloud_plugin_auto_download.groovy | 2 +-
.../test_ranger_access_resource_catalog.groovy | 2 +-
.../test_ranger_access_resource_global.groovy | 2 +-
...test_ranger_access_role_resource_catalog.groovy | 2 +-
44 files changed, 907 insertions(+), 57 deletions(-)
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index 68d88be08e4..d3e7220b226 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -179,6 +179,15 @@ public class Config extends ConfigBase {
+ "traversal and prefix confusion are rejected.")
public static String jdbc_driver_secure_path = "*";
+ @ConfField(description = "Comma-separated, case-insensitive MySQL JDBC URL
parameter "
+ + "names restricted during CREATE CATALOG and when ALTER CATALOG
sets the effective URL. "
+ + "The list is loaded at FE startup, with fe_custom.conf
overriding fe.conf. "
+ + "Changes require an FE restart. "
+ + "The two default LOCAL INFILE flags only allow disabled values,
the directory option only allows "
+ + "an empty value, and other listed names are blocked.")
+ public static String[] jdbc_mysql_restricted_url_parameters = {
+ "allowLoadLocalInfile", "allowUrlInLocalInfile",
"allowLoadLocalInfileInPath"};
+
@ConfField(description = "Functions that MySQL JDBC Catalog does not
support pushing down")
public static String[] jdbc_mysql_unsupported_pushdown_functions =
{"date_trunc", "money_format", "negative"};
diff --git
a/fe/fe-common/src/main/java/org/apache/doris/common/security/JdbcCatalogUrlSecurity.java
b/fe/fe-common/src/main/java/org/apache/doris/common/security/JdbcCatalogUrlSecurity.java
new file mode 100644
index 00000000000..c86115e8bbe
--- /dev/null
+++
b/fe/fe-common/src/main/java/org/apache/doris/common/security/JdbcCatalogUrlSecurity.java
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you 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 org.apache.doris.common.security;
+
+import org.apache.doris.common.Config;
+import org.apache.doris.foundation.security.JdbcDriverUrlSecurity;
+
+/** Applies the FE configuration to the MySQL JDBC catalog URL. */
+public final class JdbcCatalogUrlSecurity {
+ private JdbcCatalogUrlSecurity() {
+ }
+
+ public static String prepareMySqlJdbcUrl(String url) {
+ return JdbcDriverUrlSecurity.prepareMySqlJdbcUrl(url,
Config.jdbc_mysql_restricted_url_parameters);
+ }
+}
diff --git a/fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java
b/fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java
index e7eea2956ed..06ef06d7fcb 100644
--- a/fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java
+++ b/fe/fe-common/src/test/java/org/apache/doris/common/ConfigTest.java
@@ -558,14 +558,40 @@ public class ConfigTest {
}
}
- // File-path and jdbc-driver security configs must only be settable in
fe.conf (ops), never at runtime
- // via ADMIN SET FRONTEND CONFIG. setMutableConfig is exactly that runtime
entrypoint, so it must reject them.
+ @Test
+ public void testMysqlRestrictedUrlParametersUseCustomStartupOverride()
throws Exception {
+ String[] original = Config.jdbc_mysql_restricted_url_parameters;
+ String originalDriverPath = Config.jdbc_driver_secure_path;
+ try {
+ Assertions.assertArrayEquals(new String[] {
+ "allowLoadLocalInfile", "allowUrlInLocalInfile",
"allowLoadLocalInfileInPath"}, original);
+ Config config = new Config();
+ config.init(configFile("jdbc_mysql_restricted_url_parameters=
connectTimeout , socketTimeout \n")
+ .toString());
+ Assertions.assertArrayEquals(new String[] {"connectTimeout",
"socketTimeout"},
+ Config.jdbc_mysql_restricted_url_parameters);
+
+
config.initCustom(configFile("jdbc_mysql_restricted_url_parameters=
connectionTimeZone , useUnicode \n"
+ +
"jdbc_driver_secure_path=${java.io.tmpdir}/custom-drivers\n").toString());
+ Assertions.assertArrayEquals(new String[] {"connectionTimeZone",
"useUnicode"},
+ Config.jdbc_mysql_restricted_url_parameters);
+ Assertions.assertEquals(System.getProperty("java.io.tmpdir") +
"/custom-drivers",
+ Config.jdbc_driver_secure_path);
+ } finally {
+ Config.jdbc_mysql_restricted_url_parameters = original;
+ Config.jdbc_driver_secure_path = originalDriverPath;
+ }
+ }
+
+ // File-path and JDBC security configs are set at startup. ADMIN SET
FRONTEND CONFIG uses
+ // setMutableConfig, which must reject runtime changes to them.
@Test
public void testSecurityPathConfigsAreNotRuntimeMutable() {
String[] opsOnlyConfigs = {
"jdbc_driver_url_white_list",
"jdbc_drivers_dir",
"jdbc_driver_secure_path",
+ "jdbc_mysql_restricted_url_parameters",
"tmp_dir",
"plugin_dir",
"s3_load_endpoint_white_list",
diff --git
a/fe/fe-common/src/test/java/org/apache/doris/common/security/JdbcCatalogUrlSecurityTest.java
b/fe/fe-common/src/test/java/org/apache/doris/common/security/JdbcCatalogUrlSecurityTest.java
new file mode 100644
index 00000000000..7a7f7d32694
--- /dev/null
+++
b/fe/fe-common/src/test/java/org/apache/doris/common/security/JdbcCatalogUrlSecurityTest.java
@@ -0,0 +1,144 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you 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 org.apache.doris.common.security;
+
+import org.apache.doris.common.Config;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class JdbcCatalogUrlSecurityTest {
+ private static final String MYSQL_URL = "jdbc:mysql://db.example/app?";
+
+ @Test
+ public void testAllowsSafeMysqlPropertiesAndOtherDrivers() {
+
JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl("jdbc:mysql://db.example/app");
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(MYSQL_URL +
"connectTimeout=5000&allowLoadLocalInfile=false"
+ + "&allowUrlInLocalInfile=NO&allowLoadLocalInfileInPath=");
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(MYSQL_URL +
"connectionAttributes=tag:allowLoadLocalInfile%3Dtrue");
+
JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl("jdbc:mysql://address=(host=db.example)(port=3306)"
+ +
"(allowLoadLocalInfile=false)(allowLoadLocalInfileInPath=)/app");
+
JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl("jdbc:mysql:replication://[::1]:3306,(host=db.example,port=3306,"
+ + "allowUrlInLocalInfile=false)/app");
+
JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl("jdbc:postgresql://db.example/app?allowLoadLocalInfile=true");
+ }
+
+ @Test
+ public void testRejectsRawClosingParenthesisInQuotedLegacyHostPassword() {
+ String url =
"jdbc:mysql://address=(host=db.example)(password='p(a)ss')/app";
+ IllegalArgumentException error =
Assertions.assertThrows(IllegalArgumentException.class,
+ () -> JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(url));
+ Assertions.assertEquals("Invalid MySQL jdbc_url host properties",
error.getMessage());
+ }
+
+ @Test
+ public void testPreservesQuotedLegacyHostPassword() {
+ String url =
"jdbc:mysql://address=(host=db.example)(password='sample')/app";
+ Assertions.assertEquals(url + "?allowLoadLocalInfile=false",
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(url));
+ }
+
+ @Test
+ public void testAllowsQuotedDisabledLegacyHostOption() {
+ String url =
"jdbc:mysql://address=(host=db.example)(allowLoadLocalInfile=\"false\")/app";
+ Assertions.assertEquals(url + "?allowLoadLocalInfile=false",
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(url));
+ }
+
+ @Test
+ public void testRejectsUnsafeGlobalMysqlProperties() {
+ assertMySqlOptionRejected(MYSQL_URL + "allowLoadLocalInfile=true",
"allowLoadLocalInfile");
+ assertMySqlOptionRejected(MYSQL_URL + "ALLOWURLINLOCALINFILE=Yes",
"allowUrlInLocalInfile");
+ assertMySqlOptionRejected(MYSQL_URL +
"allowLoadLocalInfileInPath=%2Fshared", "allowLoadLocalInfileInPath");
+ assertMySqlOptionRejected(MYSQL_URL +
"allowLoadLocalInfile=true&allowLoadLocalInfile=false",
+ "allowLoadLocalInfile");
+ assertMySqlOptionRejected(MYSQL_URL + "allowLoadLocal%49nfile=%74rue",
"allowLoadLocalInfile");
+ }
+
+ @Test
+ public void testRejectsUnsafeHostMysqlProperties() {
+
assertMySqlOptionRejected("jdbc:mysql://address=(host=db.example)(allowLoadLocalInfile=true)/app",
+ "allowLoadLocalInfile");
+ assertMySqlOptionRejected("jdbc:mysql:loadbalance://db.example,"
+ +
"(host=replica.example,allowUrlInLocalInfile=true)/app?allowUrlInLocalInfile=false",
+ "allowUrlInLocalInfile");
+
assertMySqlOptionRejected("jdbc:mysql://[(host=db.example,allowLoadLocalInfileInPath=%2Fshared)]/app",
+ "allowLoadLocalInfileInPath");
+ }
+
+ @Test
+ public void testMalformedMysqlOptionErrorsOmitUrlValues() {
+ IllegalArgumentException error =
Assertions.assertThrows(IllegalArgumentException.class,
+ () -> JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(MYSQL_URL +
"allowLoadLocalInfile=%invalid"));
+ Assertions.assertEquals("Invalid percent encoding in MySQL jdbc_url",
error.getMessage());
+ }
+
+ @Test
+ public void testUsesConfiguredMysqlRestrictionsForGlobalAndHostOptions() {
+ String[] original = Config.jdbc_mysql_restricted_url_parameters;
+ try {
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(MYSQL_URL +
"allowMultiQueries=false");
+ Config.jdbc_mysql_restricted_url_parameters = new String[]
{"allowLoadLocalInfile", "allowMultiQueries"};
+ assertMySqlOptionRejected(MYSQL_URL + "ALLOWMULTIQUERIES=false",
"allowMultiQueries");
+
assertMySqlOptionRejected("jdbc:mysql://address=(host=db.example)(allowMultiQueries=)/app",
+ "allowMultiQueries");
+ assertMySqlOptionRejected(MYSQL_URL + "allowLoadLocalInfile=true",
"allowLoadLocalInfile");
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(MYSQL_URL +
"allowLoadLocalInfile=false");
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(MYSQL_URL +
"allowUrlInLocalInfile=true");
+ } finally {
+ Config.jdbc_mysql_restricted_url_parameters = original;
+ }
+ }
+
+ @Test
+ public void testPreparesCanonicalMysqlDefault() {
+ Assertions.assertEquals(MYSQL_URL + "allowLoadLocalInfile=false",
+
JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl("jdbc:mysql://db.example/app#catalog-note"));
+ Assertions.assertEquals(MYSQL_URL + "allowLoadLocalInfile=NO",
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(MYSQL_URL +
"allowLoadLocalInfile=NO"));
+ }
+
+ @Test
+ public void testPreservesSpacesOutsideMysqlPolicyEdits() {
+ String url = MYSQL_URL + "password=example value";
+ Assertions.assertEquals(MYSQL_URL +
"allowLoadLocalInfile=false&password=example value#catalog-note",
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(url +
"#catalog-note"));
+ String explicit = url + "&allowLoadLocal Infile = false";
+ Assertions.assertEquals(explicit,
JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(explicit));
+ Assertions.assertEquals(url + "& allowLoadLocalInfile=false",
+ JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(url + "& "));
+ assertMySqlOptionRejected(MYSQL_URL + "allowLoadLocal Infile = true",
"allowLoadLocalInfile");
+ }
+
+ @Test
+ public void testChecksAliasesInMysqlHostProperties() {
+ String[] original = Config.jdbc_mysql_restricted_url_parameters;
+ try {
+ Config.jdbc_mysql_restricted_url_parameters = new String[]
{"connectionTimeZone"};
+
assertMySqlOptionRejected("jdbc:mysql://(host=db.example,serverTimezone=UTC)/app",
"connectionTimeZone");
+ } finally {
+ Config.jdbc_mysql_restricted_url_parameters = original;
+ }
+ }
+
+ private static void assertMySqlOptionRejected(String url, String
optionName) {
+ IllegalArgumentException error =
Assertions.assertThrows(IllegalArgumentException.class,
+ () -> JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(url));
+ Assertions.assertEquals("MySQL jdbc_url disallows " + optionName,
error.getMessage());
+ }
+}
diff --git
a/fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcConnectorProvider.java
b/fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcConnectorProvider.java
index 89babe4bc6f..adbffbe6c90 100644
---
a/fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcConnectorProvider.java
+++
b/fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcConnectorProvider.java
@@ -56,6 +56,8 @@ public class JdbcConnectorProvider implements
ConnectorProvider {
// the engine's operator gate applies jdbc_driver_secure_path / the
mandatory rule on CREATE + ALTER.
// The engine masks passwords and complete JDBC connection URLs
wherever it shows catalog properties.
return ConnectorSecuritySurface.ofJdbcDriverUrls(null, "driver_url",
"jdbc.driver_url")
+ .withMysqlJdbcUrlKeys(JdbcCatalogProperties.JDBC_URL,
+ JdbcCatalogProperties.JDBC_PROPERTIES_PREFIX +
JdbcCatalogProperties.JDBC_URL)
.withSensitiveKeys(JdbcCatalogProperties.sensitiveKeys());
}
}
diff --git
a/fe/fe-connector/fe-connector-jdbc/src/test/java/org/apache/doris/connector/jdbc/JdbcConnectorProviderSecuritySurfaceTest.java
b/fe/fe-connector/fe-connector-jdbc/src/test/java/org/apache/doris/connector/jdbc/JdbcConnectorProviderSecuritySurfaceTest.java
index 80fc492f7b0..9229bd413a3 100644
---
a/fe/fe-connector/fe-connector-jdbc/src/test/java/org/apache/doris/connector/jdbc/JdbcConnectorProviderSecuritySurfaceTest.java
+++
b/fe/fe-connector/fe-connector-jdbc/src/test/java/org/apache/doris/connector/jdbc/JdbcConnectorProviderSecuritySurfaceTest.java
@@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
/**
* Pins the JDBC connector's driver_url declaration: the engine's operator
gate checks exactly these keys,
@@ -31,6 +32,12 @@ import java.util.HashSet;
*/
public class JdbcConnectorProviderSecuritySurfaceTest {
+ @Test
+ public void declaresMysqlJdbcUrlKeysInCreatePrecedenceOrder() {
+ ConnectorSecuritySurface surface = new
JdbcConnectorProvider().securitySurface();
+ Assertions.assertEquals(List.of("jdbc_url", "jdbc.jdbc_url"),
surface.mysqlJdbcUrlKeys());
+ }
+
@Test
public void declaresDriverUrlKeysAlwaysLive() {
ConnectorSecuritySurface surface = new
JdbcConnectorProvider().securitySurface();
diff --git
a/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/ConnectorSecuritySurface.java
b/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/ConnectorSecuritySurface.java
index c62baf9193f..b846709bd40 100644
---
a/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/ConnectorSecuritySurface.java
+++
b/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/ConnectorSecuritySurface.java
@@ -30,10 +30,9 @@ import java.util.Set;
/**
* The security-sensitive property surface a connector exposes to the engine's
CREATE / ALTER CATALOG
- * security gates and to the masking of catalog properties. It lets both stay
connector-agnostic: the engine
- * applies its own policies — SSRF endpoint checking, the jdbc driver-url
operator gate, and hiding secret
- * values — to the property keys declared here, instead of branching on the
catalog type. A connector that
- * names no such property returns {@link #EMPTY}.
+ * security gates and to the masking of catalog properties. The engine uses
these declarations to keep its
+ * policies connector-agnostic. Each declaration defines its own scope. A
connector that names no such
+ * property returns {@link #EMPTY}.
*
* <p>The keys are the connector's wire-stable, user-facing property names
(documented aliases included).
* They are declared here, on the provider, rather than read by the engine,
because the engine must not
@@ -44,7 +43,7 @@ public final class ConnectorSecuritySurface {
/** For connectors that name no security-sensitive property. */
public static final ConnectorSecuritySurface EMPTY = new
ConnectorSecuritySurface(
Collections.emptyList(), Collections.emptyList(), null,
Collections.emptyList(),
- Collections.emptyList(), Collections.emptyMap());
+ Collections.emptyList(), Collections.emptyMap(),
Collections.emptyList());
private final List<String> ssrfEndpointKeys;
private final Map<String, Integer> ssrfEndpointDefaultPorts;
@@ -52,16 +51,19 @@ public final class ConnectorSecuritySurface {
private final String jdbcDriverUrlFlavorKey;
private final List<String> sensitiveKeys;
private final List<SensitiveKeyPrefix> sensitiveKeyPrefixes;
+ private final List<String> mysqlJdbcUrlKeys;
private ConnectorSecuritySurface(List<String> ssrfEndpointKeys,
List<String> jdbcDriverUrlKeys,
String jdbcDriverUrlFlavorKey, List<String> sensitiveKeys,
- List<SensitiveKeyPrefix> sensitiveKeyPrefixes, Map<String,
Integer> ssrfEndpointDefaultPorts) {
+ List<SensitiveKeyPrefix> sensitiveKeyPrefixes, Map<String,
Integer> ssrfEndpointDefaultPorts,
+ List<String> mysqlJdbcUrlKeys) {
this.ssrfEndpointKeys = ssrfEndpointKeys;
this.ssrfEndpointDefaultPorts = ssrfEndpointDefaultPorts;
this.jdbcDriverUrlKeys = jdbcDriverUrlKeys;
this.jdbcDriverUrlFlavorKey = jdbcDriverUrlFlavorKey;
this.sensitiveKeys = sensitiveKeys;
this.sensitiveKeyPrefixes = sensitiveKeyPrefixes;
+ this.mysqlJdbcUrlKeys = mysqlJdbcUrlKeys;
}
/**
@@ -76,7 +78,7 @@ public final class ConnectorSecuritySurface {
*/
public static ConnectorSecuritySurface ofSsrfEndpoints(String... keys) {
return new ConnectorSecuritySurface(Arrays.asList(keys),
Collections.emptyList(), null,
- Collections.emptyList(), Collections.emptyList(),
Collections.emptyMap());
+ Collections.emptyList(), Collections.emptyList(),
Collections.emptyMap(), Collections.emptyList());
}
/**
@@ -89,7 +91,7 @@ public final class ConnectorSecuritySurface {
*/
public static ConnectorSecuritySurface ofJdbcDriverUrls(String flavorKey,
String... keys) {
return new ConnectorSecuritySurface(Collections.emptyList(),
Arrays.asList(keys), flavorKey,
- Collections.emptyList(), Collections.emptyList(),
Collections.emptyMap());
+ Collections.emptyList(), Collections.emptyList(),
Collections.emptyMap(), Collections.emptyList());
}
/**
@@ -131,7 +133,8 @@ public final class ConnectorSecuritySurface {
List<String> merged = new ArrayList<>(sensitiveKeys);
merged.addAll(keys);
return new ConnectorSecuritySurface(ssrfEndpointKeys,
jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey,
- Collections.unmodifiableList(merged), sensitiveKeyPrefixes,
ssrfEndpointDefaultPorts);
+ Collections.unmodifiableList(merged), sensitiveKeyPrefixes,
ssrfEndpointDefaultPorts,
+ mysqlJdbcUrlKeys);
}
/**
@@ -150,16 +153,16 @@ public final class ConnectorSecuritySurface {
merged.add(new SensitiveKeyPrefix(prefix,
Collections.unmodifiableList(new
ArrayList<>(Arrays.asList(markers)))));
return new ConnectorSecuritySurface(ssrfEndpointKeys,
jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey,
- sensitiveKeys, Collections.unmodifiableList(merged),
ssrfEndpointDefaultPorts);
+ sensitiveKeys, Collections.unmodifiableList(merged),
ssrfEndpointDefaultPorts, mysqlJdbcUrlKeys);
}
- /** Adds endpoint checks without dropping existing driver-url or
secret-masking declarations. */
+ /** Adds endpoint checks while retaining the existing declarations. */
public ConnectorSecuritySurface withSsrfEndpoints(String... keys) {
Set<String> endpoints = new LinkedHashSet<>(ssrfEndpointKeys);
endpoints.addAll(Arrays.asList(keys));
return new ConnectorSecuritySurface(Collections.unmodifiableList(new
ArrayList<>(endpoints)),
jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey, sensitiveKeys,
sensitiveKeyPrefixes,
- ssrfEndpointDefaultPorts);
+ ssrfEndpointDefaultPorts, mysqlJdbcUrlKeys);
}
/**
@@ -176,7 +179,17 @@ public final class ConnectorSecuritySurface {
ports.put(key, defaultPort);
}
return new ConnectorSecuritySurface(merged.ssrfEndpointKeys,
jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey,
- sensitiveKeys, sensitiveKeyPrefixes,
Collections.unmodifiableMap(ports));
+ sensitiveKeys, sensitiveKeyPrefixes,
Collections.unmodifiableMap(ports), mysqlJdbcUrlKeys);
+ }
+
+ /**
+ * Declares the connection URL keys in lookup order for the MySQL URL
policy on CREATE and ALTER CATALOG.
+ * The first present key is the effective key. When a statement supplies
that key, the engine checks
+ * and prepares its value before persisting it. On ALTER, key precedence
includes the stored properties.
+ */
+ public ConnectorSecuritySurface withMysqlJdbcUrlKeys(String... keys) {
+ return new ConnectorSecuritySurface(ssrfEndpointKeys,
jdbcDriverUrlKeys, jdbcDriverUrlFlavorKey,
+ sensitiveKeys, sensitiveKeyPrefixes, ssrfEndpointDefaultPorts,
List.of(keys));
}
/** Client default ports for scheme-less endpoint keys; absent keys
require an explicit port. */
@@ -194,6 +207,11 @@ public final class ConnectorSecuritySurface {
return jdbcDriverUrlKeys;
}
+ /** The MySQL policy's connection URL keys in precedence order, empty when
not declared. */
+ public List<String> mysqlJdbcUrlKeys() {
+ return mysqlJdbcUrlKeys;
+ }
+
/**
* The flavor key gating {@link #jdbcDriverUrlKeys()}: when non-null,
those keys are live only if this
* property's value is {@code "jdbc"}; {@code null} means always live.
diff --git
a/fe/fe-connector/fe-connector-spi/src/test/java/org/apache/doris/connector/spi/ConnectorSecuritySurfaceTest.java
b/fe/fe-connector/fe-connector-spi/src/test/java/org/apache/doris/connector/spi/ConnectorSecuritySurfaceTest.java
index f36b65f94f5..96e196a56e2 100644
---
a/fe/fe-connector/fe-connector-spi/src/test/java/org/apache/doris/connector/spi/ConnectorSecuritySurfaceTest.java
+++
b/fe/fe-connector/fe-connector-spi/src/test/java/org/apache/doris/connector/spi/ConnectorSecuritySurfaceTest.java
@@ -30,16 +30,39 @@ import java.util.Map;
public class ConnectorSecuritySurfaceTest {
+ @Test
+ public void mysqlJdbcUrlKeysAreOrderedAndImmutable() {
+ String[] keys = {"x.url", "x.legacy_url"};
+ ConnectorSecuritySurface original =
ConnectorSecuritySurface.ofJdbcDriverUrls("x.type", "x.driver_url");
+ ConnectorSecuritySurface surface = original.withMysqlJdbcUrlKeys(keys)
+ .withSsrfEndpoints(80, "x.endpoint")
+ .withSensitiveKeys("x.password")
+ .withSensitiveKeyPrefix("x.auth.", "token");
+ keys[0] = "changed";
+
+ Assertions.assertTrue(original.mysqlJdbcUrlKeys().isEmpty());
+ Assertions.assertEquals(List.of("x.url", "x.legacy_url"),
surface.mysqlJdbcUrlKeys());
+ Assertions.assertThrows(UnsupportedOperationException.class, () ->
surface.mysqlJdbcUrlKeys().clear());
+ Assertions.assertEquals(List.of("x.driver_url"),
surface.jdbcDriverUrlKeys());
+ Assertions.assertEquals("x.type", surface.jdbcDriverUrlFlavorKey());
+ Assertions.assertEquals(List.of("x.endpoint"),
surface.ssrfEndpointKeys());
+ Assertions.assertEquals(Map.of("x.endpoint", 80),
surface.ssrfEndpointDefaultPorts());
+ Assertions.assertEquals(List.of("x.password"),
surface.sensitiveKeys());
+
Assertions.assertTrue(surface.sensitiveKeyPrefixes().get(0).covers("x.auth.token"));
+ }
+
@Test
public void endpointDefaultsAreImmutableAndSurviveSurfaceComposition() {
ConnectorSecuritySurface original =
ConnectorSecuritySurface.ofJdbcDriverUrls("x.type", "x.driver_url")
.withSsrfEndpoints("x.thrift");
ConnectorSecuritySurface surface = original.withSsrfEndpoints(443,
"x.host", "x.alias")
+ .withMysqlJdbcUrlKeys("x.url", "x.legacy_url")
.withSensitiveKeys("x.secret").withSensitiveKeyPrefix("x.credentials.")
.withSsrfEndpoints("x.other");
Assertions.assertEquals(Arrays.asList("x.thrift", "x.host", "x.alias",
"x.other"),
surface.ssrfEndpointKeys());
Assertions.assertEquals(Map.of("x.host", 443, "x.alias", 443),
surface.ssrfEndpointDefaultPorts());
+ Assertions.assertEquals(List.of("x.url", "x.legacy_url"),
surface.mysqlJdbcUrlKeys());
Assertions.assertTrue(original.ssrfEndpointDefaultPorts().isEmpty());
Assertions.assertTrue(ConnectorSecuritySurface.EMPTY.ssrfEndpointDefaultPorts().isEmpty());
Assertions.assertEquals(Collections.singletonList("x.driver_url"),
surface.jdbcDriverUrlKeys());
diff --git
a/fe/fe-connector/fe-connector-spi/src/test/resources/connector-plugin-surface.txt
b/fe/fe-connector/fe-connector-spi/src/test/resources/connector-plugin-surface.txt
index c6498f150a7..156b7a909b2 100644
---
a/fe/fe-connector/fe-connector-spi/src/test/resources/connector-plugin-surface.txt
+++
b/fe/fe-connector/fe-connector-spi/src/test/resources/connector-plugin-surface.txt
@@ -106,6 +106,7 @@
org.apache.doris.connector.spi.ConnectorProvider#validateProperties(java.util.Ma
org.apache.doris.connector.spi.ConnectorProvider#validatePropertiesForUpdate(java.util.Map,java.util.Map):void
org.apache.doris.connector.spi.ConnectorSecuritySurface#jdbcDriverUrlFlavorKey():java.lang.String
org.apache.doris.connector.spi.ConnectorSecuritySurface#jdbcDriverUrlKeys():java.util.List
+org.apache.doris.connector.spi.ConnectorSecuritySurface#mysqlJdbcUrlKeys():java.util.List
org.apache.doris.connector.spi.ConnectorSecuritySurface#ofJdbcDriverUrls(java.lang.String,java.lang.String[]):org.apache.doris.connector.spi.ConnectorSecuritySurface
org.apache.doris.connector.spi.ConnectorSecuritySurface#ofSensitiveKeyPrefix(java.lang.String,java.lang.String[]):org.apache.doris.connector.spi.ConnectorSecuritySurface
org.apache.doris.connector.spi.ConnectorSecuritySurface#ofSensitiveKeys(java.lang.String[]):org.apache.doris.connector.spi.ConnectorSecuritySurface
@@ -114,6 +115,7 @@
org.apache.doris.connector.spi.ConnectorSecuritySurface#sensitiveKeyPrefixes():j
org.apache.doris.connector.spi.ConnectorSecuritySurface#sensitiveKeys():java.util.List
org.apache.doris.connector.spi.ConnectorSecuritySurface#ssrfEndpointDefaultPorts():java.util.Map
org.apache.doris.connector.spi.ConnectorSecuritySurface#ssrfEndpointKeys():java.util.List
+org.apache.doris.connector.spi.ConnectorSecuritySurface#withMysqlJdbcUrlKeys(java.lang.String[]):org.apache.doris.connector.spi.ConnectorSecuritySurface
org.apache.doris.connector.spi.ConnectorSecuritySurface#withSensitiveKeyPrefix(java.lang.String,java.lang.String[]):org.apache.doris.connector.spi.ConnectorSecuritySurface
org.apache.doris.connector.spi.ConnectorSecuritySurface#withSensitiveKeys(java.lang.String[]):org.apache.doris.connector.spi.ConnectorSecuritySurface
org.apache.doris.connector.spi.ConnectorSecuritySurface#withSensitiveKeys(java.util.Collection):org.apache.doris.connector.spi.ConnectorSecuritySurface
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorFactory.java
b/fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorFactory.java
index 2d93cd7ac18..85684b8a5e2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorFactory.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorFactory.java
@@ -109,6 +109,16 @@ public final class ConnectorFactory {
return mgr.findProvider(catalogType, properties);
}
+ /** Finds a provider eligible to back a standalone catalog, without
creating a connector. */
+ public static Optional<ConnectorProvider> findStandaloneCatalogProvider(
+ String catalogType, Map<String, String> properties) {
+ ConnectorPluginManager mgr = pluginManager;
+ if (mgr == null) {
+ return Optional.empty();
+ }
+ return mgr.findStandaloneCatalogProvider(catalogType, properties);
+ }
+
/**
* The reader of {@code format} for the file table functions, when a
connector plugin claims the format
* ({@code ConnectorProvider#getFileFormats}); empty when none does or the
plugin manager is not initialized.
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorPluginManager.java
b/fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorPluginManager.java
index 89b79a463e6..25245a8b969 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorPluginManager.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorPluginManager.java
@@ -610,8 +610,17 @@ public class ConnectorPluginManager {
* @return the matching provider, or empty if none matches
*/
public Optional<ConnectorProvider> findProvider(String catalogType,
Map<String, String> properties) {
+ return findProvider(catalogType, properties, false);
+ }
+
+ Optional<ConnectorProvider> findStandaloneCatalogProvider(String
catalogType, Map<String, String> properties) {
+ return findProvider(catalogType, properties, true);
+ }
+
+ private Optional<ConnectorProvider> findProvider(String catalogType,
Map<String, String> properties,
+ boolean standaloneOnly) {
for (ConnectorProvider provider : providers) {
- if (provider.supports(catalogType, properties)) {
+ if (provider.supports(catalogType, properties) && (!standaloneOnly
|| provider.isStandaloneCatalogType())) {
return Optional.of(provider);
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogFactory.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogFactory.java
index 9ad93fd80bf..db70b874f30 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogFactory.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogFactory.java
@@ -21,9 +21,12 @@ import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.Resource;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.FeConstants;
+import org.apache.doris.common.security.JdbcCatalogUrlSecurity;
import org.apache.doris.connector.ConnectorFactory;
import org.apache.doris.connector.DefaultConnectorContext;
import org.apache.doris.connector.spi.Connector;
+import org.apache.doris.connector.spi.ConnectorProvider;
+import org.apache.doris.connector.spi.ConnectorSecuritySurface;
import org.apache.doris.datasource.doris.RemoteDorisExternalCatalog;
import org.apache.doris.datasource.log.CatalogLog;
import org.apache.doris.datasource.plugin.PluginDrivenExternalCatalog;
@@ -35,6 +38,7 @@ import com.google.common.collect.ImmutableSet;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -75,6 +79,31 @@ public class CatalogFactory {
cmd.getComment(), cmd.getProperties(), false);
}
+ static Map<String, String> prepareCatalogProperties(String catalogType,
Map<String, String> effectiveProperties,
+ Map<String, String> submittedProperties) throws DdlException {
+ ConnectorSecuritySurface surface = ConnectorFactory
+ .findStandaloneCatalogProvider(catalogType,
effectiveProperties)
+ .map(ConnectorProvider::securitySurface)
+ .orElse(ConnectorSecuritySurface.EMPTY);
+ String key =
surface.mysqlJdbcUrlKeys().stream().filter(effectiveProperties::containsKey)
+ .findFirst().orElse(null);
+ String url = key != null && submittedProperties.containsKey(key) ?
effectiveProperties.get(key) : null;
+ if (url == null) {
+ return submittedProperties;
+ }
+ try {
+ String preparedUrl =
JdbcCatalogUrlSecurity.prepareMySqlJdbcUrl(url);
+ if (url.equals(preparedUrl)) {
+ return submittedProperties;
+ }
+ Map<String, String> preparedProps = new
HashMap<>(submittedProperties);
+ preparedProps.put(key, preparedUrl);
+ return preparedProps;
+ } catch (IllegalArgumentException e) {
+ throw new DdlException(e.getMessage());
+ }
+ }
+
private static CatalogIf createCatalog(long catalogId, String name, String
resource, String comment,
Map<String, String> props, boolean isReplay) throws DdlException {
// get catalog type from resource or properties
@@ -97,15 +126,16 @@ public class CatalogFactory {
catalogType = type.toLowerCase();
}
- // create catalog
- ExternalCatalog catalog = null;
-
// Ensure the resolved catalog type is always persisted in props.
// For resource-backed catalogs, the type is derived from the Resource
object
// and may not be present in the original props. Without this, GSON
deserialization
// after FE restart would lose the type and initLocalObjectsImpl()
would fail.
props.putIfAbsent(CatalogMgr.CATALOG_TYPE_PROP, catalogType);
+ if (!isReplay) {
+ props = prepareCatalogProperties(catalogType, props, props);
+ }
+
// Ask the connector plugins first. Any registered provider that
claims this type and can stand on its
// own as a catalog wins; the engine keeps no list of accepted types,
so installing a plugin is all it
// takes to make its type usable here. Returns null when nothing
claims it — including for a
@@ -132,6 +162,7 @@ public class CatalogFactory {
catalogType, name, e);
spiConnector = null;
}
+ ExternalCatalog catalog;
if (spiConnector != null) {
LOG.info("Created plugin-driven catalog '{}' via SPI connector for
type '{}'",
name, catalogType);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
index 49212699b85..264cb45256a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
@@ -454,6 +454,7 @@ public class CatalogMgr implements Writable,
GsonPostProcessable {
readUnlock();
}
+ Map<String, String> preparedUpdates = updates;
if (catalog instanceof ExternalCatalog) {
// Validate and journal the effective mapping policy so older
followers replay it verbatim.
for (String marker : new String[]
{CatalogProperty.ENABLE_MAPPING_VARBINARY,
@@ -462,18 +463,20 @@ public class CatalogMgr implements Writable,
GsonPostProcessable {
updates.put(marker, "true");
}
}
- }
-
- if (catalog instanceof ExternalCatalog) {
Map<String, String> effectiveProperties =
Maps.newHashMap(oldProperties);
effectiveProperties.putAll(updates);
((ExternalCatalog)
catalog).checkSubmittedMetaCacheProperties(effectiveProperties, updates);
+ if (catalog instanceof PluginDrivenExternalCatalog) {
+ // Prepare only the effective submitted URL, starting from
the original update on each retry.
+ preparedUpdates = CatalogFactory.prepareCatalogProperties(
+ catalog.getType(), effectiveProperties, updates);
+ }
}
// Filesystem binding may read Hadoop XML files. Validate the
detached snapshot before
// taking the global catalog write lock, then retry if another
ALTER changed the snapshot.
boolean validatedWithoutMutation = catalog instanceof
ExternalCatalog
- && validateCatalogPropsBeforeUpdate((ExternalCatalog)
catalog, oldProperties, updates);
+ && validateCatalogPropsBeforeUpdate((ExternalCatalog)
catalog, oldProperties, preparedUpdates);
Runnable resourceCleanup = () -> { };
writeLock();
try {
@@ -483,7 +486,7 @@ public class CatalogMgr implements Writable,
GsonPostProcessable {
}
CatalogLog log = new CatalogLog();
log.setCatalogId(catalog.getId());
- log.setNewProps(updates);
+ log.setNewProps(preparedUpdates);
resourceCleanup = applyAlterCatalogProps(
log, oldProperties, false, true,
validatedWithoutMutation);
Env.getCurrentEnv().getEditLog().logCatalogLog(OperationType.OP_ALTER_CATALOG_PROPS,
log);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/CatalogFactoryPluginRoutingTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/CatalogFactoryPluginRoutingTest.java
index 2707e406acb..be1480abfc1 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/datasource/CatalogFactoryPluginRoutingTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/CatalogFactoryPluginRoutingTest.java
@@ -17,14 +17,20 @@
package org.apache.doris.datasource;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.JdbcResource;
+import org.apache.doris.catalog.ResourceMgr;
+import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.FeConstants;
import org.apache.doris.connector.ConnectorFactory;
import org.apache.doris.connector.ConnectorPluginManager;
+import org.apache.doris.connector.jdbc.JdbcConnectorProvider;
import org.apache.doris.connector.spi.Connector;
import org.apache.doris.connector.spi.ConnectorContext;
import org.apache.doris.connector.spi.ConnectorMetadata;
import org.apache.doris.connector.spi.ConnectorProvider;
+import org.apache.doris.connector.spi.ConnectorSecuritySurface;
import org.apache.doris.connector.spi.ConnectorSession;
import org.apache.doris.connector.spi.ConnectorTestResult;
import org.apache.doris.datasource.log.CatalogLog;
@@ -32,16 +38,29 @@ import
org.apache.doris.datasource.plugin.PluginDrivenExternalCatalog;
import org.apache.doris.filesystem.properties.S3CompatibleFileSystemProperties;
import org.apache.doris.fs.FileSystemFactory;
import org.apache.doris.fs.FileSystemPluginManager;
+import org.apache.doris.mysql.privilege.AccessControllerManager;
import org.apache.doris.nereids.trees.plans.commands.CreateCatalogCommand;
+import org.apache.doris.persist.EditLog;
+import org.apache.doris.persist.OperationType;
import com.google.common.collect.Maps;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
/**
* How {@link CatalogFactory} decides which catalog type is served by what.
@@ -57,12 +76,17 @@ import java.util.concurrent.atomic.AtomicInteger;
public class CatalogFactoryPluginRoutingTest {
private static final String THIRD_PARTY_TYPE = "acme-lake";
+ private static final ConnectorSecuritySurface MYSQL_URL_SURFACE =
ConnectorSecuritySurface.EMPTY
+ .withMysqlJdbcUrlKeys("x.url", "x.legacy_url");
+
+ private ConnectorPluginManager connectorManager;
@BeforeEach
void setUp() {
// The plugin manager is a static singleton shared with every other
test in the fork: start from a known
// empty one rather than inheriting whatever the previous test class
registered.
- ConnectorFactory.initPluginManager(new ConnectorPluginManager());
+ connectorManager = new ConnectorPluginManager();
+ ConnectorFactory.initPluginManager(connectorManager);
}
@AfterEach
@@ -85,6 +109,189 @@ public class CatalogFactoryPluginRoutingTest {
Assertions.assertInstanceOf(PluginDrivenExternalCatalog.class,
catalog);
}
+ @Test
+ void declaredMysqlRestrictionsRunBeforePluginCreationAndSkipReplay()
throws Exception {
+ AtomicInteger consulted = registerProvider(THIRD_PARTY_TYPE, true,
MYSQL_URL_SURFACE, ignored -> {});
+ AtomicInteger siblingConsulted = registerProvider(THIRD_PARTY_TYPE,
false);
+ Map<String, String> properties = props(THIRD_PARTY_TYPE);
+ String url = "jdbc:mysql://db.example/app?allowLoadLocalInfile=true";
+ properties.put("x.legacy_url", url);
+
+ DdlException error = Assertions.assertThrows(DdlException.class,
+ () -> CatalogFactory.createFromCommand(1L, command("acme_ctl",
properties)));
+ Assertions.assertEquals("MySQL jdbc_url disallows
allowLoadLocalInfile", error.getDetailMessage());
+ Assertions.assertEquals(0, consulted.get());
+
+ CatalogIf<?> replayed =
CatalogFactory.createFromLog(catalogLog("acme_ctl", properties));
+ Assertions.assertEquals(url,
replayed.getProperties().get("x.legacy_url"));
+ Assertions.assertEquals(1, consulted.get());
+ Assertions.assertEquals(0, siblingConsulted.get());
+ }
+
+ @Test
+ void mysqlCreatePassesThePreparedEffectiveUrlToThePluginAndCatalog()
throws Exception {
+ Map<String, String> connectorProperties = Maps.newHashMap();
+ AtomicInteger consulted = registerProvider(THIRD_PARTY_TYPE, true,
MYSQL_URL_SURFACE,
+ connectorProperties::putAll);
+ Map<String, String> properties = props(THIRD_PARTY_TYPE);
+ String url = "jdbc:mysql://db.example/app?password=example
value#catalog-note";
+ String aliasUrl = "jdbc:mysql://alias.example/app";
+ properties.put("x.url", url);
+ properties.put("x.legacy_url", aliasUrl);
+
+ CatalogIf<?> created = CatalogFactory.createFromCommand(1L,
command("acme_ctl", properties));
+
+ String expected =
"jdbc:mysql://db.example/app?allowLoadLocalInfile=false&"
+ + "password=example value#catalog-note";
+ Assertions.assertEquals(expected, connectorProperties.get("x.url"));
+ Assertions.assertEquals(aliasUrl,
connectorProperties.get("x.legacy_url"));
+ Map<String, String> persistedProperties =
created.constructEditLog().getProps();
+ Assertions.assertEquals(expected, persistedProperties.get("x.url"));
+ Assertions.assertEquals(aliasUrl,
persistedProperties.get("x.legacy_url"));
+ Assertions.assertEquals(1, consulted.get());
+ }
+
+ @Test
+ void mysqlCreateWithoutADeclarationLeavesTheUrlAsWritten() throws
Exception {
+ AtomicInteger consulted = registerProvider("jdbc", true);
+ Map<String, String> properties = props("jdbc");
+ String url = "jdbc:mysql://db.example/app";
+ properties.put("jdbc_url", url);
+
+ CatalogIf<?> created = CatalogFactory.createFromCommand(1L,
command("jdbc_ctl", properties));
+
+ Assertions.assertEquals(url, created.getProperties().get("jdbc_url"));
+ Assertions.assertEquals(1, consulted.get());
+ }
+
+ @Test
+ void legacyResourceCreateRunsDeclaredMysqlRestrictions() {
+ AtomicInteger consulted = registerProvider("jdbc", true,
MYSQL_URL_SURFACE, ignored -> {});
+ Env env = Mockito.mock(Env.class);
+ ResourceMgr resources = Mockito.mock(ResourceMgr.class);
+ Mockito.when(env.getResourceMgr()).thenReturn(resources);
+ Mockito.when(resources.getResource("legacy_jdbc")).thenReturn(new
JdbcResource("legacy_jdbc"));
+ Map<String, String> properties = Maps.newHashMap();
+ properties.put("x.url",
"jdbc:mysql://db.example/app?allowLoadLocalInfile=true");
+
+ try (MockedStatic<Env> mockedEnv = Mockito.mockStatic(Env.class)) {
+ mockedEnv.when(Env::getCurrentEnv).thenReturn(env);
+ CreateCatalogCommand create = new CreateCatalogCommand("jdbc_ctl",
false, "legacy_jdbc", "", properties);
+ DdlException error = Assertions.assertThrows(DdlException.class,
+ () -> CatalogFactory.createFromCommand(1L, create));
+ Assertions.assertEquals("MySQL jdbc_url disallows
allowLoadLocalInfile", error.getDetailMessage());
+ }
+ Assertions.assertEquals("jdbc",
properties.get(CatalogMgr.CATALOG_TYPE_PROP));
+ Assertions.assertEquals(0, consulted.get());
+ }
+
+ @Test
+ void mysqlAlterJournalsPreparedEffectiveUrl() throws Exception {
+ connectorManager.registerProvider(new JdbcConnectorProvider());
+ CatalogMgr manager = new CatalogMgr();
+ List<CatalogLog> journal = new ArrayList<>();
+ Env env = journalEnv(journal);
+ String aliasUrl = "jdbc:mysql://alias.example/app?connectTimeout=1000";
+ String shortUrl = "jdbc:mysql://db.example/app";
+ Map<String, String> submitted = Map.of("jdbc_url", shortUrl,
"jdbc.jdbc_url", aliasUrl,
+ "connection_pool_max_size", "12");
+ try (MockedStatic<Env> mockedEnv = Mockito.mockStatic(Env.class)) {
+ mockedEnv.when(Env::getCurrentEnv).thenReturn(env);
+
manager.replayCreateCatalog(jdbcCatalogLog("jdbc:mysql://old.example/app"));
+
+ manager.alterCatalogProps("jdbc_ctl", Map.of("jdbc.jdbc_url",
aliasUrl));
+ String preparedAlias = aliasUrl + "&allowLoadLocalInfile=false";
+ Assertions.assertEquals(Map.of("jdbc.jdbc_url", preparedAlias),
journal.get(0).getNewProps());
+ Assertions.assertEquals(preparedAlias,
manager.getCatalog("jdbc_ctl").getProperties().get("jdbc.jdbc_url"));
+
+ manager.alterCatalogProps("jdbc_ctl", submitted);
+ String preparedShort = shortUrl + "?allowLoadLocalInfile=false";
+ Map<String, String> expected = Map.of("jdbc_url", preparedShort,
"jdbc.jdbc_url", aliasUrl,
+ "connection_pool_max_size", "12");
+ Assertions.assertEquals(2, journal.size());
+ Assertions.assertEquals(expected, journal.get(1).getNewProps());
+
Assertions.assertTrue(manager.getCatalog("jdbc_ctl").getProperties().entrySet()
+ .containsAll(expected.entrySet()));
+ Assertions.assertEquals(shortUrl, submitted.get("jdbc_url"));
+ }
+ }
+
+ @Test
+ void mysqlAlterSkipsStoredUrlUntilSubmittedAndReplayKeepsTheRecord()
throws Exception {
+ connectorManager.registerProvider(new JdbcConnectorProvider());
+ CatalogMgr manager = new CatalogMgr();
+ List<CatalogLog> journal = new ArrayList<>();
+ Env env = journalEnv(journal);
+ String legacyUrl = "jdbc:mysql://old.example/app?connectTimeout=1000";
+ String[] savedOptions = Config.jdbc_mysql_restricted_url_parameters;
+ Config.jdbc_mysql_restricted_url_parameters = new String[]
{"allowLoadLocalInfile", "connectTimeout"};
+ try (MockedStatic<Env> mockedEnv = Mockito.mockStatic(Env.class)) {
+ mockedEnv.when(Env::getCurrentEnv).thenReturn(env);
+ manager.replayCreateCatalog(jdbcCatalogLog(legacyUrl));
+ CatalogIf<?> catalog = manager.getCatalog("jdbc_ctl");
+
+ Map<String, String> unrelatedUpdate =
Map.of("connection_pool_max_size", "12");
+ manager.alterCatalogProps("jdbc_ctl", unrelatedUpdate);
+ Assertions.assertEquals(unrelatedUpdate,
journal.get(0).getNewProps());
+ Assertions.assertEquals(legacyUrl,
catalog.getProperties().get("jdbc.jdbc_url"));
+
+ Map<String, String> previous = Map.copyOf(catalog.getProperties());
+ DdlException error = Assertions.assertThrows(DdlException.class,
+ () -> manager.alterCatalogProps("jdbc_ctl",
Map.of("jdbc.jdbc_url", legacyUrl,
+ "connection_pool_max_size", "13")));
+ Assertions.assertEquals("MySQL jdbc_url disallows connectTimeout",
error.getDetailMessage());
+ Assertions.assertEquals(previous, catalog.getProperties());
+ Assertions.assertEquals(1, journal.size());
+
+ String replayedUrl =
"jdbc:mysql://replay.example/app?connectTimeout=2000";
+ CatalogLog replayed = new CatalogLog();
+ replayed.setCatalogId(catalog.getId());
+ replayed.setNewProps(Map.of("jdbc_url", replayedUrl));
+ manager.replayAlterCatalogProps(replayed, null, true);
+ Assertions.assertEquals(replayedUrl,
catalog.getProperties().get("jdbc_url"));
+ Assertions.assertEquals(Map.of("jdbc_url", replayedUrl),
replayed.getNewProps());
+ Assertions.assertEquals(1, journal.size());
+ } finally {
+ Config.jdbc_mysql_restricted_url_parameters = savedOptions;
+ }
+ }
+
+ @Test
+ void mysqlAlterRetryReevaluatesAliasPrecedence() throws Exception {
+ CatalogMgr manager = new CatalogMgr();
+ String aliasUrl = "jdbc:mysql://alias.example/app";
+ String shortUrl = "jdbc:mysql://db.example/app";
+ AtomicBoolean firstAliasValidation = new AtomicBoolean(true);
+ connectorManager.registerProvider(new JdbcConnectorProvider() {
+ @Override
+ public void validatePropertiesForUpdate(Map<String, String>
currentProperties,
+ Map<String, String> updatedProperties) {
+ super.validatePropertiesForUpdate(currentProperties,
updatedProperties);
+ if (updatedProperties.containsKey("jdbc.jdbc_url") &&
firstAliasValidation.getAndSet(false)) {
+ Assertions.assertEquals(aliasUrl +
"?allowLoadLocalInfile=false",
+ updatedProperties.get("jdbc.jdbc_url"));
+ // Change the stored snapshot before the outer ALTER takes
the write lock.
+ Assertions.assertDoesNotThrow(() ->
manager.alterCatalogProps("jdbc_ctl",
+ Map.of("jdbc_url", shortUrl)));
+ }
+ }
+ });
+ List<CatalogLog> journal = new ArrayList<>();
+ Env env = journalEnv(journal);
+ try (MockedStatic<Env> mockedEnv = Mockito.mockStatic(Env.class)) {
+ mockedEnv.when(Env::getCurrentEnv).thenReturn(env);
+
manager.replayCreateCatalog(jdbcCatalogLog("jdbc:mysql://old.example/app"));
+
+ manager.alterCatalogProps("jdbc_ctl", Map.of("jdbc.jdbc_url",
aliasUrl));
+
+ Assertions.assertEquals(2, journal.size());
+ Assertions.assertEquals(Map.of("jdbc_url", shortUrl +
"?allowLoadLocalInfile=false"),
+ journal.get(0).getNewProps());
+ Assertions.assertEquals(Map.of("jdbc.jdbc_url", aliasUrl),
journal.get(1).getNewProps());
+ Assertions.assertEquals(aliasUrl,
manager.getCatalog("jdbc_ctl").getProperties().get("jdbc.jdbc_url"));
+ }
+ }
+
@Test
void siblingOnlyTypeStillCannotBeCreatedAsACatalog() {
// A sibling-only connector (hudi is the real one) serves tables
parasitic on another connector's
@@ -223,10 +430,14 @@ public class CatalogFactoryPluginRoutingTest {
}
/** Registers a single fake provider and returns a counter of how often it
was asked to build a connector. */
- private static AtomicInteger registerProvider(String type, boolean
standalone) {
+ private AtomicInteger registerProvider(String type, boolean standalone) {
+ return registerProvider(type, standalone,
ConnectorSecuritySurface.EMPTY, ignored -> {});
+ }
+
+ private AtomicInteger registerProvider(String type, boolean standalone,
+ ConnectorSecuritySurface surface, Consumer<Map<String, String>>
onCreate) {
AtomicInteger consulted = new AtomicInteger();
- ConnectorPluginManager manager = new ConnectorPluginManager();
- manager.registerProvider(new ConnectorProvider() {
+ connectorManager.registerProvider(new ConnectorProvider() {
@Override
public String getType() {
return type;
@@ -237,9 +448,15 @@ public class CatalogFactoryPluginRoutingTest {
return standalone;
}
+ @Override
+ public ConnectorSecuritySurface securitySurface() {
+ return surface;
+ }
+
@Override
public Connector create(Map<String, String> properties,
ConnectorContext context) {
consulted.incrementAndGet();
+ onCreate.accept(properties);
return new Connector() {
@Override
public ConnectorMetadata getMetadata(ConnectorSession
session) {
@@ -252,7 +469,6 @@ public class CatalogFactoryPluginRoutingTest {
};
}
});
- ConnectorFactory.initPluginManager(manager);
return consulted;
}
@@ -272,6 +488,34 @@ public class CatalogFactoryPluginRoutingTest {
return log;
}
+ private static CatalogLog jdbcCatalogLog(String url) {
+ Map<String, String> properties = props("jdbc");
+ properties.put("jdbc.jdbc_url", url);
+ properties.put("driver_url", "mysql-example.jar");
+ properties.put("driver_class", "com.mysql.cj.jdbc.Driver");
+ return catalogLog("jdbc_ctl", properties);
+ }
+
+ private static Env journalEnv(List<CatalogLog> journal) {
+ Env env = Mockito.mock(Env.class);
+ EditLog editLog = Mockito.mock(EditLog.class);
+ ExternalMetaCacheMgr cacheMgr =
Mockito.mock(ExternalMetaCacheMgr.class);
+ AccessControllerManager accessManager =
Mockito.mock(AccessControllerManager.class);
+ Mockito.when(env.getEditLog()).thenReturn(editLog);
+ Mockito.when(env.getExtMetaCacheMgr()).thenReturn(cacheMgr);
+ Mockito.when(env.getAccessManager()).thenReturn(accessManager);
+ Mockito.when(accessManager.detachAccessController(Mockito.anyString(),
Mockito.anyLong()))
+ .thenReturn(() -> { });
+ Mockito.doAnswer(invocation -> {
+ CatalogLog log = invocation.getArgument(1);
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ log.write(new DataOutputStream(bytes));
+ journal.add(CatalogLog.read(new DataInputStream(new
ByteArrayInputStream(bytes.toByteArray()))));
+ return null;
+
}).when(editLog).logCatalogLog(Mockito.eq(OperationType.OP_ALTER_CATALOG_PROPS),
Mockito.any());
+ return env;
+ }
+
private static CreateCatalogCommand command(String name, Map<String,
String> props) {
return new CreateCatalogCommand(name, false, "", "", props);
}
diff --git
a/fe/fe-foundation/src/main/java/org/apache/doris/foundation/security/JdbcDriverUrlSecurity.java
b/fe/fe-foundation/src/main/java/org/apache/doris/foundation/security/JdbcDriverUrlSecurity.java
index 98970097b83..823d46c9817 100644
---
a/fe/fe-foundation/src/main/java/org/apache/doris/foundation/security/JdbcDriverUrlSecurity.java
+++
b/fe/fe-foundation/src/main/java/org/apache/doris/foundation/security/JdbcDriverUrlSecurity.java
@@ -17,8 +17,15 @@
package org.apache.doris.foundation.security;
+import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
@@ -60,6 +67,30 @@ public final class JdbcDriverUrlSecurity {
// This intentionally forbids any path separator, so it can never escape
the drivers directory.
private static final Pattern SAFE_DRIVER_FILE_NAME =
Pattern.compile("^[A-Za-z0-9._-]+\\.jar$");
+ private static final String MYSQL_PREFIX = "jdbc:mysql";
+ private static final Pattern MYSQL_URL_PREFIX =
Pattern.compile("jdbc:mysql[\\w+:%]*\\s*(?<authority>//)?",
+ Pattern.CASE_INSENSITIVE);
+ private static final String ALLOW_LOAD_LOCAL_INFILE =
"allowLoadLocalInfile";
+ private static final String ALLOW_URL_IN_LOCAL_INFILE =
"allowUrlInLocalInfile";
+ private static final String ALLOW_LOAD_LOCAL_INFILE_IN_PATH =
"allowLoadLocalInfileInPath";
+
+ // Classic protocol aliases from Connector/J 8.4 PropertyKey.
+ private static final Map<String, String> MYSQL_OPTION_ALIASES =
Map.ofEntries(
+ Map.entry("namedpipepath", "path"),
+ Map.entry("allowslavedownconnections",
"allowreplicadownconnections"),
+ Map.entry("allowmasterdownconnections",
"allowsourcedownconnections"),
+ Map.entry("servertimezone", "connectiontimezone"),
+ Map.entry("haenablejmx", "ha.enablejmx"),
+ Map.entry("haloadbalancestrategy", "ha.loadbalancestrategy"),
+ Map.entry("loadbalanceblacklisttimeout",
"loadbalanceblocklisttimeout"),
+ Map.entry("nullcatalogmeanscurrent", "nulldatabasemeanscurrent"),
+ Map.entry("queriesbeforeretrymaster", "queriesbeforeretrysource"),
+ Map.entry("parseinfocachefactory", "queryinfocachefactory"),
+ Map.entry("readfrommasterwhennoslaves",
"readfromsourcewhennoreplicas"),
+ Map.entry("secondsbeforeretrymaster", "secondsbeforeretrysource"),
+ Map.entry("enabledsslciphersuites", "tlsciphersuites"),
+ Map.entry("enabledtlsprotocols", "tlsversions"));
+
private JdbcDriverUrlSecurity() {
}
@@ -99,4 +130,187 @@ public final class JdbcDriverUrlSecurity {
}
}
}
+
+ /** Validates a MySQL catalog URL and prepares it for Connector/J versions
with different defaults. */
+ public static String prepareMySqlJdbcUrl(String url, String[]
restrictedOptionNames) {
+ if (url == null) {
+ return null;
+ }
+ // Check the same space-stripped URL the connector will use, while
retaining the original text.
+ String jdbcUrl = url.replace(" ", "").trim();
+ if (!jdbcUrl.regionMatches(true, 0, MYSQL_PREFIX, 0,
MYSQL_PREFIX.length())) {
+ return url;
+ }
+ int fragment = jdbcUrl.indexOf('#');
+ String modernUrl = fragment < 0 ? jdbcUrl : jdbcUrl.substring(0,
fragment).trim();
+ int queryStart = modernUrl.indexOf('?');
+ String base = queryStart < 0 ? modernUrl : modernUrl.substring(0,
queryStart);
+ Matcher prefix = MYSQL_URL_PREFIX.matcher(base);
+ if (!prefix.lookingAt()
+ || (prefix.group("authority") == null && prefix.end() <
base.length()
+ && base.charAt(prefix.end()) != '/')) {
+ throw new IllegalArgumentException("Invalid MySQL jdbc_url");
+ }
+
+ Map<String, String> restrictedOptions = new HashMap<>();
+ for (String option : restrictedOptionNames) {
+ restrictedOptions.putIfAbsent(normalizeMysqlOption(option),
option);
+ }
+
+ String query = queryStart < 0 ? null : modernUrl.substring(queryStart
+ 1);
+ boolean hasCanonicalLocalInfileOption = query != null &&
checkProperties(query, "&", restrictedOptions);
+ boolean preserveQueryFragment = fragment >= 0 && query != null;
+ if (preserveQueryFragment) {
+ // Connector/J 5.1 includes the fragment in query values and reads
any following options.
+ checkLegacyMysqlQuery(jdbcUrl.substring(queryStart + 1),
restrictedOptions);
+ } else if (fragment >= 0) {
+ // Keep stripping fragments outside the query, where 5.1 could
read them as host or database text.
+ url = url.substring(0, url.indexOf('#')).trim();
+ }
+ if (prefix.group("authority") != null) {
+ checkHostProperties(base, prefix.end(), restrictedOptions);
+ }
+ if
(restrictedOptions.containsKey(normalizeMysqlOption(ALLOW_LOAD_LOCAL_INFILE))
+ && !hasCanonicalLocalInfileOption) {
+ String defaultOption = ALLOW_LOAD_LOCAL_INFILE + "=false";
+ if (preserveQueryFragment) {
+ // Insert a separate option that both drivers see without
splitting an existing value.
+ int rawQueryStart = url.indexOf('?') + 1;
+ return url.substring(0, rawQueryStart) + defaultOption + "&" +
url.substring(rawQueryStart);
+ }
+ String separator = query == null ? "?" : (query.isEmpty() ||
modernUrl.endsWith("&") ? "" : "&");
+ url += separator + defaultOption;
+ }
+ return url;
+ }
+
+ private static void checkHostProperties(String base, int start,
Map<String, String> restrictedOptions) {
+ boolean addressFormat = false;
+ int previousEnd = start;
+ for (int i = start; i < base.length(); i++) {
+ char current = base.charAt(i);
+ if (current == '/') {
+ return;
+ }
+ if (current == ')') {
+ throw new IllegalArgumentException("Invalid MySQL jdbc_url
host properties");
+ }
+ if (current != '(') {
+ continue;
+ }
+ String prefix = base.substring(previousEnd, i).trim();
+ if (!prefix.isEmpty()) {
+ addressFormat =
prefix.toLowerCase(Locale.ROOT).endsWith("address=");
+ }
+ int groupEnd = findHostPropertyEnd(base, i + 1, addressFormat);
+ String properties = base.substring(i + 1, groupEnd);
+ // address=(key=value)(key=value) has one property per group.
+ // A (key=value,key=value) host has a comma-separated list in one
group.
+ if (addressFormat) {
+ checkProperty(properties, restrictedOptions, true);
+ } else {
+ checkProperties(properties, ",", restrictedOptions);
+ }
+ previousEnd = groupEnd + 1;
+ i = groupEnd;
+ }
+ }
+
+ private static int findHostPropertyEnd(String authority, int start,
boolean addressFormat) {
+ int rawGroupEnd = authority.indexOf(')', start);
+ for (int i = start; i <= rawGroupEnd; i++) {
+ char current = authority.charAt(i);
+ if (current == ')') {
+ return i;
+ }
+ if (current == '(' || current == '/') {
+ break;
+ }
+ // Connector/J 5.1 allows quoted delimiters in legacy properties.
+ // Connector/J 8.4 ends the group at the first raw ')', so a
quoted span cannot cross it.
+ if (addressFormat && (current == '\'' || current == '"')) {
+ i = authority.indexOf(current, i + 1);
+ if (i < 0 || i > rawGroupEnd) {
+ break;
+ }
+ }
+ }
+ throw new IllegalArgumentException("Invalid MySQL jdbc_url host
properties");
+ }
+
+ private static boolean checkProperties(String properties, String separator,
+ Map<String, String> restrictedOptions) {
+ boolean hasCanonicalLocalInfileOption = false;
+ for (String property : properties.split(separator)) {
+ checkProperty(property, restrictedOptions, false);
+ // Older Connector/J versions require the exact key spelling in
the query string.
+ hasCanonicalLocalInfileOption |=
property.startsWith(ALLOW_LOAD_LOCAL_INFILE + "=");
+ }
+ return hasCanonicalLocalInfileOption;
+ }
+
+ private static void checkProperty(String property, Map<String, String>
restrictedOptions, boolean addressFormat) {
+ int equals = property.indexOf('=');
+ String key = normalizeMysqlOption(decode(equals < 0 ? property :
property.substring(0, equals)));
+ String value = equals < 0 ? "" : property.substring(equals + 1);
+ // The modern driver preserves quotes in directory values, so check
that value without unquoting.
+ if (addressFormat &&
!ALLOW_LOAD_LOCAL_INFILE_IN_PATH.equalsIgnoreCase(key)) {
+ value = unquoteLegacyHostValue(value.trim());
+ }
+ checkRestrictedMysqlOption(key, value, restrictedOptions);
+ }
+
+ private static void checkLegacyMysqlQuery(String query, Map<String,
String> restrictedOptions) {
+ for (String property : query.split("&")) {
+ int equals = property.indexOf('=');
+ // Connector/J 5.1 keeps raw keys and reads only pairs with a
nonempty key and value.
+ if (equals > 0 && equals + 1 < property.length()) {
+ String key = normalizeMysqlOption(property.substring(0,
equals));
+ checkRestrictedMysqlOption(key, property.substring(equals +
1), restrictedOptions);
+ }
+ }
+ }
+
+ private static void checkRestrictedMysqlOption(String key, String value,
Map<String, String> restrictedOptions) {
+ String option = key.isEmpty() ? null : restrictedOptions.get(key);
+ if (option != null && !isAllowedValue(key, value)) {
+ throw new IllegalArgumentException("MySQL jdbc_url disallows " +
option);
+ }
+ }
+
+ private static String unquoteLegacyHostValue(String value) {
+ if (value.length() >= 2) {
+ char quote = value.charAt(0);
+ if ((quote == '\'' || quote == '"') && value.charAt(value.length()
- 1) == quote) {
+ return value.substring(1, value.length() - 1);
+ }
+ }
+ return value;
+ }
+
+ private static String normalizeMysqlOption(String key) {
+ String normalizedKey = key.trim().toLowerCase(Locale.ROOT);
+ return MYSQL_OPTION_ALIASES.getOrDefault(normalizedKey, normalizedKey);
+ }
+
+ private static boolean isAllowedValue(String option, String rawValue) {
+ if (option.equalsIgnoreCase(ALLOW_LOAD_LOCAL_INFILE_IN_PATH)) {
+ return decode(rawValue).isEmpty();
+ }
+ if (option.equalsIgnoreCase(ALLOW_LOAD_LOCAL_INFILE) ||
option.equalsIgnoreCase(ALLOW_URL_IN_LOCAL_INFILE)) {
+ String value = decode(rawValue);
+ return value.equalsIgnoreCase("false") ||
value.equalsIgnoreCase("no");
+ }
+ return false;
+ }
+
+ private static String decode(String component) {
+ try {
+ return URLDecoder.decode(component.trim(),
StandardCharsets.UTF_8.name());
+ } catch (UnsupportedEncodingException e) {
+ throw new AssertionError(e);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException("Invalid percent encoding in
MySQL jdbc_url");
+ }
+ }
}
diff --git
a/fe/fe-foundation/src/test/java/org/apache/doris/foundation/security/JdbcDriverUrlSecurityTest.java
b/fe/fe-foundation/src/test/java/org/apache/doris/foundation/security/JdbcDriverUrlSecurityTest.java
index e3f58466dcf..42b56347508 100644
---
a/fe/fe-foundation/src/test/java/org/apache/doris/foundation/security/JdbcDriverUrlSecurityTest.java
+++
b/fe/fe-foundation/src/test/java/org/apache/doris/foundation/security/JdbcDriverUrlSecurityTest.java
@@ -19,6 +19,8 @@ package org.apache.doris.foundation.security;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
/**
* Tests for the mandatory, non-configurable driver_url security rule in
@@ -28,6 +30,68 @@ import org.junit.jupiter.api.Test;
*/
public class JdbcDriverUrlSecurityTest {
+ @Test
+ public void testPreservesQuotedLegacyHostPath() {
+ String[] restrictions = {"allowLoadLocalInfile"};
+ for (String quote : new String[] {"'", "\""}) {
+ String url =
"jdbc:mysql://address=(host=db.example)(trustCertificateKeyStoreUrl=" + quote
+ + "file:/etc/certs/example store.jks" + quote + ")/app";
+ Assertions.assertEquals(url + "?allowLoadLocalInfile=false",
+ JdbcDriverUrlSecurity.prepareMySqlJdbcUrl(url,
restrictions));
+ }
+ }
+
+ @ParameterizedTest
+ @ValueSource(chars = {'\'', '"'})
+ public void testRejectsRawClosingParenthesisInQuotedAddressValue(char
quote) {
+ String url =
"jdbc:mysql://address=(host=db.invalid)(connectionAttributes=" + quote
+ + "label:sample)value" + quote + ")/app";
+ IllegalArgumentException error =
Assertions.assertThrows(IllegalArgumentException.class,
+ () -> JdbcDriverUrlSecurity.prepareMySqlJdbcUrl(url, new
String[0]));
+ Assertions.assertEquals("Invalid MySQL jdbc_url host properties",
error.getMessage());
+ }
+
+ @ParameterizedTest
+ @ValueSource(chars = {'\'', '"'})
+ public void
testPreservesEncodedClosingParenthesisInQuotedAddressValue(char quote) {
+ String url =
"jdbc:mysql://address=(host=db.invalid)(connectionAttributes=" + quote
+ + "label:sample%29value" + quote + ")/app";
+ Assertions.assertEquals(url,
JdbcDriverUrlSecurity.prepareMySqlJdbcUrl(url, new String[0]));
+ }
+
+ @Test
+ public void testPreservesEncodedModernHostPath() {
+ String url =
"jdbc:mysql://(host=db.example,trustCertificateKeyStoreUrl=file:%2Fetc%2Fexample.jks)/app";
+ Assertions.assertEquals(url + "?allowLoadLocalInfile=false",
+ JdbcDriverUrlSecurity.prepareMySqlJdbcUrl(url, new String[]
{"allowLoadLocalInfile"}));
+ }
+
+ @Test
+ public void testPreservesLiteralHashAndPreparesSharedMysqlQueryDefault() {
+ String base = "jdbc:mysql://db.example/app?";
+ String options =
"trustCertificateKeyStorePassword=example#value&connectTimeout=5000";
+ String[] restrictions = {"allowLoadLocalInfile"};
+ String expected = base + "allowLoadLocalInfile=false&" + options;
+ Assertions.assertEquals(expected,
JdbcDriverUrlSecurity.prepareMySqlJdbcUrl(base + options, restrictions));
+ Assertions.assertEquals(expected,
JdbcDriverUrlSecurity.prepareMySqlJdbcUrl(expected, restrictions));
+ Assertions.assertEquals(base + options,
+ JdbcDriverUrlSecurity.prepareMySqlJdbcUrl(base + options, new
String[0]));
+ }
+
+ @Test
+ public void testValidatesBothMysqlQueryInterpretations() {
+ String base = "jdbc:mysql://db.example/app?";
+ String[] restrictions = {"connectTimeout"};
+ for (String options : new String[] {
+
"trustCertificateKeyStorePassword=example#value&connectTimeout=5000",
+ "connectTimeout#catalog-note"
+ }) {
+ IllegalArgumentException error =
Assertions.assertThrows(IllegalArgumentException.class,
+ () -> JdbcDriverUrlSecurity.prepareMySqlJdbcUrl(base +
options, restrictions));
+ Assertions.assertEquals("MySQL jdbc_url disallows connectTimeout",
error.getMessage());
+ }
+ }
+
// ---- rejected ----
@Test
diff --git
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/Config.groovy
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/Config.groovy
index 24a892bd1e5..ec458d13c35 100644
---
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/Config.groovy
+++
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/Config.groovy
@@ -1339,6 +1339,19 @@ class Config {
}
}
+ String getCatalogJdbcUrl() {
+ // The regression client needs LOCAL INFILE for LOAD DATA. Catalog
fixtures do not.
+ int queryStart = jdbcUrl.indexOf('?') + 1
+ if (queryStart == 0) {
+ return jdbcUrl
+ }
+ int fragmentStart = jdbcUrl.indexOf('#', queryStart)
+ int queryEnd = fragmentStart < 0 ? jdbcUrl.length() : fragmentStart
+ String options = jdbcUrl.substring(queryStart, queryEnd)
+ return jdbcUrl.substring(0, queryStart) +
+ options.replaceAll(/(?i)((?:^|&)allowLoadLocalInfile=)[^&]*/,
'$1false') + jdbcUrl.substring(queryEnd)
+ }
+
public static String buildUrlWithDbImpl(String jdbcUrl, String dbName) {
if (!dbName?.trim()) {
return jdbcUrl
diff --git
a/regression-test/suites/ddl_p0/create_view_nereids/create_view_nereids_fix_null.groovy
b/regression-test/suites/ddl_p0/create_view_nereids/create_view_nereids_fix_null.groovy
index 99f87d03403..576891fb9a5 100644
---
a/regression-test/suites/ddl_p0/create_view_nereids/create_view_nereids_fix_null.groovy
+++
b/regression-test/suites/ddl_p0/create_view_nereids/create_view_nereids_fix_null.groovy
@@ -33,7 +33,7 @@ suite("create_view_nereids_fix_null") {
logger.info("bucket: " + bucket)
String driver_url =
"https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.4.0.jar"
String dbname = context.config.getDbNameByFile(context.file)
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = context.config.jdbcUser
logger.info("jdbcUser: " + jdbcUser)
String jdbcPassword = context.config.jdbcPassword
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog.groovy
b/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog.groovy
index 6c05a2fa293..cba33ac9f1e 100644
---
a/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog.groovy
@@ -18,7 +18,7 @@
suite("test_doris_jdbc_catalog", "p0,external") {
qt_sql """select current_catalog()"""
- String jdbcUrl = context.config.jdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_query_bitmap.groovy
b/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_query_bitmap.groovy
index 577b206c4a8..55d4fe99ab0 100644
---
a/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_query_bitmap.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_query_bitmap.groovy
@@ -18,7 +18,7 @@
suite("test_doris_jdbc_catalog_query_bitmap", "p0,external") {
qt_sql """select current_catalog()"""
- String jdbcUrl = context.config.jdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_query_hll_quantile.groovy
b/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_query_hll_quantile.groovy
index 3a45067eed1..6f5bcbb8794 100644
---
a/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_query_hll_quantile.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_query_hll_quantile.groovy
@@ -18,7 +18,7 @@
suite("test_doris_jdbc_catalog_query_hll_quantile", "p0,external") {
qt_sql """select current_catalog()"""
- String jdbcUrl = context.config.jdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_varbinary.groovy
b/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_varbinary.groovy
index 2a32e06dad6..3c5f591b9d0 100644
---
a/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_varbinary.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/test_doris_jdbc_catalog_varbinary.groovy
@@ -19,7 +19,7 @@
// declared length, like the binary types of every other JDBC source; the
plugin connector used to map them to
// STRING. A remote Doris exposes VARBINARY through views and external tables,
so the remote side is a view.
suite("test_doris_jdbc_catalog_varbinary", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_jdbc_array_literal_predicate.groovy
b/regression-test/suites/external_table_p0/jdbc/test_jdbc_array_literal_predicate.groovy
index 65cd4e7cc74..ac58cba0506 100644
---
a/regression-test/suites/external_table_p0/jdbc/test_jdbc_array_literal_predicate.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/test_jdbc_array_literal_predicate.groovy
@@ -45,7 +45,7 @@ suite("test_jdbc_array_literal_predicate", "p0,external") {
"type" = "jdbc",
"user" = "${jdbcUser}",
"password" = "${jdbcPassword}",
- "jdbc_url" = "${context.config.jdbcUrl}",
+ "jdbc_url" = "${context.config.catalogJdbcUrl}",
"driver_url" = "${driver_prefix}/mysql-connector-j-8.4.0.jar",
"driver_class" = "com.mysql.cj.jdbc.Driver"
)"""
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_jdbc_call.groovy
b/regression-test/suites/external_table_p0/jdbc/test_jdbc_call.groovy
index ec91eb05e00..71d6abe3910 100644
--- a/regression-test/suites/external_table_p0/jdbc/test_jdbc_call.groovy
+++ b/regression-test/suites/external_table_p0/jdbc/test_jdbc_call.groovy
@@ -16,7 +16,7 @@
// under the License.
suite("test_jdbc_call", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_jni_complex_type.groovy
b/regression-test/suites/external_table_p0/jdbc/test_jni_complex_type.groovy
index e07a0ed281b..357c3f98f30 100644
--- a/regression-test/suites/external_table_p0/jdbc/test_jni_complex_type.groovy
+++ b/regression-test/suites/external_table_p0/jdbc/test_jni_complex_type.groovy
@@ -18,7 +18,7 @@
suite("test_jni_complex_type", "p0,external") {
qt_sql """select current_catalog()"""
- String jdbcUrl = context.config.jdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog_table_comment.groovy
b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog_table_comment.groovy
index 610d708e5e4..17e5c0d565a 100644
---
a/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog_table_comment.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/test_mysql_jdbc_catalog_table_comment.groovy
@@ -61,7 +61,7 @@ suite("test_jdbc_mysql_catalog_table_comment", "p0") {
}
// doris catalog
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_doris_catalog"
String jdbcPassword = "C123_567p"
driver_url =
"https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.4.0.jar"
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_non_nullable_jdbc_mtmv.groovy
b/regression-test/suites/external_table_p0/jdbc/test_non_nullable_jdbc_mtmv.groovy
index dd5787597a3..32c4e347037 100644
---
a/regression-test/suites/external_table_p0/jdbc/test_non_nullable_jdbc_mtmv.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/test_non_nullable_jdbc_mtmv.groovy
@@ -27,7 +27,7 @@ suite("test_non_nullable_jdbc_mtmv", "p0,external") {
sql "DROP CATALOG IF EXISTS non_nullable_mv_jdbc"
sql """CREATE CATALOG non_nullable_mv_jdbc PROPERTIES (
"type" = "jdbc", "user" = "${context.config.jdbcUser}", "password" =
"${context.config.jdbcPassword}",
- "jdbc_url" = "${context.config.jdbcUrl}", "driver_url" = "${driver}",
+ "jdbc_url" = "${context.config.catalogJdbcUrl}", "driver_url" =
"${driver}",
"driver_class" = "com.mysql.cj.jdbc.Driver"
)"""
checkNonNullableMvRewrite("non_nullable_mv_jdbc.${db}.non_nullable_jdbc_base",
diff --git
a/regression-test/suites/external_table_p0/jdbc/test_query_tvf_cross_catalog.groovy
b/regression-test/suites/external_table_p0/jdbc/test_query_tvf_cross_catalog.groovy
index 00229da5042..f589502335a 100644
---
a/regression-test/suites/external_table_p0/jdbc/test_query_tvf_cross_catalog.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/test_query_tvf_cross_catalog.groovy
@@ -16,7 +16,7 @@
// under the License.
suite("test_query_tvf_cross_catalog", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl +
"&jdbcCompliantTruncation=false&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&jdbcCompliantTruncation=false&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String enabled = context.config.otherConfigs.get("enableJdbcTest")
diff --git
a/regression-test/suites/external_table_p0/jdbc/type_test/select/test_doris_all_types_select.groovy
b/regression-test/suites/external_table_p0/jdbc/type_test/select/test_doris_all_types_select.groovy
index 0b5e7fc1586..dbffe8417c4 100644
---
a/regression-test/suites/external_table_p0/jdbc/type_test/select/test_doris_all_types_select.groovy
+++
b/regression-test/suites/external_table_p0/jdbc/type_test/select/test_doris_all_types_select.groovy
@@ -16,7 +16,7 @@
// under the License.
suite("test_doris_all_types_select", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl +
"&jdbcCompliantTruncation=false&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&jdbcCompliantTruncation=false&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/test_conflict_name.groovy
b/regression-test/suites/external_table_p0/lower_case/test_conflict_name.groovy
index 36d06b4352c..0abbb092f17 100644
---
a/regression-test/suites/external_table_p0/lower_case/test_conflict_name.groovy
+++
b/regression-test/suites/external_table_p0/lower_case/test_conflict_name.groovy
@@ -17,7 +17,7 @@
suite("test_conflict_name", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_conflict_name_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_include.groovy
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_include.groovy
index 08f863e2b32..5f79816b6a8 100644
---
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_include.groovy
+++
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_include.groovy
@@ -17,7 +17,7 @@
suite("test_lower_case_meta_include", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_lower_include_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_show_and_select.groovy
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_show_and_select.groovy
index b4bc61e4fb3..c5642071a2c 100644
---
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_show_and_select.groovy
+++
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_show_and_select.groovy
@@ -21,7 +21,7 @@ import org.awaitility.Awaitility
suite("test_lower_case_meta_show_and_select", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_lower_without_conf_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_grant.groovy
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_grant.groovy
index 2f65b14aa5a..fb12c1582e4 100644
---
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_grant.groovy
+++
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_grant.groovy
@@ -17,7 +17,7 @@
suite("test_lower_case_meta_with_lower_table_conf_auth", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_show_and_select.groovy
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_show_and_select.groovy
index 240be7f5de3..87740e4b83f 100644
---
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_show_and_select.groovy
+++
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_meta_with_lower_table_conf_show_and_select.groovy
@@ -17,7 +17,7 @@
suite("test_lower_case_meta_with_lower_table_conf_show_and_select",
"p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_lower_with_conf"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_mtmv.groovy
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_mtmv.groovy
index 3d7da20922b..5e7eb00d854 100644
---
a/regression-test/suites/external_table_p0/lower_case/test_lower_case_mtmv.groovy
+++
b/regression-test/suites/external_table_p0/lower_case/test_lower_case_mtmv.groovy
@@ -17,7 +17,7 @@
suite("test_lower_case_mtmv", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_lower_case_mtmv_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/test_meta_cache_select_without_refresh.groovy
b/regression-test/suites/external_table_p0/lower_case/test_meta_cache_select_without_refresh.groovy
index 87548e2e602..570f61b7bcd 100644
---
a/regression-test/suites/external_table_p0/lower_case/test_meta_cache_select_without_refresh.groovy
+++
b/regression-test/suites/external_table_p0/lower_case/test_meta_cache_select_without_refresh.groovy
@@ -17,7 +17,7 @@
suite("test_meta_cache_select_without_refresh", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_meta_cache_select_without_refresh_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/test_meta_names_mapping.groovy
b/regression-test/suites/external_table_p0/lower_case/test_meta_names_mapping.groovy
index 0ff2e3e00e8..ae1505cc92a 100644
---
a/regression-test/suites/external_table_p0/lower_case/test_meta_names_mapping.groovy
+++
b/regression-test/suites/external_table_p0/lower_case/test_meta_names_mapping.groovy
@@ -17,7 +17,7 @@
suite("test_meta_names_mapping", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_meta_names_mapping_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/test_timing_refresh_catalog.groovy
b/regression-test/suites/external_table_p0/lower_case/test_timing_refresh_catalog.groovy
index 6fb92c9545e..18f5e91b29f 100644
---
a/regression-test/suites/external_table_p0/lower_case/test_timing_refresh_catalog.groovy
+++
b/regression-test/suites/external_table_p0/lower_case/test_timing_refresh_catalog.groovy
@@ -21,7 +21,7 @@ import org.awaitility.Awaitility
suite("test_timing_refresh_catalog", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_timing_refresh_catalog_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/external_table_p0/lower_case/upgrade/load.groovy
b/regression-test/suites/external_table_p0/lower_case/upgrade/load.groovy
index c3afe9e15a5..84245aad6f0 100644
--- a/regression-test/suites/external_table_p0/lower_case/upgrade/load.groovy
+++ b/regression-test/suites/external_table_p0/lower_case/upgrade/load.groovy
@@ -21,7 +21,7 @@ import org.awaitility.Awaitility
suite("test_upgrade_lower_case_catalog_prepare", "p0,external") {
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = "test_upgrade_lower_case_catalog_user"
String jdbcPassword = "C123_567p"
String s3_endpoint = getS3Endpoint()
diff --git a/regression-test/suites/nereids_syntax_p0/alias_conflict.groovy
b/regression-test/suites/nereids_syntax_p0/alias_conflict.groovy
index 87946d7a357..65c966302ba 100644
--- a/regression-test/suites/nereids_syntax_p0/alias_conflict.groovy
+++ b/regression-test/suites/nereids_syntax_p0/alias_conflict.groovy
@@ -165,7 +165,7 @@ suite("alias_conflict") {
'type'='jdbc',
'user'='${context.config.jdbcUser}',
'password'='${context.config.jdbcPassword}',
- 'jdbc_url' = '${context.config.jdbcUrl}',
+ 'jdbc_url' = '${context.config.catalogJdbcUrl}',
'driver_url' = "${driver_url}",
'driver_class' = 'com.mysql.cj.jdbc.Driver'
);
diff --git
a/regression-test/suites/plugin_p1/test_cloud_plugin_auto_download.groovy
b/regression-test/suites/plugin_p1/test_cloud_plugin_auto_download.groovy
index 2b697db07ba..dbab907d2d1 100644
--- a/regression-test/suites/plugin_p1/test_cloud_plugin_auto_download.groovy
+++ b/regression-test/suites/plugin_p1/test_cloud_plugin_auto_download.groovy
@@ -23,7 +23,7 @@ suite("test_cloud_plugin_auto_download", "p1,external") {
return
}
- String jdbcUrl = context.config.jdbcUrl
+ String jdbcUrl = context.config.catalogJdbcUrl
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
diff --git
a/regression-test/suites/ranger_p2/test_ranger_access_resource_catalog.groovy
b/regression-test/suites/ranger_p2/test_ranger_access_resource_catalog.groovy
index aed26f0c6d8..97814a26d1c 100644
---
a/regression-test/suites/ranger_p2/test_ranger_access_resource_catalog.groovy
+++
b/regression-test/suites/ranger_p2/test_ranger_access_resource_catalog.groovy
@@ -95,7 +95,7 @@ suite("test_ranger_access_resource_catalog",
"p2,ranger,external") {
String rangerServiceName =
context.config.otherConfigs.get("rangerServiceName")
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
String HmsPort = context.config.otherConfigs.get("hive3HmsPort")
- String jdbcUrl = context.config.jdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3Endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/ranger_p2/test_ranger_access_resource_global.groovy
b/regression-test/suites/ranger_p2/test_ranger_access_resource_global.groovy
index fa8dd95b47c..eb112303922 100644
--- a/regression-test/suites/ranger_p2/test_ranger_access_resource_global.groovy
+++ b/regression-test/suites/ranger_p2/test_ranger_access_resource_global.groovy
@@ -95,7 +95,7 @@ suite("test_ranger_access_resource_global",
"p2,ranger,external") {
String rangerServiceName =
context.config.otherConfigs.get("rangerServiceName")
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
String HmsPort = context.config.otherConfigs.get("hive3HmsPort")
- String jdbcUrl = context.config.jdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3Endpoint = getS3Endpoint()
diff --git
a/regression-test/suites/ranger_p2/test_ranger_access_role_resource_catalog.groovy
b/regression-test/suites/ranger_p2/test_ranger_access_role_resource_catalog.groovy
index aa6f311d0b2..4af5ff7c993 100644
---
a/regression-test/suites/ranger_p2/test_ranger_access_role_resource_catalog.groovy
+++
b/regression-test/suites/ranger_p2/test_ranger_access_role_resource_catalog.groovy
@@ -96,7 +96,7 @@ suite("test_ranger_access_role_resource_catalog",
"p2,ranger,external") {
String rangerServiceName =
context.config.otherConfigs.get("rangerServiceName")
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
String HmsPort = context.config.otherConfigs.get("hive3HmsPort")
- String jdbcUrl = context.config.jdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
+ String jdbcUrl = context.config.catalogJdbcUrl +
"&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3Endpoint = getS3Endpoint()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]