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 2020/10/29 03:40:15 UTC

[GitHub] [shardingsphere] tristaZero commented on a change in pull request #7949: fix some sql parse exception and ddl, dcl route logic

tristaZero commented on a change in pull request #7949:
URL: https://github.com/apache/shardingsphere/pull/7949#discussion_r513923047



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
##########
@@ -140,10 +131,16 @@ private static ShardingRouteEngine getDALRoutingEngine(final ShardingRule shardi
         return new ShardingDataSourceGroupBroadcastRoutingEngine();
     }
     
-    private static ShardingRouteEngine getDCLRoutingEngine(final SQLStatementContext sqlStatementContext, final ShardingSphereMetaData metaData) {
-        return isDCLForSingleTable(sqlStatementContext) 
-                ? new ShardingTableBroadcastRoutingEngine(metaData.getSchemaMetaData().getConfiguredSchemaMetaData(), sqlStatementContext)
-                : new ShardingInstanceBroadcastRoutingEngine(metaData.getDataSourcesMetaData());
+    private static ShardingRouteEngine getDCLRoutingEngine(final ShardingRule shardingRule, final Map<String, Collection<String>> unconfiguredSchemaMetaDataMap,
+                                                           final SQLStatementContext sqlStatementContext, final ShardingSphereMetaData metaData) {
+        if (isDCLForSingleTable(sqlStatementContext)) {
+            Collection<String> tableNames = sqlStatementContext.getTablesContext().getTableNames();
+            return !shardingRule.tableRuleExists(tableNames)
+                    ? new ShardingUnconfiguredTablesRoutingEngine(tableNames, unconfiguredSchemaMetaDataMap, sqlStatementContext.getSqlStatement()) 
+                    : new ShardingTableBroadcastRoutingEngine(metaData.getSchemaMetaData().getConfiguredSchemaMetaData(), sqlStatementContext);
+        } else {
+            return new ShardingInstanceBroadcastRoutingEngine(metaData.getDataSourcesMetaData());

Review comment:
       Could you give a SQL example involving `ShardingInstanceBroadcastRoutingEngine`

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/api/parser/SQLParserEngine.java
##########
@@ -64,7 +64,7 @@ public ParseTree parse(final String sql, final boolean useCache) {
     private ParseTree parse(final String sql) {
         ParseASTNode result = twoPhaseParse(sql);
         if (result.getRootNode() instanceof ErrorNode) {
-            throw new SQLParsingException(String.format("Unsupported SQL of `%s`", sql));
+            throw new SQLParsingException(String.format("Unsupported SQL of `%s`", sql).replaceAll("%", "%%"));

Review comment:
       Why is `replaceAll("%", "%%")` needed?




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

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