Skip to content

Commit

Permalink
Remove queued query
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmacko47 committed Apr 18, 2021
1 parent 3430c51 commit a93ef9d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/protocol/Protocol.js
Expand Up @@ -336,6 +336,14 @@ Protocol.prototype._dequeue = function(sequence) {
return;
}

if (sequence !== this._queue[0]) {
var idx = this._queue.indexOf(sequence);
if (idx > 0) {
this._queue.splice(idx, 1)
}
return;
}

this._queue.shift();

var sequence = this._queue[0];
Expand Down
17 changes: 17 additions & 0 deletions lib/protocol/sequences/Query.js
Expand Up @@ -24,12 +24,29 @@ function Query(options, callback) {
this._fields = [];
this._index = 0;
this._loadError = null;
this._started = false;
}

Query.prototype.start = function() {
this._started = true;
this.emit('packet', new Packets.ComQueryPacket(this.sql));
};

Query.prototype.started = function() {
return this._started;
}

Query.prototype.ended = function() {
return this._ended;
}

Query.prototype.dequeue = function() {
if (this._started) {
throw new Error('Query already started.');
}
this.end()
}

Query.prototype.determinePacket = function determinePacket(byte, parser) {
var resultSet = this._resultSet;

Expand Down

0 comments on commit a93ef9d

Please sign in to comment.