Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
48edb1ff
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,发现更多精彩内容 >>
提交
48edb1ff
编写于
4月 20, 2018
作者:
T
tuohai666
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
for #675 conventions
上级
84b00489
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
28 deletion
+23
-28
sharding-proxy/src/main/java/io/shardingjdbc/proxy/backend/common/StatementExecuteBackendHandler.java
.../proxy/backend/common/StatementExecuteBackendHandler.java
+22
-27
sharding-proxy/src/main/java/io/shardingjdbc/proxy/transport/mysql/packet/command/statement/execute/ComStmtExecutePacket.java
...acket/command/statement/execute/ComStmtExecutePacket.java
+1
-1
未找到文件。
sharding-proxy/src/main/java/io/shardingjdbc/proxy/backend/common/StatementExecuteBackendHandler.java
浏览文件 @
48edb1ff
...
...
@@ -77,7 +77,7 @@ public final class StatementExecuteBackendHandler implements BackendHandler {
private
final
List
<
ColumnType
>
columnTypes
;
private
boolean
noMoreValues
;
private
boolean
hasMoreResultValueFlag
;
public
StatementExecuteBackendHandler
(
final
List
<
PreparedStatementParameter
>
preparedStatementParameters
,
final
int
statementId
,
final
DatabaseType
databaseType
,
final
boolean
showSQL
)
{
this
.
preparedStatementParameters
=
preparedStatementParameters
;
...
...
@@ -85,7 +85,7 @@ public final class StatementExecuteBackendHandler implements BackendHandler {
connections
=
new
ArrayList
<>(
1024
);
resultSets
=
new
ArrayList
<>(
1024
);
columnTypes
=
new
ArrayList
<>(
32
);
noMoreValues
=
fals
e
;
hasMoreResultValueFlag
=
tru
e
;
}
@Override
...
...
@@ -164,7 +164,7 @@ public final class StatementExecuteBackendHandler implements BackendHandler {
}
catch
(
final
SQLException
ex
)
{
return
new
CommandResponsePackets
(
new
ErrPacket
(
1
,
ex
.
getErrorCode
(),
""
,
ex
.
getSQLState
(),
ex
.
getMessage
()));
}
finally
{
if
(
preparedStatement
!=
null
)
{
if
(
null
!=
preparedStatement
)
{
try
{
preparedStatement
.
close
();
}
catch
(
final
SQLException
ignore
)
{
...
...
@@ -255,10 +255,6 @@ public final class StatementExecuteBackendHandler implements BackendHandler {
private
CommandResponsePackets
mergeDQLorDAL
(
final
SQLStatement
sqlStatement
,
final
List
<
CommandResponsePackets
>
packets
)
{
List
<
QueryResult
>
queryResults
=
new
ArrayList
<>(
packets
.
size
());
// for (CommandResponsePackets each : packets) {
// // TODO replace to a common PacketQueryResult
// queryResults.add(new MySQLPacketStatementExecuteQueryResult(each, resultSet, columnTypes));
// }
for
(
int
i
=
0
;
i
<
packets
.
size
();
i
++)
{
// TODO replace to a common PacketQueryResult
queryResults
.
add
(
new
MySQLPacketStatementExecuteQueryResult
(
packets
.
get
(
i
),
resultSets
.
get
(
i
),
columnTypes
));
...
...
@@ -277,7 +273,6 @@ public final class StatementExecuteBackendHandler implements BackendHandler {
FieldCountPacket
fieldCountPacketSampling
=
(
FieldCountPacket
)
databaseProtocolPacketsSampling
.
next
();
result
.
addPacket
(
fieldCountPacketSampling
);
++
currentSequenceId
;
int
columnCount
=
fieldCountPacketSampling
.
getColumnCount
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
result
.
addPacket
(
databaseProtocolPacketsSampling
.
next
());
++
currentSequenceId
;
...
...
@@ -288,22 +283,37 @@ public final class StatementExecuteBackendHandler implements BackendHandler {
}
public
boolean
hasMoreResultValue
()
throws
SQLException
{
if
(
noMoreValues
)
{
if
(
!
hasMoreResultValueFlag
)
{
return
false
;
}
if
(!
mergedResult
.
next
())
{
noMoreValues
=
tru
e
;
hasMoreResultValueFlag
=
fals
e
;
cleanJDBCResources
();
}
return
true
;
}
public
DatabaseProtocolPacket
getResultValue
()
{
if
(!
hasMoreResultValueFlag
)
{
return
new
EofPacket
(++
currentSequenceId
,
0
,
StatusFlag
.
SERVER_STATUS_AUTOCOMMIT
.
getValue
());
}
try
{
List
<
Object
>
data
=
new
ArrayList
<>(
columnCount
);
for
(
int
i
=
1
;
i
<=
columnCount
;
i
++)
{
data
.
add
(
mergedResult
.
getValue
(
i
,
Object
.
class
));
}
return
new
BinaryResultSetRowPacket
(++
currentSequenceId
,
columnCount
,
data
,
columnTypes
);
}
catch
(
final
SQLException
ex
)
{
return
new
ErrPacket
(
1
,
ex
.
getErrorCode
(),
""
,
ex
.
getSQLState
(),
ex
.
getMessage
());
}
}
private
void
cleanJDBCResources
()
{
for
(
ResultSet
each
:
resultSets
)
{
if
(
null
!=
each
)
{
try
{
each
.
close
();
}
catch
(
SQLException
ignore
)
{
}
catch
(
final
SQLException
ignore
)
{
}
}
}
...
...
@@ -311,24 +321,9 @@ public final class StatementExecuteBackendHandler implements BackendHandler {
if
(
null
!=
each
)
{
try
{
each
.
close
();
}
catch
(
SQLException
ignore
)
{
}
catch
(
final
SQLException
ignore
)
{
}
}
}
}
public
DatabaseProtocolPacket
getResultValue
()
{
if
(
noMoreValues
)
{
return
new
EofPacket
(++
currentSequenceId
,
0
,
StatusFlag
.
SERVER_STATUS_AUTOCOMMIT
.
getValue
());
}
try
{
List
<
Object
>
data
=
new
ArrayList
<>(
columnCount
);
for
(
int
i
=
1
;
i
<=
columnCount
;
i
++)
{
data
.
add
(
mergedResult
.
getValue
(
i
,
Object
.
class
));
}
return
new
BinaryResultSetRowPacket
(++
currentSequenceId
,
columnCount
,
data
,
columnTypes
);
}
catch
(
final
SQLException
ex
)
{
return
new
ErrPacket
(
1
,
ex
.
getErrorCode
(),
""
,
ex
.
getSQLState
(),
ex
.
getMessage
());
}
}
}
sharding-proxy/src/main/java/io/shardingjdbc/proxy/transport/mysql/packet/command/statement/execute/ComStmtExecutePacket.java
浏览文件 @
48edb1ff
...
...
@@ -155,7 +155,7 @@ public final class ComStmtExecutePacket extends CommandPacket {
public
boolean
hasMoreResultValue
()
{
try
{
return
statementExecuteBackendHandler
.
hasMoreResultValue
();
}
catch
(
SQLException
ex
)
{
}
catch
(
final
SQLException
ex
)
{
return
false
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录