Skip to content

Commit

Permalink
[inner-2321] fix: explain statement contained in multiple-sql appears…
Browse files Browse the repository at this point in the history
… lost connection...

(cherry picked from commit 02f9ee6)
  • Loading branch information
wenyh1 committed Jan 14, 2024
1 parent 5eb3652 commit 00349ea
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,25 @@ public static void writeOutHeadAndEof(ShardingService service, RouteResultset rr
ByteBuffer buffer = service.allocate();
// writeDirectly header
ResultSetHeaderPacket header = PacketUtil.getHeader(FIELD_COUNT);
byte packetId = header.getPacketId();
header.setPacketId(service.nextPacketId());
buffer = header.write(buffer, service, true);

// writeDirectly fields
for (FieldPacket field : FIELDS) {
field.setPacketId(++packetId);
field.setPacketId(service.nextPacketId());
buffer = field.write(buffer, service, true);
}

// writeDirectly eof
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
eof.setPacketId(service.nextPacketId());
buffer = eof.write(buffer, service, true);

if (!rrs.isNeedOptimizer()) {
// writeDirectly rows
for (RouteResultsetNode node : rrs.getNodes()) {
RowDataPacket row = getRow(node, service.getCharset().getResults());
row.setPacketId(++packetId);
row.setPacketId(service.nextPacketId());
buffer = row.write(buffer, service, true);
}
} else {
Expand All @@ -232,13 +232,13 @@ public static void writeOutHeadAndEof(ShardingService service, RouteResultset rr
row.add(StringUtil.encode(result.getName(), service.getCharset().getResults()));
row.add(StringUtil.encode(result.getType(), service.getCharset().getResults()));
row.add(StringUtil.encode(result.getRefOrSQL(), service.getCharset().getResults()));
row.setPacketId(++packetId);
row.setPacketId(service.nextPacketId());
buffer = row.write(buffer, service, true);
}
}
// writeDirectly last eof
EOFRowPacket lastEof = new EOFRowPacket();
lastEof.setPacketId(++packetId);
lastEof.setPacketId(service.nextPacketId());
lastEof.write(buffer, service);
}
}

0 comments on commit 00349ea

Please sign in to comment.