You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "strongduanmu (via GitHub)" <gi...@apache.org> on 2023/04/17 15:09:08 UTC

[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #25172: Add unsupported storage type check

strongduanmu commented on code in PR #25172:
URL: https://github.com/apache/shardingsphere/pull/25172#discussion_r1168871484


##########
kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/factory/ExternalMetaDataFactory.java:
##########
@@ -76,12 +85,26 @@ private static Map<String, ShardingSphereDatabase> createGenericDatabases(final
             String databaseName = entry.getKey();
             if (!entry.getValue().getDataSources().isEmpty() || !protocolType.getSystemSchemas().contains(databaseName)) {
                 Map<String, DatabaseType> storageTypes = DatabaseTypeEngine.getStorageTypes(entry.getKey(), entry.getValue());
+                checkSupportedStorageTypes(entry.getValue().getDataSources(), databaseName, storageTypes);
                 result.put(databaseName.toLowerCase(), ShardingSphereDatabase.create(databaseName, protocolType, storageTypes, entry.getValue(), props, instanceContext));
             }
         }
         return result;
     }
     
+    private static void checkSupportedStorageTypes(final Map<String, DataSource> dataSources, final String databaseName, final Map<String, DatabaseType> storageTypes) throws SQLException {
+        if (dataSources.isEmpty()) {
+            return;
+        }
+        try (Connection connection = dataSources.values().iterator().next().getConnection()) {
+            String url = connection.getMetaData().getURL();
+            if (MOCKED_URL.stream().anyMatch(url::startsWith)) {
+                return;
+            }
+        }
+        storageTypes.forEach((key, value) -> ShardingSpherePreconditions.checkState(!SQL92DatabaseType.class.equals(value.getClass()), () -> new UnsupportedStorageTypeException(databaseName, key)));

Review Comment:
   Why only check sql92?



-- 
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