Search in sources :

Example 21 with ResultSetHeaderPacket

use of io.mycat.net.mysql.ResultSetHeaderPacket in project Mycat-Server by MyCATApache.

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.packetId;
    buffer = header.write(buffer, c, true);
    // write fields
    for (FieldPacket field : fields) {
        field.packetId = ++packetId;
        buffer = field.write(buffer, c, true);
    }
    // write eof
    EOFPacket eof = new EOFPacket();
    eof.packetId = ++packetId;
    buffer = eof.write(buffer, c, true);
    // write rows
    RouteResultsetNode[] rrsn = rrs.getNodes();
    for (RouteResultsetNode node : rrsn) {
        RowDataPacket row = getRow(node, c.getCharset());
        row.packetId = ++packetId;
        buffer = row.write(buffer, c, true);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // post write
    c.write(buffer);
}
Also used : ResultSetHeaderPacket(io.mycat.net.mysql.ResultSetHeaderPacket) RouteResultsetNode(io.mycat.route.RouteResultsetNode) RowDataPacket(io.mycat.net.mysql.RowDataPacket) EOFPacket(io.mycat.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket) RouteResultset(io.mycat.route.RouteResultset)

Example 22 with ResultSetHeaderPacket

use of io.mycat.net.mysql.ResultSetHeaderPacket in project Mycat-Server by MyCATApache.

the class MysqlProcHandler method handle.

public static void handle(String stmt, ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    // write header
    ResultSetHeaderPacket header = PacketUtil.getHeader(FIELD_COUNT);
    byte packetId = header.packetId;
    buffer = header.write(buffer, c, true);
    // write fields
    for (FieldPacket field : fields) {
        field.packetId = ++packetId;
        buffer = field.write(buffer, c, true);
    }
    // write eof
    EOFPacket eof = new EOFPacket();
    eof.packetId = ++packetId;
    buffer = eof.write(buffer, c, true);
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // post write
    c.write(buffer);
}
Also used : ResultSetHeaderPacket(io.mycat.net.mysql.ResultSetHeaderPacket) EOFPacket(io.mycat.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Aggregations

ResultSetHeaderPacket (io.mycat.net.mysql.ResultSetHeaderPacket)22 ByteBuffer (java.nio.ByteBuffer)19 EOFPacket (io.mycat.net.mysql.EOFPacket)18 FieldPacket (io.mycat.net.mysql.FieldPacket)18 RowDataPacket (io.mycat.net.mysql.RowDataPacket)13 ServerConnection (io.mycat.server.ServerConnection)4 Procedure (io.mycat.route.Procedure)2 ProcedureParameter (io.mycat.route.ProcedureParameter)2 RouteResultset (io.mycat.route.RouteResultset)2 RouteResultsetNode (io.mycat.route.RouteResultsetNode)2 ColMeta (io.mycat.sqlengine.mpp.ColMeta)2 IOException (java.io.IOException)2 BigDecimal (java.math.BigDecimal)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 DataRow (io.mycat.backend.postgresql.packet.DataRow)1 RowDescription (io.mycat.backend.postgresql.packet.RowDescription)1 BufferArray (io.mycat.buffer.BufferArray)1 ArrayList (java.util.ArrayList)1