This is an automated email from the ASF dual-hosted git repository.

lijibing 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 0ffb71b5589 [improvement](mysql)Support mysql COM_RESET_CONNECTION 
command. (#44747)
0ffb71b5589 is described below

commit 0ffb71b558949840bc3d83b073177b0952b82cbb
Author: James <lijib...@selectdb.com>
AuthorDate: Fri Nov 29 18:09:48 2024 +0800

    [improvement](mysql)Support mysql COM_RESET_CONNECTION command. (#44747)
    
    ### What problem does this PR solve?
    Support mysql COM_RESET_CONNECTION command.
    Doris server side reset default catalog and return
    ctx.getState().setOk()
    
    Python test code:
    ```
    import mysql.connector
    
    connection = mysql.connector.connect(
        host="172.20.32.136",
        port=29030,
        user="root",
        password="",
        database=""
    )
    print(connection.cmd_reset_connection())
    ```
    
    Issue Number: close #xxx
    
    Related PR: #xxx
    
    Problem Summary:
    
    ### Release note
    
    None
---
 fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java   | 5 +++++
 fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java | 7 +++++++
 .../src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java   | 3 +++
 3 files changed, 15 insertions(+)

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 a16422ba9e5..c21c9ee3f86 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
@@ -342,6 +342,11 @@ public class ConnectContext {
         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 2340aa37aeb..fcc6c2362cf 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.DebugUtil;
 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 @@ public abstract class ConnectProcessor {
         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 376d4740e63..da3baced5fa 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 @@ public class MysqlConnectProcessor extends ConnectProcessor 
{
             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 + ")");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to