Issue #54: We should probably delay the _flush cb() to CommandComplete

performance-tune-copy-to
jeromew 8 years ago
parent 7003f6070f
commit b2e108571e

@ -43,7 +43,7 @@ CopyStreamQuery.prototype._flush = function(cb) {
var Int32Len = 4; var Int32Len = 4;
var finBuffer = Buffer([code.CopyDone, 0, 0, 0, Int32Len]) var finBuffer = Buffer([code.CopyDone, 0, 0, 0, Int32Len])
this.push(finBuffer) this.push(finBuffer)
cb() this.cb_flush = cb
} }
CopyStreamQuery.prototype.handleError = function(e) { CopyStreamQuery.prototype.handleError = function(e) {
@ -62,6 +62,10 @@ CopyStreamQuery.prototype.handleCommandComplete = function(msg) {
this.rowCount = parseInt(match[1], 10) this.rowCount = parseInt(match[1], 10)
} }
// we delay the _flush cb so that the 'end' event is
// triggered after CommandComplete
this.cb_flush()
// unpipe from connection // unpipe from connection
this.unpipe(this.connection) this.unpipe(this.connection)
this.connection = null this.connection = null

Loading…
Cancel
Save