Search in sources :

Example 16 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat-Server by MyCATApache.

the class AuthPacket method read.

public void read(byte[] data) {
    MySQLMessage mm = new MySQLMessage(data);
    packetLength = mm.readUB3();
    packetId = mm.read();
    clientFlags = mm.readUB4();
    maxPacketSize = mm.readUB4();
    charsetIndex = (mm.read() & 0xff);
    // read extra
    int current = mm.position();
    int len = (int) mm.readLength();
    if (len > 0 && len < FILLER.length) {
        byte[] ab = new byte[len];
        System.arraycopy(mm.bytes(), mm.position(), ab, 0, len);
        this.extra = ab;
    }
    mm.position(current + FILLER.length);
    user = mm.readStringWithNull();
    password = mm.readBytesWithLength();
    if (((clientFlags & Capabilities.CLIENT_CONNECT_WITH_DB) != 0) && mm.hasRemaining()) {
        database = mm.readStringWithNull();
    }
}
Also used : MySQLMessage(io.mycat.backend.mysql.MySQLMessage)

Example 17 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat-Server by MyCATApache.

the class FieldPacket method read.

/**
 * 把BinaryPacket转变成FieldPacket
 */
public void read(BinaryPacket bin) {
    this.packetLength = bin.packetLength;
    this.packetId = bin.packetId;
    readBody(new MySQLMessage(bin.data));
}
Also used : MySQLMessage(io.mycat.backend.mysql.MySQLMessage)

Example 18 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat-Server by MyCATApache.

the class FieldPacket method read.

/**
 * 把字节数组转变成FieldPacket
 */
public void read(byte[] data) {
    MySQLMessage mm = new MySQLMessage(data);
    this.packetLength = mm.readUB3();
    this.packetId = mm.read();
    readBody(mm);
}
Also used : MySQLMessage(io.mycat.backend.mysql.MySQLMessage)

Example 19 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat-Server by MyCATApache.

the class OkPacket method read.

public void read(byte[] data) {
    MySQLMessage mm = new MySQLMessage(data);
    packetLength = mm.readUB3();
    packetId = mm.read();
    fieldCount = mm.read();
    affectedRows = mm.readLength();
    insertId = mm.readLength();
    serverStatus = mm.readUB2();
    warningCount = mm.readUB2();
    if (mm.hasRemaining()) {
        this.message = mm.readBytesWithLength();
    }
}
Also used : MySQLMessage(io.mycat.backend.mysql.MySQLMessage)

Example 20 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat-Server by MyCATApache.

the class RowDataPacket method read.

public void read(byte[] data) {
    value = data;
    MySQLMessage mm = new MySQLMessage(data);
    packetLength = mm.readUB3();
    packetId = mm.read();
    for (int i = 0; i < fieldCount; i++) {
        fieldValues.add(mm.readBytesWithLength());
    }
}
Also used : MySQLMessage(io.mycat.backend.mysql.MySQLMessage)

Aggregations

MySQLMessage (io.mycat.backend.mysql.MySQLMessage)56 Test (org.junit.Test)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 ByteBuffer (java.nio.ByteBuffer)4 BindValue (io.mycat.backend.mysql.BindValue)2 BufferHolder (io.mycat.memory.unsafe.row.BufferHolder)2 UnsafeRow (io.mycat.memory.unsafe.row.UnsafeRow)2 UnsafeRowWriter (io.mycat.memory.unsafe.row.UnsafeRowWriter)2 EOFPacket (io.mycat.net.mysql.EOFPacket)2 ServerConnection (io.mycat.server.ServerConnection)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2