Do not send close after readyForQuery

Close is used to release a named portal (which isn't used by pg-cursor) or when you're early-terminating a cursor on the unnamed portal. Sending 'close' on an connection which has already sent 'readyForQuery' results in the connection responding with a _second_ 'readyForQuery' which causes a lot of issues within node-postgres as 'readyForQuery' is the signal to indicate the client has gone back into the idle state.
This commit is contained in:
Brian M. Carlson 2017-08-04 17:40:52 -05:00
parent 6072bcea8e
commit 620ddc0ded

View File

@ -145,6 +145,9 @@ Cursor.prototype.end = function(cb) {
}
Cursor.prototype.close = function(cb) {
if (this.state == 'done') {
return setImmediate(cb)
}
this.connection.close({type: 'P'})
this.connection.sync()
this.state = 'done'