Permalink
Browse files

Add missing packets

  • Loading branch information...
1 parent 6baa627 commit fe2eca4bb808abe2efd0d69e0d2e59b8be4f5aa7 @felixge felixge committed Mar 22, 2012
Showing with 50 additions and 0 deletions.
  1. +21 −0 lib/protocol/packets/EofPacket.js
  2. +29 −0 lib/protocol/packets/RowDataPacket.js
@@ -0,0 +1,21 @@
+/*
+ * see http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol#EOF_Packet
+ */
+
+var Packet = require('./Packet');
+var Util = require('util');
+var Elements = require('../elements');
+
+module.exports = EofPacket;
+Util.inherits(EofPacket, Packet);
+function EofPacket(properties) {
+ properties = properties || {};
+ Packet.call(this, properties);
+
+ // Version 4.1
+ this.push([
+ this.fieldCount = new Elements.UnsignedNumber(1, properties.fieldCount),
+ this.warningCount = new Elements.UnsignedNumber(2, properties.warningCount),
+ this.statusFlags = new Elements.UnsignedNumber(2, properties.statusFlags),
+ ]);
+}
@@ -0,0 +1,29 @@
+/*
+ * see http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol#Field_Packet
+ */
+
+var Packet = require('./Packet');
+var Util = require('util');
+var Elements = require('../elements');
+
+module.exports = RowDataPacket;
+Util.inherits(RowDataPacket, Packet);
+function RowDataPacket(properties) {
+ properties = properties || {};
+ Packet.call(this, properties);
+
+ this.columns = {};
+
+ if (properties.fieldPackets) {
+ this._defineSchemaFromFieldPackets(properties.fieldPackets);
+ }
+}
+
+RowDataPacket.prototype._defineSchemaFromFieldPackets = function(fieldPackets) {
+ var self = this;
+
+ this.push(fieldPackets.map(function(packet) {
+ // @TODO Specify the actual encoding of this!
+ return self.columns[packet.name.value] = new Elements.LengthCodedString('utf8');
+ }));
+};

0 comments on commit fe2eca4

Please sign in to comment.