ResetPacket.java
1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package io.mycat.net.mysql;
import io.mycat.backend.mysql.MySQLMessage;
/**
* <pre>
*
* COM_STMT_RESET resets the data of a prepared statement which was accumulated with COM_STMT_SEND_LONG_DATA commands and closes the cursor if it was opened with COM_STMT_EXECUTE
* The server will send a OK_Packet if the statement could be reset, a ERR_Packet if not.
*
* COM_STMT_RESET:
* COM_STMT_RESET
* direction: client -> server
* response: OK or ERR
* payload:
* 1 [1a] COM_STMT_RESET
* 4 statement-id
*
* </pre>
*
* @author CrazyPig
* @since 2016-09-08
*
*/
public class ResetPacket extends MySQLPacket {
private static final byte PACKET_FALG = (byte) 26;
private long pstmtId;
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();
}
@Override
public int calcPacketSize() {
return 1 + 4;
}
@Override
protected String getPacketInfo() {
return "MySQL Reset Packet";
}
public long getPstmtId() {
return pstmtId;
}
}