diff --git a/lib/packets/resultset_header.js b/lib/packets/resultset_header.js index e0f77071ae..95ff56a534 100644 --- a/lib/packets/resultset_header.js +++ b/lib/packets/resultset_header.js @@ -15,6 +15,7 @@ class ResultSetHeader { const encoding = connection.serverEncoding; const flags = connection._handshakePacket.capabilityFlags; const isSet = function(flag) { + console.log('isSet?', flag, ClientConstants[flag]); return flags & ClientConstants[flag]; }; if (packet.buffer[packet.offset] !== 0) { @@ -36,7 +37,9 @@ class ResultSetHeader { } let stateChanges = null; if (isSet('SESSION_TRACK') && packet.offset < packet.end) { + const sessionInfoTypes = require('../constants/session_track.js'); this.info = packet.readLengthCodedString(encoding); + if (this.serverStatus && ServerSatusFlags.SERVER_SESSION_STATE_CHANGED) { // session change info record - see // https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html#cs-sect-packet-ok-sessioninfo @@ -48,7 +51,6 @@ class ResultSetHeader { stateChanges = { systemVariables: {}, schema: null, - // gtids: {}, trackStateChange: null }; } @@ -56,23 +58,23 @@ class ResultSetHeader { type = packet.readInt8(); len = packet.readLengthCodedNumber(); stateEnd = packet.offset + len; - key = packet.readLengthCodedString(encoding); - if (type === 0) { + if (type === sessionInfoTypes.SYSTEM_VARIABLES) { + key = packet.readLengthCodedString(encoding); const val = packet.readLengthCodedString(encoding); stateChanges.systemVariables[key] = val; if (key === 'character_set_client') { const charsetNumber = EncodingToCharset[val]; connection.config.charsetNumber = charsetNumber; } - } else if (type === 1) { - // TODO double check it's supposed to be the only value, not a list. + } else if (type === sessionInfoTypes.SCHEMA) { + key = packet.readLengthCodedString(encoding); stateChanges.schema = key; - } else if (type === 2) { + } else if (type === sessionInfoTypes.STATE_CHANGE) { stateChanges.trackStateChange = packet.readLengthCodedString( encoding ); } else { - // GTIDs (type == 3) or unknown type - just skip for now + // unsupported session track type. For now just ignore } packet.offset = stateEnd; }