This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 43b9fd6876b branch-4.0: [fix](mysql) optimize some error handling
logic #56416 (#56455)
43b9fd6876b is described below
commit 43b9fd6876be87ae60fd6e6513cd8e9c6a157d66
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Sep 25 09:35:31 2025 -0700
branch-4.0: [fix](mysql) optimize some error handling logic #56416 (#56455)
Cherry-picked from #56416
---
.../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 83d122ebd1f..f4e2a8309cf 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
@@ -6242,12 +6242,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 f0392955dab..3b0a5bd8c44 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
@@ -234,6 +234,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;
}
@@ -252,27 +253,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 5db0b3d4d41..f285fd6a811 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
@@ -144,20 +144,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);
@@ -170,7 +156,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]