use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class ShowTables method writeFullTablesHeader.
public static PackageBufINf writeFullTablesHeader(ByteBuffer buffer, ServerConnection c, String cSchema, List<FieldPacket> fieldPackets) {
int fieldCount = 2;
ResultSetHeaderPacket header = PacketUtil.getHeader(fieldCount);
FieldPacket[] fields = new FieldPacket[fieldCount];
int i = 0;
byte packetId = 0;
header.setPacketId(++packetId);
fields[i] = PacketUtil.getField("Tables in " + cSchema, Fields.FIELD_TYPE_VAR_STRING);
fields[i].setPacketId(++packetId);
fieldPackets.add(fields[i]);
fields[i + 1] = PacketUtil.getField("Table_type ", Fields.FIELD_TYPE_VAR_STRING);
fields[i + 1].setPacketId(++packetId);
fieldPackets.add(fields[i + 1]);
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
// write header
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
eof.write(buffer, c, true);
PackageBufINf packBuffInfo = new PackageBufINf();
packBuffInfo.setBuffer(buffer);
packBuffInfo.setPacketId(packetId);
return packBuffInfo;
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class ShowTables method responseDirect.
private static void responseDirect(ServerConnection c, String cSchema, ShowCreateStmtInfo info) {
ByteBuffer buffer = c.allocate();
Map<String, String> tableMap = getTableSet(cSchema, info);
PackageBufINf bufInf;
if (info.isFull()) {
List<FieldPacket> fieldPackets = new ArrayList<>(2);
bufInf = writeFullTablesHeader(buffer, c, cSchema, fieldPackets);
if (info.getWhere() != null) {
MySQLItemVisitor mev = new MySQLItemVisitor(c.getSchema(), c.getCharset().getResultsIndex(), DbleServer.getInstance().getTmManager());
info.getWhereExpr().accept(mev);
List<Field> sourceFields = HandlerTool.createFields(fieldPackets);
Item whereItem = HandlerTool.createItem(mev.getItem(), sourceFields, 0, false, DMLResponseHandler.HandlerType.WHERE);
bufInf = writeFullTablesRow(bufInf.getBuffer(), c, tableMap, bufInf.getPacketId(), whereItem, sourceFields);
} else {
bufInf = writeFullTablesRow(bufInf.getBuffer(), c, tableMap, bufInf.getPacketId(), null, null);
}
} else {
bufInf = writeTablesHeaderAndRows(buffer, c, tableMap, cSchema);
}
writeRowEof(bufInf.getBuffer(), c, bufInf.getPacketId());
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class ShowTables method writeTablesHeaderAndRows.
public static PackageBufINf writeTablesHeaderAndRows(ByteBuffer buffer, ServerConnection c, Map<String, String> tableMap, String cSchema) {
int fieldCount = 1;
ResultSetHeaderPacket header = PacketUtil.getHeader(fieldCount);
FieldPacket[] fields = new FieldPacket[fieldCount];
int i = 0;
byte packetId = 0;
header.setPacketId(++packetId);
fields[i] = PacketUtil.getField("Tables in " + cSchema, Fields.FIELD_TYPE_VAR_STRING);
fields[i].setPacketId(++packetId);
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
// write header
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
// write eof
eof.write(buffer, c, true);
for (String name : tableMap.keySet()) {
RowDataPacket row = new RowDataPacket(fieldCount);
row.add(StringUtil.encode(name.toLowerCase(), c.getCharset().getResults()));
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
}
PackageBufINf packBuffInfo = new PackageBufINf();
packBuffInfo.setBuffer(buffer);
packBuffInfo.setPacketId(packetId);
return packBuffInfo;
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class SelectVersionComment method response.
public static void response(FrontendConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = HEADER.write(buffer, c, true);
// write fields
for (FieldPacket field : FIELDS) {
buffer = field.write(buffer, c, true);
}
// write eof
buffer = EOF.write(buffer, c, true);
// write rows
byte packetId = EOF.getPacketId();
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(Versions.VERSION_COMMENT);
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.setPacketId(++packetId);
buffer = lastEof.write(buffer, c, true);
// post write
c.write(buffer);
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class SessionIncrement method response.
public static void response(ServerConnection c) {
ByteBuffer buffer = c.allocate();
buffer = HEADER.write(buffer, c, true);
for (FieldPacket field : FIELDS) {
buffer = field.write(buffer, c, true);
}
buffer = EOF.write(buffer, c, true);
byte packetId = EOF.getPacketId();
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(LongUtil.toBytes(1));
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
EOFPacket lastEof = new EOFPacket();
lastEof.setPacketId(++packetId);
buffer = lastEof.write(buffer, c, true);
c.write(buffer);
}
Aggregations