use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class ShowTime method execute.
public static void execute(ManagerConnection c, int type) {
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 = getRow(type, c.getCharset().getResults());
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 ShowWhiteHost method execute.
public static void execute(ManagerConnection 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();
Map<String, List<UserConfig>> map = DbleServer.getInstance().getConfig().getFirewall().getWhitehost();
for (Map.Entry<String, List<UserConfig>> entry : map.entrySet()) {
List<UserConfig> userConfigs = entry.getValue();
StringBuilder users = new StringBuilder();
for (int i = 0; i < userConfigs.size(); i++) {
if (i > 0) {
users.append(",");
}
users.append(userConfigs.get(i).getName());
}
RowDataPacket row = getRow(entry.getKey(), users.toString(), c.getCharset().getResults());
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);
// write buffer
c.write(buffer);
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class AggregatorDistinct method setup.
/**
************************************************************************
*/
/**
* Called before feeding the first row. Used to allocate/setup the internal
* structures used for aggregation.
*
* @param thd Thread descriptor
* @return status
* @throws UnsupportedEncodingException
* @retval FALSE success
* @retval TRUE faliure
* <p>
* Prepares Aggregator_distinct to process the incoming stream.
* Creates the temporary table and the Unique class if needed.
* Called by Item_sum::aggregator_setup()
*/
@Override
public boolean setup() {
endupDone = false;
if (itemSum.setup())
return true;
// TODO see item_sum.cc for more
FieldPacket tmp = new FieldPacket();
itemSum.getArg(0).makeField(tmp);
field = Field.getFieldItem(tmp.getName(), tmp.getDb(), tmp.getTable(), tmp.getOrgTable(), tmp.getType(), tmp.getCharsetIndex(), (int) tmp.getLength(), tmp.getDecimals(), tmp.getFlags());
return false;
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class ExplainHandler method handle.
public static void handle(String stmt, ServerConnection c, int offset) {
stmt = stmt.substring(offset).trim();
RouteResultset rrs = getRouteResultset(c, stmt);
if (rrs == null) {
return;
}
ByteBuffer buffer = c.allocate();
// write header
ResultSetHeaderPacket header = PacketUtil.getHeader(FIELD_COUNT);
byte packetId = header.getPacketId();
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : FIELDS) {
field.setPacketId(++packetId);
buffer = field.write(buffer, c, true);
}
// write eof
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
buffer = eof.write(buffer, c, true);
if (!rrs.isNeedOptimizer()) {
// write rows
for (RouteResultsetNode node : rrs.getNodes()) {
RowDataPacket row = getRow(node, c.getCharset().getResults());
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
}
} else {
List<String[]> results = getComplexQueryResult(rrs, c);
for (String[] result : results) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(result[0], c.getCharset().getResults()));
row.add(StringUtil.encode(result[1], c.getCharset().getResults()));
row.add(StringUtil.encode(result[2].replaceAll("[\\t\\n\\r]", " "), c.getCharset().getResults()));
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 MysqlInformationSchemaHandler method doWrite.
/**
* @param fieldCount
* @param fields
* @param c
*/
public static void doWrite(int fieldCount, FieldPacket[] fields, ServerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
ResultSetHeaderPacket header = PacketUtil.getHeader(fieldCount);
byte packetId = header.getPacketId();
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : fields) {
field.setPacketId(++packetId);
buffer = field.write(buffer, c, true);
}
// write eof
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
buffer = eof.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);
}
Aggregations