diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java index 776457d5531f12..0f140ed5bdd383 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java @@ -346,6 +346,11 @@ public String removeLastDBOfCatalog(String catalog) { return lastDBOfCatalog.get(catalog); } + // Used by COM_RESET_CONNECTION + public void clearLastDBOfCatalog() { + lastDBOfCatalog.clear(); + } + public void setNotEvalNondeterministicFunction(boolean notEvalNondeterministicFunction) { this.notEvalNondeterministicFunction = notEvalNondeterministicFunction; } 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 2340aa37aebb55..fcc6c2362cf276 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 @@ -44,6 +44,7 @@ import org.apache.doris.common.util.SqlUtils; import org.apache.doris.common.util.Util; import org.apache.doris.datasource.CatalogIf; +import org.apache.doris.datasource.InternalCatalog; import org.apache.doris.metric.MetricRepo; import org.apache.doris.mysql.MysqlChannel; import org.apache.doris.mysql.MysqlPacket; @@ -198,6 +199,12 @@ protected void handleDebug() { ctx.getState().setOk(); } + protected void handleResetConnection() { + ctx.changeDefaultCatalog(InternalCatalog.INTERNAL_CATALOG_NAME); + ctx.clearLastDBOfCatalog(); + ctx.getState().setOk(); + } + protected void handleStmtReset() { ctx.getState().setOk(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java index 376d4740e632a1..da3baced5fad78 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java @@ -264,6 +264,9 @@ private void dispatch() throws IOException { case COM_SET_OPTION: handleSetOption(); break; + case COM_RESET_CONNECTION: + handleResetConnection(); + break; default: ctx.getState().setError(ErrorCode.ERR_UNKNOWN_COM_ERROR, "Unsupported command(" + command + ")"); LOG.warn("Unsupported command(" + command + ")");