Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
ae98a3a0
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 搜索 >>
提交
ae98a3a0
编写于
9月 10, 2020
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename BackendConnection.schemaName
上级
ae84b341
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
46 addition
and
46 deletion
+46
-46
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java
...end/communication/DatabaseCommunicationEngineFactory.java
+2
-2
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
...d/communication/jdbc/JDBCDatabaseCommunicationEngine.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnection.java
...kend/communication/jdbc/connection/BackendConnection.java
+6
-6
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendTransactionManager.java
...munication/jdbc/connection/BackendTransactionManager.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
...unication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/ProxySQLExecutorCallback.java
...on/jdbc/execute/engine/jdbc/ProxySQLExecutorCallback.java
+2
-2
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandler.java
...ere/proxy/backend/text/admin/BroadcastBackendHandler.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandler.java
...ingsphere/proxy/backend/text/admin/RDLBackendHandler.java
+2
-2
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandler.java
...re/proxy/backend/text/admin/ShowTablesBackendHandler.java
+2
-2
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/UnicastBackendHandler.java
...phere/proxy/backend/text/admin/UnicastBackendHandler.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/query/QueryBackendHandler.java
...gsphere/proxy/backend/text/query/QueryBackendHandler.java
+2
-2
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandler.java
...d/text/sctl/explain/ShardingCTLExplainBackendHandler.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintShowTableStatusExecutor.java
...l/hint/internal/executor/HintShowTableStatusExecutor.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/TextProtocolBackendHandlerFactoryTest.java
.../proxy/backend/TextProtocolBackendHandlerFactoryTest.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineFactoryTest.java
...nication/jdbc/DatabaseCommunicationEngineFactoryTest.java
+3
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendTransactionManagerTest.java
...cation/jdbc/connection/BackendTransactionManagerTest.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandlerTest.java
...proxy/backend/text/admin/BroadcastBackendHandlerTest.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
...phere/proxy/backend/text/admin/RDLBackendHandlerTest.java
+5
-5
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandlerTest.java
...roxy/backend/text/admin/ShowTablesBackendHandlerTest.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
...xt/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
...end/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
...and/query/binary/execute/MySQLComStmtExecuteExecutor.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
...and/query/binary/prepare/MySQLComStmtPrepareExecutor.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
...query/text/fieldlist/MySQLComFieldListPacketExecutor.java
+2
-2
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
...ontend/mysql/command/MySQLCommandExecutorFactoryTest.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
...query/binary/execute/MySQLComStmtExecuteExecutorTest.java
+2
-2
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
.../command/query/binary/bind/PostgreSQLComBindExecutor.java
+1
-1
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutor.java
...ommand/query/binary/parse/PostgreSQLComParseExecutor.java
+1
-1
未找到文件。
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactory.java
浏览文件 @
ae98a3a0
...
...
@@ -56,7 +56,7 @@ public final class DatabaseCommunicationEngineFactory {
* @return instance of text protocol backend handler
*/
public
DatabaseCommunicationEngine
newTextProtocolInstance
(
final
SQLStatement
sqlStatement
,
final
String
sql
,
final
BackendConnection
backendConnection
)
{
SchemaContext
schemaContext
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
());
SchemaContext
schemaContext
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
());
return
new
JDBCDatabaseCommunicationEngine
(
sql
,
backendConnection
,
new
JDBCExecuteEngine
(
backendConnection
,
new
StatementExecutorWrapper
(
schemaContext
,
sqlStatement
)));
}
...
...
@@ -70,7 +70,7 @@ public final class DatabaseCommunicationEngineFactory {
* @return instance of binary protocol backend handler
*/
public
DatabaseCommunicationEngine
newBinaryProtocolInstance
(
final
SQLStatement
sqlStatement
,
final
String
sql
,
final
List
<
Object
>
parameters
,
final
BackendConnection
backendConnection
)
{
SchemaContext
schemaContext
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
());
SchemaContext
schemaContext
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
());
return
new
JDBCDatabaseCommunicationEngine
(
sql
,
backendConnection
,
new
JDBCExecuteEngine
(
backendConnection
,
new
PreparedStatementExecutorWrapper
(
schemaContext
,
sqlStatement
,
parameters
)));
}
}
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
浏览文件 @
ae98a3a0
...
...
@@ -76,7 +76,7 @@ public final class JDBCDatabaseCommunicationEngine implements DatabaseCommunicat
this
.
sql
=
sql
;
connection
=
backendConnection
;
executeEngine
=
sqlExecuteEngine
;
schema
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
());
schema
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
());
}
@Override
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnection.java
浏览文件 @
ae98a3a0
...
...
@@ -63,7 +63,7 @@ public final class BackendConnection implements JDBCExecutionConnection, AutoClo
private
static
final
int
MAXIMUM_RETRY_COUNT
=
5
;
private
volatile
String
schema
;
private
volatile
String
schema
Name
;
private
TransactionType
transactionType
;
...
...
@@ -102,7 +102,7 @@ public final class BackendConnection implements JDBCExecutionConnection, AutoClo
* @param transactionType transaction type
*/
public
void
setTransactionType
(
final
TransactionType
transactionType
)
{
if
(
null
==
schema
)
{
if
(
null
==
schema
Name
)
{
throw
new
ShardingSphereException
(
"Please select database, then switch transaction type."
);
}
if
(
isSwitchFailed
())
{
...
...
@@ -120,7 +120,7 @@ public final class BackendConnection implements JDBCExecutionConnection, AutoClo
if
(
isSwitchFailed
())
{
throw
new
ShardingSphereException
(
"Failed to switch schema, please terminate current transaction."
);
}
schema
=
schemaName
;
this
.
schemaName
=
schemaName
;
}
@SneakyThrows
(
InterruptedException
.
class
)
...
...
@@ -170,7 +170,7 @@ public final class BackendConnection implements JDBCExecutionConnection, AutoClo
}
private
List
<
Connection
>
getConnectionsWithoutTransaction
(
final
String
dataSourceName
,
final
int
connectionSize
,
final
ConnectionMode
connectionMode
)
throws
SQLException
{
Preconditions
.
checkNotNull
(
schema
,
"current schema is null"
);
Preconditions
.
checkNotNull
(
schema
Name
,
"current schema is null"
);
List
<
Connection
>
result
=
getConnectionFromUnderlying
(
dataSourceName
,
connectionSize
,
connectionMode
);
synchronized
(
cachedConnections
)
{
cachedConnections
.
putAll
(
dataSourceName
,
result
);
...
...
@@ -179,7 +179,7 @@ public final class BackendConnection implements JDBCExecutionConnection, AutoClo
}
private
List
<
Connection
>
createNewConnections
(
final
String
dataSourceName
,
final
int
connectionSize
,
final
ConnectionMode
connectionMode
)
throws
SQLException
{
Preconditions
.
checkNotNull
(
schema
,
"current schema is null"
);
Preconditions
.
checkNotNull
(
schema
Name
,
"current schema is null"
);
List
<
Connection
>
result
=
getConnectionFromUnderlying
(
dataSourceName
,
connectionSize
,
connectionMode
);
for
(
Connection
each
:
result
)
{
replayMethodsInvocation
(
each
);
...
...
@@ -188,7 +188,7 @@ public final class BackendConnection implements JDBCExecutionConnection, AutoClo
}
private
List
<
Connection
>
getConnectionFromUnderlying
(
final
String
dataSourceName
,
final
int
connectionSize
,
final
ConnectionMode
connectionMode
)
throws
SQLException
{
return
ProxyContext
.
getInstance
().
getBackendDataSource
().
getConnections
(
schema
,
dataSourceName
,
connectionSize
,
connectionMode
);
return
ProxyContext
.
getInstance
().
getBackendDataSource
().
getConnections
(
schema
Name
,
dataSourceName
,
connectionSize
,
connectionMode
);
}
@Override
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendTransactionManager.java
浏览文件 @
ae98a3a0
...
...
@@ -41,7 +41,7 @@ public final class BackendTransactionManager implements TransactionManager {
connection
=
backendConnection
;
transactionType
=
connection
.
getTransactionType
();
localTransactionManager
=
new
LocalTransactionManager
(
backendConnection
);
ShardingTransactionManagerEngine
engine
=
ProxyContext
.
getInstance
().
getTransactionContexts
().
getEngines
().
get
(
connection
.
getSchema
());
ShardingTransactionManagerEngine
engine
=
ProxyContext
.
getInstance
().
getTransactionContexts
().
getEngines
().
get
(
connection
.
getSchema
Name
());
shardingTransactionManager
=
null
==
engine
?
null
:
engine
.
getTransactionManager
(
transactionType
);
}
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
浏览文件 @
ae98a3a0
...
...
@@ -121,7 +121,7 @@ public final class JDBCExecuteEngine implements SQLExecuteEngine {
}
private
Collection
<
ExecuteResult
>
executeWithUnmanagedResource
(
final
ExecutionContext
executionContext
,
final
int
maxConnectionsSizePerQuery
)
throws
SQLException
{
Collection
<
ShardingSphereRule
>
rules
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
()).
getSchema
().
getRules
();
Collection
<
ShardingSphereRule
>
rules
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
()).
getSchema
().
getRules
();
Collection
<
InputGroup
<
RawSQLExecuteUnit
>>
inputGroups
=
new
RawExecuteGroupEngine
(
maxConnectionsSizePerQuery
,
rules
).
generate
(
executionContext
.
getExecutionUnits
());
// TODO handle query header
return
rawExecutor
.
execute
(
inputGroups
,
new
RawSQLExecutorCallback
());
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/ProxySQLExecutorCallback.java
浏览文件 @
ae98a3a0
...
...
@@ -99,7 +99,7 @@ public final class ProxySQLExecutorCallback extends DefaultSQLExecutorCallback<E
private
List
<
QueryHeader
>
getQueryHeaders
(
final
ProjectionsContext
projectionsContext
,
final
ResultSetMetaData
resultSetMetaData
)
throws
SQLException
{
List
<
QueryHeader
>
result
=
new
LinkedList
<>();
for
(
int
columnIndex
=
1
;
columnIndex
<=
projectionsContext
.
getExpandProjections
().
size
();
columnIndex
++)
{
result
.
add
(
QueryHeaderBuilder
.
build
(
projectionsContext
,
resultSetMetaData
,
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
()),
columnIndex
));
result
.
add
(
QueryHeaderBuilder
.
build
(
projectionsContext
,
resultSetMetaData
,
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
()),
columnIndex
));
}
return
result
;
}
...
...
@@ -107,7 +107,7 @@ public final class ProxySQLExecutorCallback extends DefaultSQLExecutorCallback<E
private
List
<
QueryHeader
>
getQueryHeaders
(
final
ResultSetMetaData
resultSetMetaData
)
throws
SQLException
{
List
<
QueryHeader
>
result
=
new
LinkedList
<>();
for
(
int
columnIndex
=
1
;
columnIndex
<=
resultSetMetaData
.
getColumnCount
();
columnIndex
++)
{
result
.
add
(
QueryHeaderBuilder
.
build
(
resultSetMetaData
,
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
()),
columnIndex
));
result
.
add
(
QueryHeaderBuilder
.
build
(
resultSetMetaData
,
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
()),
columnIndex
));
}
return
result
;
}
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandler.java
浏览文件 @
ae98a3a0
...
...
@@ -45,7 +45,7 @@ public final class BroadcastBackendHandler implements TextProtocolBackendHandler
@Override
public
BackendResponse
execute
()
throws
SQLException
{
String
originalSchema
=
backendConnection
.
getSchema
();
String
originalSchema
=
backendConnection
.
getSchema
Name
();
for
(
String
each
:
ProxyContext
.
getInstance
().
getAllSchemaNames
())
{
backendConnection
.
setCurrentSchema
(
each
);
databaseCommunicationEngineFactory
.
newTextProtocolInstance
(
sqlStatement
,
sql
,
backendConnection
).
execute
();
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandler.java
浏览文件 @
ae98a3a0
...
...
@@ -101,7 +101,7 @@ public final class RDLBackendHandler implements TextProtocolBackendHandler {
Map
<
String
,
DataSourceConfiguration
>
dataSources
=
DataSourceParameterConverter
.
getDataSourceConfigurationMap
(
DataSourceParameterConverter
.
getDataSourceParameterMapFromYamlConfiguration
(
parameters
));
// TODO Need to get the executed feedback from registry center for returning.
ShardingSphereEventBus
.
getInstance
().
post
(
new
DataSourcePersistEvent
(
backendConnection
.
getSchema
(),
dataSources
));
ShardingSphereEventBus
.
getInstance
().
post
(
new
DataSourcePersistEvent
(
backendConnection
.
getSchema
Name
(),
dataSources
));
UpdateResponse
result
=
new
UpdateResponse
();
result
.
setType
(
"CREATE"
);
return
result
;
...
...
@@ -111,7 +111,7 @@ public final class RDLBackendHandler implements TextProtocolBackendHandler {
YamlShardingRuleConfiguration
configs
=
new
CreateShardingRuleStatementContextConverter
().
convert
(
context
);
Collection
<
RuleConfiguration
>
rules
=
new
YamlRuleConfigurationSwapperEngine
().
swapToRuleConfigurations
(
Collections
.
singleton
(
configs
));
// TODO Need to get the executed feedback from registry center for returning.
ShardingSphereEventBus
.
getInstance
().
post
(
new
RulePersistEvent
(
backendConnection
.
getSchema
(),
rules
));
ShardingSphereEventBus
.
getInstance
().
post
(
new
RulePersistEvent
(
backendConnection
.
getSchema
Name
(),
rules
));
UpdateResponse
result
=
new
UpdateResponse
();
result
.
setType
(
"CREATE"
);
return
result
;
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandler.java
浏览文件 @
ae98a3a0
...
...
@@ -53,12 +53,12 @@ public final class ShowTablesBackendHandler implements TextProtocolBackendHandle
@Override
public
BackendResponse
execute
()
throws
SQLException
{
SchemaContext
context
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
());
SchemaContext
context
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
());
if
(
null
==
context
)
{
throw
new
NoDatabaseSelectedException
();
}
if
(!
context
.
isComplete
())
{
return
getDefaultQueryResponse
(
backendConnection
.
getSchema
());
return
getDefaultQueryResponse
(
backendConnection
.
getSchema
Name
());
}
// TODO Get all tables from meta data.
databaseCommunicationEngine
=
databaseCommunicationEngineFactory
.
newTextProtocolInstance
(
sqlStatement
,
sql
,
backendConnection
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/UnicastBackendHandler.java
浏览文件 @
ae98a3a0
...
...
@@ -50,7 +50,7 @@ public final class UnicastBackendHandler implements TextProtocolBackendHandler {
@Override
public
BackendResponse
execute
()
throws
SQLException
{
if
(
null
==
backendConnection
.
getSchema
())
{
if
(
null
==
backendConnection
.
getSchema
Name
())
{
Map
<
String
,
SchemaContext
>
schemaContexts
=
ProxyContext
.
getInstance
().
getSchemaContexts
().
getSchemaContexts
();
if
(
schemaContexts
.
isEmpty
())
{
throw
new
NoDatabaseSelectedException
();
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/query/QueryBackendHandler.java
浏览文件 @
ae98a3a0
...
...
@@ -53,12 +53,12 @@ public final class QueryBackendHandler implements TextProtocolBackendHandler {
@Override
public
BackendResponse
execute
()
throws
SQLException
{
SchemaContext
context
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
());
SchemaContext
context
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
());
if
(
null
==
context
)
{
throw
new
NoDatabaseSelectedException
();
}
if
(!
context
.
isComplete
())
{
return
getDefaultQueryResponse
(
backendConnection
.
getSchema
());
return
getDefaultQueryResponse
(
backendConnection
.
getSchema
Name
());
}
databaseCommunicationEngine
=
databaseCommunicationEngineFactory
.
newTextProtocolInstance
(
sqlStatement
,
sql
,
backendConnection
);
return
databaseCommunicationEngine
.
execute
();
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandler.java
浏览文件 @
ae98a3a0
...
...
@@ -56,7 +56,7 @@ public final class ShardingCTLExplainBackendHandler implements TextProtocolBacke
if
(!
explainStatement
.
isPresent
())
{
throw
new
InvalidShardingCTLFormatException
(
sql
);
}
SchemaContext
schema
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
());
SchemaContext
schema
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
());
StatementExecutorWrapper
statementExecutorWrapper
=
new
StatementExecutorWrapper
(
schema
,
schema
.
getRuntimeContext
().
getSqlParserEngine
().
parse
(
explainStatement
.
get
().
getSql
(),
false
));
executionUnits
=
statementExecutorWrapper
.
generateExecutionContext
(
explainStatement
.
get
().
getSql
()).
getExecutionUnits
().
iterator
();
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/internal/executor/HintShowTableStatusExecutor.java
浏览文件 @
ae98a3a0
...
...
@@ -57,7 +57,7 @@ public final class HintShowTableStatusExecutor extends AbstractHintQueryExecutor
protected
MergedResult
createMergedResult
()
{
Map
<
String
,
HintShowTableStatusResult
>
results
=
new
HashMap
<>();
Collection
<
String
>
tableNames
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
()).
getSchema
().
getMetaData
().
getRuleSchemaMetaData
().
getConfiguredSchemaMetaData
().
getAllTableNames
();
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
()).
getSchema
().
getMetaData
().
getRuleSchemaMetaData
().
getConfiguredSchemaMetaData
().
getAllTableNames
();
for
(
String
each
:
tableNames
)
{
if
(
HintManager
.
isDatabaseShardingOnly
())
{
fillShardingValues
(
results
,
each
,
HintManager
.
getDatabaseShardingValues
(),
Collections
.
emptyList
());
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/TextProtocolBackendHandlerFactoryTest.java
浏览文件 @
ae98a3a0
...
...
@@ -64,7 +64,7 @@ public final class TextProtocolBackendHandlerFactoryTest {
public
void
setUp
()
{
when
(
backendConnection
.
getTransactionType
()).
thenReturn
(
TransactionType
.
LOCAL
);
setTransactionContexts
();
when
(
backendConnection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
}
@SneakyThrows
(
ReflectiveOperationException
.
class
)
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineFactoryTest.java
浏览文件 @
ae98a3a0
...
...
@@ -55,7 +55,7 @@ public final class DatabaseCommunicationEngineFactoryTest {
schemaContexts
.
set
(
ProxyContext
.
getInstance
(),
new
StandardSchemaContexts
(
getSchemaContextMap
(),
new
Authentication
(),
new
ConfigurationProperties
(
new
Properties
()),
new
MySQLDatabaseType
()));
BackendConnection
backendConnection
=
mock
(
BackendConnection
.
class
,
RETURNS_DEEP_STUBS
);
when
(
backendConnection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
isSerialExecute
()).
thenReturn
(
true
);
}
...
...
@@ -69,7 +69,7 @@ public final class DatabaseCommunicationEngineFactoryTest {
@Test
public
void
assertNewTextProtocolInstance
()
{
BackendConnection
backendConnection
=
mock
(
BackendConnection
.
class
);
when
(
backendConnection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
DatabaseCommunicationEngine
engine
=
DatabaseCommunicationEngineFactory
.
getInstance
().
newTextProtocolInstance
(
mock
(
SQLStatement
.
class
),
"schemaName"
,
backendConnection
);
assertNotNull
(
engine
);
...
...
@@ -79,7 +79,7 @@ public final class DatabaseCommunicationEngineFactoryTest {
@Test
public
void
assertNewBinaryProtocolInstance
()
{
BackendConnection
backendConnection
=
mock
(
BackendConnection
.
class
);
when
(
backendConnection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
DatabaseCommunicationEngine
engine
=
DatabaseCommunicationEngineFactory
.
getInstance
().
newBinaryProtocolInstance
(
mock
(
SQLStatement
.
class
),
"schemaName"
,
Collections
.
emptyList
(),
backendConnection
);
assertNotNull
(
engine
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendTransactionManagerTest.java
浏览文件 @
ae98a3a0
...
...
@@ -58,7 +58,7 @@ public final class BackendTransactionManagerTest {
@Before
public
void
setUp
()
{
setTransactionContexts
();
when
(
backendConnection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getStateHandler
()).
thenReturn
(
stateHandler
);
}
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandlerTest.java
浏览文件 @
ae98a3a0
...
...
@@ -73,7 +73,7 @@ public final class BroadcastBackendHandlerTest {
schemaContexts
.
setAccessible
(
true
);
schemaContexts
.
set
(
ProxyContext
.
getInstance
(),
new
StandardSchemaContexts
(
getSchemaContextMap
(),
new
Authentication
(),
new
ConfigurationProperties
(
new
Properties
()),
new
MySQLDatabaseType
()));
when
(
backendConnection
.
getSchema
()).
thenReturn
(
String
.
format
(
SCHEMA_PATTERN
,
0
));
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
String
.
format
(
SCHEMA_PATTERN
,
0
));
}
@Test
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
浏览文件 @
ae98a3a0
...
...
@@ -64,7 +64,7 @@ public final class RDLBackendHandlerTest {
@Test
public
void
assertExecuteCreateDatabaseContext
()
throws
SQLException
{
BackendConnection
connection
=
mock
(
BackendConnection
.
class
);
when
(
connection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
connection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
RDLBackendHandler
executeEngine
=
new
RDLBackendHandler
(
connection
,
new
CreateDatabaseStatement
(
"new_db"
));
try
{
executeEngine
.
execute
();
...
...
@@ -79,7 +79,7 @@ public final class RDLBackendHandlerTest {
@Test
public
void
assertExecuteDropDatabaseContext
()
throws
SQLException
{
BackendConnection
connection
=
mock
(
BackendConnection
.
class
);
when
(
connection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
connection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
RDLBackendHandler
executeEngine
=
new
RDLBackendHandler
(
connection
,
new
DropDatabaseStatement
(
"schema"
));
try
{
executeEngine
.
execute
();
...
...
@@ -94,7 +94,7 @@ public final class RDLBackendHandlerTest {
@Test
public
void
assertExecuteCreateDatabaseContextWithException
()
throws
SQLException
{
BackendConnection
connection
=
mock
(
BackendConnection
.
class
);
when
(
connection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
connection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
RDLBackendHandler
executeEngine
=
new
RDLBackendHandler
(
connection
,
new
CreateDatabaseStatement
(
"schema"
));
try
{
executeEngine
.
execute
();
...
...
@@ -117,7 +117,7 @@ public final class RDLBackendHandlerTest {
@Test
public
void
assertExecuteDataSourcesContext
()
throws
SQLException
{
BackendConnection
connection
=
mock
(
BackendConnection
.
class
);
when
(
connection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
connection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
RDLBackendHandler
executeEngine
=
new
RDLBackendHandler
(
connection
,
mock
(
CreateDataSourcesStatement
.
class
));
try
{
executeEngine
.
execute
();
...
...
@@ -132,7 +132,7 @@ public final class RDLBackendHandlerTest {
@Test
public
void
assertExecuteShardingRuleContext
()
throws
SQLException
{
BackendConnection
connection
=
mock
(
BackendConnection
.
class
);
when
(
connection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
connection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
RDLBackendHandler
executeEngine
=
new
RDLBackendHandler
(
connection
,
mock
(
CreateShardingRuleStatement
.
class
));
try
{
executeEngine
.
execute
();
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandlerTest.java
浏览文件 @
ae98a3a0
...
...
@@ -59,7 +59,7 @@ public class ShowTablesBackendHandlerTest {
when
(
backendConnection
.
getUsername
()).
thenReturn
(
"root"
);
tablesBackendHandler
=
new
ShowTablesBackendHandler
(
"show tables"
,
mock
(
SQLStatement
.
class
),
backendConnection
);
Map
<
String
,
SchemaContext
>
schemaContextMap
=
getSchemaContextMap
();
when
(
backendConnection
.
getSchema
()).
thenReturn
(
String
.
format
(
SCHEMA_PATTERN
,
0
));
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
String
.
format
(
SCHEMA_PATTERN
,
0
));
Field
schemaContexts
=
ProxyContext
.
getInstance
().
getClass
().
getDeclaredField
(
"schemaContexts"
);
schemaContexts
.
setAccessible
(
true
);
schemaContexts
.
set
(
ProxyContext
.
getInstance
(),
new
StandardSchemaContexts
(
schemaContextMap
,
getAuthentication
(),
new
ConfigurationProperties
(
new
Properties
()),
new
MySQLDatabaseType
()));
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
浏览文件 @
ae98a3a0
...
...
@@ -52,7 +52,7 @@ public final class ShardingCTLExplainBackendHandlerTest {
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
setUp
()
{
BackendConnection
connection
=
mock
(
BackendConnection
.
class
);
when
(
connection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
connection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
handler
=
new
ShardingCTLExplainBackendHandler
(
"sctl:explain select 1"
,
connection
);
Field
schemaContexts
=
ProxyContext
.
getInstance
().
getClass
().
getDeclaredField
(
"schemaContexts"
);
schemaContexts
.
setAccessible
(
true
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
浏览文件 @
ae98a3a0
...
...
@@ -169,7 +169,7 @@ public final class ShardingCTLHintBackendHandlerTest {
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
assertShowTableStatus
()
throws
SQLException
{
clearThreadLocal
();
when
(
backendConnection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
Field
schemaContexts
=
ProxyContext
.
getInstance
().
getClass
().
getDeclaredField
(
"schemaContexts"
);
schemaContexts
.
setAccessible
(
true
);
schemaContexts
.
set
(
ProxyContext
.
getInstance
(),
...
...
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
浏览文件 @
ae98a3a0
...
...
@@ -62,7 +62,7 @@ public final class MySQLComStmtExecuteExecutor implements QueryCommandExecutor {
private
int
currentSequenceId
;
public
MySQLComStmtExecuteExecutor
(
final
MySQLComStmtExecutePacket
comStmtExecutePacket
,
final
BackendConnection
backendConnection
)
{
SQLStatement
sqlStatement
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
()).
getRuntimeContext
().
getSqlParserEngine
().
parse
(
comStmtExecutePacket
.
getSql
(),
true
);
SQLStatement
sqlStatement
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
()).
getRuntimeContext
().
getSqlParserEngine
().
parse
(
comStmtExecutePacket
.
getSql
(),
true
);
databaseCommunicationEngine
=
DatabaseCommunicationEngineFactory
.
getInstance
().
newBinaryProtocolInstance
(
sqlStatement
,
comStmtExecutePacket
.
getSql
(),
comStmtExecutePacket
.
getParameters
(),
backendConnection
);
}
...
...
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
浏览文件 @
ae98a3a0
...
...
@@ -52,7 +52,7 @@ public final class MySQLComStmtPrepareExecutor implements CommandExecutor {
public
MySQLComStmtPrepareExecutor
(
final
MySQLComStmtPreparePacket
packet
,
final
BackendConnection
backendConnection
)
{
this
.
packet
=
packet
;
schema
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
());
schema
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
());
}
@Override
...
...
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
浏览文件 @
ae98a3a0
...
...
@@ -50,9 +50,9 @@ public final class MySQLComFieldListPacketExecutor implements CommandExecutor {
public
MySQLComFieldListPacketExecutor
(
final
MySQLComFieldListPacket
packet
,
final
BackendConnection
backendConnection
)
{
this
.
packet
=
packet
;
schemaName
=
backendConnection
.
getSchema
();
schemaName
=
backendConnection
.
getSchema
Name
();
String
sql
=
String
.
format
(
SQL
,
packet
.
getTable
(),
schemaName
);
SQLStatement
sqlStatement
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
()).
getRuntimeContext
().
getSqlParserEngine
().
parse
(
sql
,
false
);
SQLStatement
sqlStatement
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
()).
getRuntimeContext
().
getSqlParserEngine
().
parse
(
sql
,
false
);
databaseCommunicationEngine
=
DatabaseCommunicationEngineFactory
.
getInstance
().
newTextProtocolInstance
(
sqlStatement
,
sql
,
backendConnection
);
}
...
...
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
浏览文件 @
ae98a3a0
...
...
@@ -71,7 +71,7 @@ public final class MySQLCommandExecutorFactoryTest {
schemaContexts
.
set
(
ProxyContext
.
getInstance
(),
new
StandardSchemaContexts
(
getSchemaContextMap
(),
new
Authentication
(),
new
ConfigurationProperties
(
new
Properties
()),
new
MySQLDatabaseType
()));
BackendConnection
backendConnection
=
mock
(
BackendConnection
.
class
);
when
(
backendConnection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
assertThat
(
MySQLCommandExecutorFactory
.
newInstance
(
MySQLCommandPacketType
.
COM_QUIT
,
mock
(
CommandPacket
.
class
),
backendConnection
),
instanceOf
(
MySQLComQuitExecutor
.
class
));
assertThat
(
MySQLCommandExecutorFactory
.
newInstance
(
MySQLCommandPacketType
.
COM_INIT_DB
,
...
...
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
浏览文件 @
ae98a3a0
...
...
@@ -76,7 +76,7 @@ public final class MySQLComStmtExecuteExecutorTest {
@Test
public
void
assertIsQueryResponse
()
throws
NoSuchFieldException
,
SQLException
{
BackendConnection
backendConnection
=
mock
(
BackendConnection
.
class
);
when
(
backendConnection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
MySQLComStmtExecuteExecutor
mysqlComStmtExecuteExecutor
=
new
MySQLComStmtExecuteExecutor
(
mock
(
MySQLComStmtExecutePacket
.
class
),
backendConnection
);
FieldSetter
.
setField
(
mysqlComStmtExecuteExecutor
,
MySQLComStmtExecuteExecutor
.
class
.
getDeclaredField
(
"databaseCommunicationEngine"
),
databaseCommunicationEngine
);
when
(
databaseCommunicationEngine
.
execute
()).
thenReturn
(
new
QueryResponse
(
Collections
.
singletonList
(
mock
(
QueryHeader
.
class
))));
...
...
@@ -87,7 +87,7 @@ public final class MySQLComStmtExecuteExecutorTest {
@Test
public
void
assertIsUpdateResponse
()
throws
NoSuchFieldException
,
SQLException
{
BackendConnection
backendConnection
=
mock
(
BackendConnection
.
class
);
when
(
backendConnection
.
getSchema
()).
thenReturn
(
"schema"
);
when
(
backendConnection
.
getSchema
Name
()).
thenReturn
(
"schema"
);
MySQLComStmtExecuteExecutor
mysqlComStmtExecuteExecutor
=
new
MySQLComStmtExecuteExecutor
(
mock
(
MySQLComStmtExecutePacket
.
class
),
backendConnection
);
FieldSetter
.
setField
(
mysqlComStmtExecuteExecutor
,
MySQLComStmtExecuteExecutor
.
class
.
getDeclaredField
(
"databaseCommunicationEngine"
),
databaseCommunicationEngine
);
when
(
databaseCommunicationEngine
.
execute
()).
thenReturn
(
new
UpdateResponse
());
...
...
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
浏览文件 @
ae98a3a0
...
...
@@ -67,7 +67,7 @@ public final class PostgreSQLComBindExecutor implements QueryCommandExecutor {
public
PostgreSQLComBindExecutor
(
final
PostgreSQLComBindPacket
packet
,
final
BackendConnection
backendConnection
)
{
this
.
packet
=
packet
;
SchemaContext
schemaContext
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
());
SchemaContext
schemaContext
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
());
if
(
null
!=
packet
.
getSql
()
&&
null
!=
schemaContext
)
{
SQLStatement
sqlStatement
=
schemaContext
.
getRuntimeContext
().
getSqlParserEngine
().
parse
(
packet
.
getSql
(),
true
);
databaseCommunicationEngine
=
...
...
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutor.java
浏览文件 @
ae98a3a0
...
...
@@ -44,7 +44,7 @@ public final class PostgreSQLComParseExecutor implements CommandExecutor {
public
PostgreSQLComParseExecutor
(
final
PostgreSQLComParsePacket
packet
,
final
BackendConnection
backendConnection
)
{
this
.
packet
=
packet
;
schema
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
());
schema
=
ProxyContext
.
getInstance
().
getSchema
(
backendConnection
.
getSchema
Name
());
binaryStatementRegistry
=
BinaryStatementRegistry
.
getInstance
().
get
(
backendConnection
.
getConnectionId
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录