You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/10/13 04:41:31 UTC
(shardingsphere) branch master updated: Refactor MySQLSetVariableAdminExecutor (#36869)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new c8017796a19 Refactor MySQLSetVariableAdminExecutor (#36869)
c8017796a19 is described below
commit c8017796a198122cab72b810125f7d73f76f82ff
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Oct 13 12:41:25 2025 +0800
Refactor MySQLSetVariableAdminExecutor (#36869)
---
.../handler/admin/executor/MySQLSetVariableAdminExecutor.java | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/proxy/backend/dialect/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutor.java b/proxy/backend/dialect/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutor.java
index 006dd5d5a95..aac1e6015fd 100644
--- a/proxy/backend/dialect/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutor.java
+++ b/proxy/backend/dialect/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutor.java
@@ -18,14 +18,12 @@
package org.apache.shardingsphere.proxy.backend.mysql.handler.admin.executor;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.exception.mysql.exception.UnknownSystemVariableException;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.engine.SQLBindEngine;
import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.session.query.QueryContext;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.proxy.backend.connector.DatabaseProxyConnectorFactory;
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutor;
@@ -52,17 +50,15 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public final class MySQLSetVariableAdminExecutor implements DatabaseAdminExecutor {
- private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "MySQL");
-
private final SetStatement setStatement;
@Override
public void execute(final ConnectionSession connectionSession, final ShardingSphereMetaData metaData) throws SQLException {
Map<String, String> sessionVariables = extractSessionVariables();
validateSessionVariables(sessionVariables.keySet());
- CharsetSetExecutor charsetSetExecutor = new CharsetSetExecutor(databaseType, connectionSession);
+ CharsetSetExecutor charsetSetExecutor = new CharsetSetExecutor(setStatement.getDatabaseType(), connectionSession);
sessionVariables.forEach(charsetSetExecutor::set);
- new SessionVariableRecordExecutor(databaseType, connectionSession).recordVariable(sessionVariables);
+ new SessionVariableRecordExecutor(setStatement.getDatabaseType(), connectionSession).recordVariable(sessionVariables);
executeSetGlobalVariablesIfPresent(connectionSession, metaData);
}
@@ -89,7 +85,7 @@ public final class MySQLSetVariableAdminExecutor implements DatabaseAdminExecuto
}
String sql = "SET " + concatenatedGlobalVariables;
SQLParserRule sqlParserRule = metaData.getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);
- SQLStatement sqlStatement = sqlParserRule.getSQLParserEngine(databaseType).parse(sql, false);
+ SQLStatement sqlStatement = sqlParserRule.getSQLParserEngine(setStatement.getDatabaseType()).parse(sql, false);
SQLStatementContext sqlStatementContext = new SQLBindEngine(metaData,
connectionSession.getCurrentDatabaseName(), new HintValueContext()).bind(sqlStatement);
DatabaseProxyBackendHandler databaseProxyBackendHandler = DatabaseProxyConnectorFactory.newInstance(