Search in sources :

Example 6 with ReadView

use of io.mycat.vertx.ReadView in project Mycat2 by MyCATApache.

the class StringArrayDecoder method decodeColumnDefinitionPacketPayload.

ColumnDefPacketImpl decodeColumnDefinitionPacketPayload(Buffer payload) {
    ReadView readView = new ReadView(payload);
    byte[] catalog = readView.readLenencStringBytes();
    byte[] schema = readView.readLenencStringBytes();
    byte[] table = readView.readLenencStringBytes();
    byte[] orgTable = readView.readLenencStringBytes();
    byte[] name = readView.readLenencStringBytes();
    byte[] orgName = readView.readLenencStringBytes();
    long lengthOfFixedLengthFields = readView.readLenencInt();
    int characterSet = (int) readView.readFixInt(2);
    long columnLength = (int) readView.readFixInt(4);
    int type = readView.readByte() & 0xff;
    int flags = (int) readView.readFixInt(2);
    byte decimals = readView.readByte();
    ColumnDefPacketImpl columnDefPacket = new ColumnDefPacketImpl();
    columnDefPacket.setColumnSchema(schema);
    columnDefPacket.setColumnTable(table);
    columnDefPacket.setColumnOrgTable(orgTable);
    columnDefPacket.setColumnName(name);
    columnDefPacket.setColumnOrgName(orgName);
    columnDefPacket.setColumnCharsetSet(characterSet);
    columnDefPacket.setColumnLength((int) columnLength);
    columnDefPacket.setColumnType(type);
    columnDefPacket.setColumnFlags(flags);
    columnDefPacket.setColumnDecimals(decimals);
    return columnDefPacket;
}
Also used : ReadView(io.mycat.vertx.ReadView) ColumnDefPacketImpl(io.mycat.beans.mysql.packet.ColumnDefPacketImpl)

Example 7 with ReadView

use of io.mycat.vertx.ReadView in project Mycat2 by MyCATApache.

the class PacketUtil method decodeOkPacketPayload.

// simplify the ok packet as those properties are actually not used for now
public static Packets.OkPacket decodeOkPacketPayload(Buffer payload) {
    ReadView readView = new ReadView(payload);
    readView.skipInReading(1);
    long affectedRows = readView.readLenencInt();
    long lastInsertId = readView.readLenencInt();
    int serverStatusFlags = readView.readLenencInt().intValue();
    String statusInfo = null;
    String sessionStateInfo = null;
    return new Packets.OkPacket(affectedRows, lastInsertId, serverStatusFlags, 0, statusInfo, sessionStateInfo);
}
Also used : ReadView(io.mycat.vertx.ReadView)

Example 8 with ReadView

use of io.mycat.vertx.ReadView in project Mycat2 by MyCATApache.

the class PacketUtil method handleErrorPacketPayload.

public static Throwable handleErrorPacketPayload(Buffer payload) {
    ReadView readView = new ReadView(payload);
    // skip ERR packet header
    readView.skipInReading(1);
    int errorCode = (int) readView.readFixInt(2);
    // CLIENT_PROTOCOL_41 capability flag will always be set
    // SQL state marker will always be #
    readView.skipInReading(1);
    String sqlState = readView.readFixString(5);
    String errorMessage = readView.readEOFString();
    return (new SQLException(errorMessage, sqlState, errorCode));
}
Also used : SQLException(java.sql.SQLException) ReadView(io.mycat.vertx.ReadView)

Aggregations

ReadView (io.mycat.vertx.ReadView)8 ColumnDefPacketImpl (io.mycat.beans.mysql.packet.ColumnDefPacketImpl)2 SQLException (java.sql.SQLException)2 SQLUtils (com.alibaba.druid.sql.SQLUtils)1 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)1 SQLDeleteStatement (com.alibaba.druid.sql.ast.statement.SQLDeleteStatement)1 SQLInsertStatement (com.alibaba.druid.sql.ast.statement.SQLInsertStatement)1 SQLSelectStatement (com.alibaba.druid.sql.ast.statement.SQLSelectStatement)1 SQLUpdateStatement (com.alibaba.druid.sql.ast.statement.SQLUpdateStatement)1 MySqlKillStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlKillStatement)1 MySqlASTVisitorAdapter (com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter)1 io.mycat (io.mycat)1 Process (io.mycat.Process)1 MycatErrorCode (io.mycat.beans.mycat.MycatErrorCode)1 MycatRowMetaData (io.mycat.beans.mycat.MycatRowMetaData)1 ResultSetBuilder (io.mycat.beans.mycat.ResultSetBuilder)1 MySQLCommandType (io.mycat.beans.mysql.MySQLCommandType)1 AuthPacket.calcLenencLength (io.mycat.beans.mysql.packet.AuthPacket.calcLenencLength)1