Skip to content

Commit e68b754

Browse files
committed
Remove queued query
1 parent 3430c51 commit e68b754

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/protocol/Protocol.js

+8
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,14 @@ Protocol.prototype._dequeue = function(sequence) {
336336
return;
337337
}
338338

339+
if (sequence !== this._queue[0]) {
340+
var idx = this._queue.indexOf(sequence);
341+
if (idx > 0) {
342+
this._queue.splice(idx, 1);
343+
}
344+
return;
345+
}
346+
339347
this._queue.shift();
340348

341349
var sequence = this._queue[0];

lib/protocol/sequences/Query.js

+17
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,29 @@ function Query(options, callback) {
2424
this._fields = [];
2525
this._index = 0;
2626
this._loadError = null;
27+
this._started = false;
2728
}
2829

2930
Query.prototype.start = function() {
31+
this._started = true;
3032
this.emit('packet', new Packets.ComQueryPacket(this.sql));
3133
};
3234

35+
Query.prototype.started = function() {
36+
return this._started;
37+
};
38+
39+
Query.prototype.ended = function() {
40+
return this._ended;
41+
};
42+
43+
Query.prototype.dequeue = function() {
44+
if (this._started) {
45+
throw new Error('Query already started.');
46+
}
47+
this.end();
48+
};
49+
3350
Query.prototype.determinePacket = function determinePacket(byte, parser) {
3451
var resultSet = this._resultSet;
3552

0 commit comments

Comments
 (0)