This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new cbcdee443f0 branch-3.1: [fix](mysql) optimize some error handling
logic #56416 (#56448)
cbcdee443f0 is described below
commit cbcdee443f069c7524f3a8788876c7f51af250bd
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Sep 27 20:32:44 2025 -0700
branch-3.1: [fix](mysql) optimize some error handling logic #56416 (#56448)
Cherry-picked from #56416
Co-authored-by: Mingyu Chen (Rayner) <[email protected]>
---
.../src/main/java/org/apache/doris/catalog/Env.java | 7 +------
.../main/java/org/apache/doris/mysql/MysqlProto.java | 19 ++-----------------
.../java/org/apache/doris/qe/ConnectProcessor.java | 15 ---------------
3 files changed, 3 insertions(+), 38 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 89f757eb3a1..aaf7649ba4f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -5806,12 +5806,7 @@ public class Env {
// Switch catalog of this session
public void changeCatalog(ConnectContext ctx, String catalogName) throws
DdlException {
- CatalogIf catalogIf = catalogMgr.getCatalog(catalogName);
- if (catalogIf == null) {
- throw new
DdlException(ErrorCode.ERR_UNKNOWN_CATALOG.formatErrorMsg(catalogName),
- ErrorCode.ERR_UNKNOWN_CATALOG);
- }
-
+ CatalogIf catalogIf = catalogMgr.getCatalogOrDdlException(catalogName);
String currentDB = ctx.getDatabase();
if (StringUtils.isNotEmpty(currentDB)) {
// When dropped the current catalog in current context, the
current catalog will be null.
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java
b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java
index 7fed32d1aca..5c938ed6bc9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java
@@ -235,6 +235,7 @@ public class MysqlProto {
dbName = dbNames[1];
} else if (dbNames.length > 2) {
context.getState().setError(ErrorCode.ERR_BAD_DB_ERROR, "Only
one dot can be in the name: " + db);
+ sendResponsePacket(context);
return false;
}
@@ -253,27 +254,11 @@ public class MysqlProto {
}
}
- String dbFullName = dbName;
-
- // check catalog and db exists
- if (catalogName != null) {
- CatalogIf catalogIf =
context.getEnv().getCatalogMgr().getCatalog(catalogName);
- if (catalogIf == null) {
- context.getState()
- .setError(ErrorCode.ERR_BAD_DB_ERROR,
ErrorCode.ERR_BAD_DB_ERROR.formatErrorMsg(db));
- return false;
- }
- if (catalogIf.getDbNullable(dbFullName) == null) {
- context.getState()
- .setError(ErrorCode.ERR_BAD_DB_ERROR,
ErrorCode.ERR_BAD_DB_ERROR.formatErrorMsg(db));
- return false;
- }
- }
try {
if (catalogName != null) {
context.getEnv().changeCatalog(context, catalogName);
}
- Env.getCurrentEnv().changeDb(context, dbFullName);
+ Env.getCurrentEnv().changeDb(context, dbName);
} catch (DdlException e) {
context.getState().setError(e.getMysqlErrorCode(),
e.getMessage());
sendResponsePacket(context);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
index 606a457c8f1..26262681b23 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
@@ -147,20 +147,6 @@ public abstract class ConnectProcessor {
}
}
- // check catalog and db exists
- if (catalogName != null) {
- CatalogIf catalogIf =
ctx.getEnv().getCatalogMgr().getCatalog(catalogName);
- if (catalogIf == null) {
- ctx.getState().setError(ErrorCode.ERR_BAD_DB_ERROR,
- ErrorCode.ERR_BAD_DB_ERROR.formatErrorMsg(catalogName
+ "." + dbName));
- return;
- }
- if (catalogIf.getDbNullable(dbName) == null) {
- ctx.getState().setError(ErrorCode.ERR_BAD_DB_ERROR,
- ErrorCode.ERR_BAD_DB_ERROR.formatErrorMsg(catalogName
+ "." + dbName));
- return;
- }
- }
try {
if (catalogName != null) {
ctx.getEnv().changeCatalog(ctx, catalogName);
@@ -173,7 +159,6 @@ public abstract class ConnectProcessor {
ctx.getState().setError(ErrorCode.ERR_INTERNAL_ERROR,
Util.getRootCauseMessage(t));
return;
}
-
ctx.getState().setOk();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]