You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/04/13 21:55:53 UTC

[GitHub] [shardingsphere] TeslaCN commented on a diff in pull request #16796: Shardingsphere-proxy fails to establish a connection when it proxies multiple versions of mysql databases

TeslaCN commented on code in PR #16796:
URL: https://github.com/apache/shardingsphere/pull/16796#discussion_r849927741


##########
shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java:
##########
@@ -34,27 +38,38 @@ public final class MySQLServerInfo {
     
     public static final MySQLCharacterSet DEFAULT_CHARSET = MySQLCharacterSet.UTF8MB4_GENERAL_CI;
     
-    private static final String DEFAULT_MYSQL_VERSION = "5.7.22";
+    private static final String DEFAULT_MYSQL_VERSION = "5.6.23";
     
     private static final String SERVER_VERSION_PATTERN = "%s-ShardingSphere-Proxy %s";
     
-    private static volatile String serverVersion;
+    private static Map<String, String> serverVersions = new ConcurrentHashMap<>();
     
     /**
      * Set server version.
-     *
+     * 
+     * @param schemaName schema name
      * @param serverVersion server version
      */
-    public static synchronized void setServerVersion(final String serverVersion) {
-        MySQLServerInfo.serverVersion = null == serverVersion ? null : String.format(SERVER_VERSION_PATTERN, serverVersion, CommonConstants.PROXY_VERSION.get());
+    public static void setServerVersion(final String schemaName, final String serverVersion) {
+        serverVersions.put(schemaName, String.format(SERVER_VERSION_PATTERN, serverVersion, CommonConstants.PROXY_VERSION.get()));

Review Comment:
   A connection may have no schema name before client executing `use database`, this may cause NPE.



##########
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/constant/TransactionIsolationLevel.java:
##########
@@ -28,9 +28,9 @@
 public enum TransactionIsolationLevel {
 
     NONE("NONE"),
-    READ_UNCOMMITTED("READ_UNCOMMITTED"),

Review Comment:
   Are these changes related to the issue?



##########
shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java:
##########
@@ -34,27 +38,38 @@ public final class MySQLServerInfo {
     
     public static final MySQLCharacterSet DEFAULT_CHARSET = MySQLCharacterSet.UTF8MB4_GENERAL_CI;
     
-    private static final String DEFAULT_MYSQL_VERSION = "5.7.22";
+    private static final String DEFAULT_MYSQL_VERSION = "5.6.23";
     
     private static final String SERVER_VERSION_PATTERN = "%s-ShardingSphere-Proxy %s";
     
-    private static volatile String serverVersion;
+    private static Map<String, String> serverVersions = new ConcurrentHashMap<>();

Review Comment:
   Consider making this final.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org