You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
module.exports = OkPacket;
|
|
function OkPacket() {
|
|
this.fieldCount = undefined;
|
|
this.affectedRows = undefined;
|
|
this.insertId = undefined;
|
|
this.serverStatus = undefined;
|
|
this.warningCount = undefined;
|
|
this.message = undefined;
|
|
}
|
|
|
|
OkPacket.prototype.parse = function(parser) {
|
|
this.fieldCount = parser.parseUnsignedNumber(1);
|
|
this.affectedRows = parser.parseLengthCodedNumber();
|
|
this.insertId = parser.parseLengthCodedNumber();
|
|
this.serverStatus = parser.parseUnsignedNumber(2);
|
|
this.warningCount = parser.parseUnsignedNumber(2);
|
|
this.message = parser.parsePacketTerminatedString();
|
|
this.changedRows = 0;
|
|
|
|
var m = this.message.match(/\schanged:\s*(\d+)/i);
|
|
|
|
if (m !== null) {
|
|
this.changedRows = parseInt(m[1], 10);
|
|
}
|
|
};
|
|
|
|
OkPacket.prototype.write = function(writer) {
|
|
writer.writeUnsignedNumber(1, 0x00);
|
|
writer.writeLengthCodedNumber(this.affectedRows || 0);
|
|
writer.writeLengthCodedNumber(this.insertId || 0);
|
|
writer.writeUnsignedNumber(2, this.serverStatus || 0);
|
|
writer.writeUnsignedNumber(2, this.warningCount || 0);
|
|
writer.writeString(this.message);
|
|
};
|