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/05/25 13:36:38 UTC
(shardingsphere) branch master updated: Optimize MySQLComFieldListPacketExecutor with DatabaseType (#35509)
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 8c7c2fce787 Optimize MySQLComFieldListPacketExecutor with DatabaseType (#35509)
8c7c2fce787 is described below
commit 8c7c2fce787b1d16679045a7e4f8bad4f1b776d6
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun May 25 21:36:32 2025 +0800
Optimize MySQLComFieldListPacketExecutor with DatabaseType (#35509)
- Add a private final DatabaseType field initialized with "MySQL"
- Replace inline DatabaseType retrieval with the new field for better readability and performance
---
.../command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
index 344a5ef30d4..50846b8c92b 100644
--- a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
+++ b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
@@ -55,6 +55,8 @@ public final class MySQLComFieldListPacketExecutor implements CommandExecutor {
private static final String SQL = "SHOW COLUMNS FROM %s FROM %s";
+ private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "MySQL");
+
private final MySQLComFieldListPacket packet;
private final ConnectionSession connectionSession;
@@ -67,7 +69,7 @@ public final class MySQLComFieldListPacketExecutor implements CommandExecutor {
String sql = String.format(SQL, packet.getTable(), currentDatabaseName);
MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
SQLParserRule sqlParserRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);
- SQLStatement sqlStatement = sqlParserRule.getSQLParserEngine(TypedSPILoader.getService(DatabaseType.class, "MySQL")).parse(sql, false);
+ SQLStatement sqlStatement = sqlParserRule.getSQLParserEngine(databaseType).parse(sql, false);
HintValueContext hintValueContext = SQLHintUtils.extractHint(sql);
SQLStatementContext sqlStatementContext = new SQLBindEngine(metaDataContexts.getMetaData(), currentDatabaseName, hintValueContext).bind(sqlStatement, Collections.emptyList());
ProxyDatabaseConnectionManager databaseConnectionManager = connectionSession.getDatabaseConnectionManager();