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;
}
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);
}
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));
}
Aggregations