提交 4546124a 编写于 作者: T terrymanu

remove BackendHandler.isHasMoreResultValueFlag()

上级 559c96b9
......@@ -50,7 +50,4 @@ public interface BackendHandler {
* @return database packet
*/
DatabasePacket getResultValue();
@Deprecated
boolean isHasMoreResultValueFlag();
}
......@@ -38,7 +38,6 @@ import io.shardingsphere.proxy.transport.common.packet.DatabasePacket;
import io.shardingsphere.proxy.transport.mysql.constant.ServerErrorCode;
import io.shardingsphere.proxy.transport.mysql.packet.command.reponse.CommandResponsePackets;
import io.shardingsphere.proxy.transport.mysql.packet.command.reponse.QueryResponsePackets;
import io.shardingsphere.proxy.transport.mysql.packet.generic.EofPacket;
import io.shardingsphere.proxy.transport.mysql.packet.generic.ErrPacket;
import io.shardingsphere.proxy.transport.mysql.packet.generic.OKPacket;
import io.shardingsphere.transaction.xa.AtomikosUserTransaction;
......@@ -147,21 +146,15 @@ public final class JDBCBackendHandler implements BackendHandler {
@Override
public boolean hasMoreResultValue() throws SQLException {
if (null == mergedResult || !hasMoreResultValueFlag) {
if (null == mergedResult || !mergedResult.next()) {
backendConnection.close();
return false;
}
if (!mergedResult.next()) {
hasMoreResultValueFlag = false;
}
return true;
}
@Override
public DatabasePacket getResultValue() {
if (!hasMoreResultValueFlag) {
return new EofPacket(++currentSequenceId);
}
QueryResponsePackets queryResponsePackets = ((ExecuteQueryResponse) executeResponse).getQueryResponsePackets();
try {
List<Object> data = new ArrayList<>(queryResponsePackets.getColumnCount());
......@@ -171,7 +164,7 @@ public final class JDBCBackendHandler implements BackendHandler {
return executeEngine.getJdbcExecutorWrapper().createResultSetPacket(
++currentSequenceId, data, queryResponsePackets.getColumnCount(), queryResponsePackets.getColumnTypes(), DatabaseType.MySQL);
} catch (final SQLException ex) {
return new ErrPacket(1, ex);
return new ErrPacket(++currentSequenceId, ex);
}
}
}
......@@ -26,6 +26,7 @@ import io.shardingsphere.proxy.transport.mysql.constant.ServerErrorCode;
import io.shardingsphere.proxy.transport.mysql.packet.MySQLPacketPayload;
import io.shardingsphere.proxy.transport.mysql.packet.command.CommandPacket;
import io.shardingsphere.proxy.transport.mysql.packet.command.CommandPacketFactory;
import io.shardingsphere.proxy.transport.mysql.packet.generic.EofPacket;
import io.shardingsphere.proxy.transport.mysql.packet.generic.ErrPacket;
import io.shardingsphere.proxy.transport.mysql.packet.generic.OKPacket;
import io.shardingsphere.proxy.transport.mysql.packet.handshake.AuthorityHandler;
......@@ -86,8 +87,11 @@ public final class MySQLFrontendHandler extends FrontendHandler {
while (!context.channel().isWritable()) {
continue;
}
context.writeAndFlush(commandPacket.getResultValue());
DatabasePacket resultValue = commandPacket.getResultValue();
sequenceId = resultValue.getSequenceId();
context.writeAndFlush(resultValue);
}
context.writeAndFlush(new EofPacket(++sequenceId));
}
}
});
......
......@@ -23,4 +23,10 @@ package io.shardingsphere.proxy.transport.common.packet;
* @author zhangliang
*/
public interface DatabasePacket {
/**
* Get sequence ID.
* @return sequence ID
*/
int getSequenceId();
}
......@@ -25,4 +25,9 @@ import io.shardingsphere.proxy.transport.common.packet.DatabasePacket;
* @author zhangyonglun
*/
public final class DummyPacket implements DatabasePacket {
@Override
public int getSequenceId() {
return 1;
}
}
......@@ -36,7 +36,6 @@ import io.shardingsphere.proxy.transport.mysql.packet.command.statement.close.Du
import io.shardingsphere.proxy.transport.mysql.packet.command.text.query.ColumnDefinition41Packet;
import io.shardingsphere.proxy.transport.mysql.packet.command.text.query.ComQueryPacket;
import io.shardingsphere.proxy.transport.mysql.packet.command.text.query.TextResultSetRowPacket;
import io.shardingsphere.proxy.transport.mysql.packet.generic.EofPacket;
import io.shardingsphere.proxy.transport.mysql.packet.generic.ErrPacket;
import lombok.extern.slf4j.Slf4j;
......@@ -112,9 +111,6 @@ public final class ComFieldListPacket extends CommandPacket implements CommandPa
@Override
public DatabasePacket getResultValue() {
DatabasePacket resultValue = backendHandler.getResultValue();
if (!backendHandler.isHasMoreResultValueFlag()) {
return new EofPacket(++currentSequenceId);
}
if (resultValue instanceof TextResultSetRowPacket) {
TextResultSetRowPacket fieldListResponse = (TextResultSetRowPacket) resultValue;
String columnName = (String) fieldListResponse.getData().get(0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册