Search in sources :

Example 36 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat_plus by coderczp.

the class OkPacket method read.

public void read(BinaryPacket bin) {
    packetLength = bin.packetLength;
    packetId = bin.packetId;
    MySQLMessage mm = new MySQLMessage(bin.data);
    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 37 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat_plus by coderczp.

the class MySQLMessageTest method testReadBytesWithNull.

@Test
public void testReadBytesWithNull() {
    byte[] bytes = new byte[] { 1, 2, 3, 0, 5 };
    MySQLMessage message = new MySQLMessage(bytes);
    byte[] ab = message.readBytesWithNull();
    Assert.assertEquals(3, ab.length);
    Assert.assertEquals(4, message.position());
}
Also used : MySQLMessage(io.mycat.backend.mysql.MySQLMessage) Test(org.junit.Test)

Example 38 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat_plus by coderczp.

the class MySQLMessageTest method testReadBytesWithNull3.

@Test
public void testReadBytesWithNull3() {
    byte[] bytes = new byte[] {};
    MySQLMessage message = new MySQLMessage(bytes);
    byte[] ab = message.readBytesWithNull();
    Assert.assertEquals(0, ab.length);
    Assert.assertEquals(0, message.position());
}
Also used : MySQLMessage(io.mycat.backend.mysql.MySQLMessage) Test(org.junit.Test)

Example 39 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat_plus by coderczp.

the class ResetPacket method read.

public void read(byte[] data) {
    MySQLMessage mm = new MySQLMessage(data);
    packetLength = mm.readUB3();
    packetId = mm.read();
    byte code = mm.read();
    assert code == PACKET_FALG;
    pstmtId = mm.readUB4();
}
Also used : MySQLMessage(io.mycat.backend.mysql.MySQLMessage)

Example 40 with MySQLMessage

use of io.mycat.backend.mysql.MySQLMessage in project Mycat_plus by coderczp.

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