Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
0b5ee351
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
0b5ee351
编写于
9月 15, 2020
作者:
L
Liang Zhang
提交者:
GitHub
9月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #7342 (#7464)
上级
05d3d3ad
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
64 addition
and
15 deletion
+64
-15
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-merge/src/main/java/org/apache/shardingsphere/sharding/merge/dal/show/LogicTablesMergedResult.java
...here/sharding/merge/dal/show/LogicTablesMergedResult.java
+1
-1
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-merge/src/test/java/org/apache/shardingsphere/sharding/merge/dal/show/ShowTablesMergedResultTest.java
...e/sharding/merge/dal/show/ShowTablesMergedResultTest.java
+0
-6
shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/DataNodeRouter.java
...org/apache/shardingsphere/infra/route/DataNodeRouter.java
+9
-8
shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/decorator/UnconfiguredSchemaRouteDecorator.java
...fra/route/decorator/UnconfiguredSchemaRouteDecorator.java
+54
-0
未找到文件。
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-merge/src/main/java/org/apache/shardingsphere/sharding/merge/dal/show/LogicTablesMergedResult.java
浏览文件 @
0b5ee351
...
...
@@ -53,7 +53,7 @@ public class LogicTablesMergedResult extends MemoryMergedResult<ShardingRule> {
String
actualTableName
=
memoryResultSetRow
.
getCell
(
1
).
toString
();
Optional
<
TableRule
>
tableRule
=
shardingRule
.
findTableRuleByActualTable
(
actualTableName
);
if
(!
tableRule
.
isPresent
())
{
if
(
shardingRule
.
getTableRules
().
isEmpty
()
||
schemaMetaData
.
containsTable
(
actualTableName
)
&&
tableNames
.
add
(
actualTableName
))
{
if
(
shardingRule
.
getTableRules
().
isEmpty
()
||
tableNames
.
add
(
actualTableName
))
{
result
.
add
(
memoryResultSetRow
);
}
}
else
if
(
tableNames
.
add
(
tableRule
.
get
().
getLogicTable
()))
{
...
...
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-merge/src/test/java/org/apache/shardingsphere/sharding/merge/dal/show/ShowTablesMergedResultTest.java
浏览文件 @
0b5ee351
...
...
@@ -82,10 +82,4 @@ public final class ShowTablesMergedResultTest {
LogicTablesMergedResult
actual
=
new
LogicTablesMergedResult
(
shardingRule
,
mock
(
SQLStatementContext
.
class
),
schemaMetaData
,
Collections
.
singletonList
(
createQueryResult
(
"table_0"
)));
assertTrue
(
actual
.
next
());
}
@Test
public
void
assertNextForActualTableNameNotInTableRule
()
throws
SQLException
{
LogicTablesMergedResult
actual
=
new
LogicTablesMergedResult
(
shardingRule
,
mock
(
SQLStatementContext
.
class
),
schemaMetaData
,
Collections
.
singletonList
(
createQueryResult
(
"table_3"
)));
assertFalse
(
actual
.
next
());
}
}
shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/DataNodeRouter.java
浏览文件 @
0b5ee351
...
...
@@ -17,19 +17,20 @@
package
org.apache.shardingsphere.infra.route
;
import
org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader
;
import
org.apache.shardingsphere.infra.spi.order.OrderedSPIRegistry
;
import
org.apache.shardingsphere.sql.parser.binder.SQLStatementContextFactory
;
import
org.apache.shardingsphere.sql.parser.binder.statement.CommonSQLStatementContext
;
import
org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext
;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
;
import
org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData
;
import
org.apache.shardingsphere.infra.rule.ShardingSphereRule
;
import
org.apache.shardingsphere.infra.route.context.RouteContext
;
import
org.apache.shardingsphere.infra.route.context.RouteResult
;
import
org.apache.shardingsphere.infra.route.decorator.RouteDecorator
;
import
org.apache.shardingsphere.infra.route.decorator.UnconfiguredSchemaRouteDecorator
;
import
org.apache.shardingsphere.infra.route.hook.SPIRoutingHook
;
import
org.apache.shardingsphere.infra.rule.ShardingSphereRule
;
import
org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader
;
import
org.apache.shardingsphere.infra.spi.order.OrderedSPIRegistry
;
import
org.apache.shardingsphere.sql.parser.binder.SQLStatementContextFactory
;
import
org.apache.shardingsphere.sql.parser.binder.statement.CommonSQLStatementContext
;
import
org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext
;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -89,7 +90,7 @@ public final class DataNodeRouter {
for
(
Entry
<
ShardingSphereRule
,
RouteDecorator
>
entry
:
decorators
.
entrySet
())
{
result
=
entry
.
getValue
().
decorate
(
result
,
metaData
,
entry
.
getKey
(),
props
);
}
return
result
;
return
new
UnconfiguredSchemaRouteDecorator
().
decorate
(
result
,
metaData
)
;
}
private
RouteContext
createRouteContext
(
final
SQLStatement
sqlStatement
,
final
List
<
Object
>
parameters
)
{
...
...
shardingsphere-infra/shardingsphere-infra-route/src/main/java/org/apache/shardingsphere/infra/route/decorator/UnconfiguredSchemaRouteDecorator.java
0 → 100644
浏览文件 @
0b5ee351
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.shardingsphere.infra.route.decorator
;
import
org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData
;
import
org.apache.shardingsphere.infra.route.context.RouteContext
;
import
org.apache.shardingsphere.infra.route.context.RouteMapper
;
import
org.apache.shardingsphere.infra.route.context.RouteUnit
;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement
;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowTablesStatement
;
import
java.util.Collections
;
/**
* Unconfigured schema route decorator.
*/
public
final
class
UnconfiguredSchemaRouteDecorator
{
/**
* Decorate route context.
*
* @param routeContext route context
* @param metaData meta data of ShardingSphere
* @return decorated route context
*/
public
RouteContext
decorate
(
final
RouteContext
routeContext
,
final
ShardingSphereMetaData
metaData
)
{
if
(
isNeedUnconfiguredSchema
(
routeContext
.
getSqlStatementContext
().
getSqlStatement
()))
{
for
(
String
each
:
metaData
.
getRuleSchemaMetaData
().
getUnconfiguredSchemaMetaDataMap
().
keySet
())
{
routeContext
.
getRouteResult
().
getRouteUnits
().
add
(
new
RouteUnit
(
new
RouteMapper
(
each
,
each
),
Collections
.
emptyList
()));
}
}
return
routeContext
;
}
// TODO use dynamic config to judge UnconfiguredSchema
private
boolean
isNeedUnconfiguredSchema
(
final
SQLStatement
sqlStatement
)
{
return
sqlStatement
instanceof
MySQLShowTablesStatement
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录