Skip to content

Commit 9311e2c

Browse files
committed
Transaction status is handled by readyForQuery message. Please, share!
readyForQuery can receive one of this state: /* * getReadyForQuery - process ReadyForQuery message */ static int getReadyForQuery(PGconn *conn) { charxact_status; if (pqGetc(&xact_status, conn) ) return EOF; switch (xact_status) { case 'I': conn->xactStatus = PQTRANS_IDLE; break; case 'T': conn->xactStatus = PQTRANS_INTRANS; break; case 'E': conn->xactStatus = PQTRANS_INERROR; break; default: conn->xactStatus = PQTRANS_UNKNOWN; break; } return 0; }
1 parent 9870c86 commit 9311e2c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/client.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ Client.prototype.connect = function (callback) {
138138

139139
// hook up query handling events to connection
140140
// after the connection initially becomes ready for queries
141-
con.once('readyForQuery', function () {
141+
con.once('readyForQuery', function (msg) {
142+
self._transactionStatus = msg.status
142143
self._connecting = false
143144
self._connected = true
144145
self._attachListeners(con)
@@ -155,8 +156,9 @@ Client.prototype.connect = function (callback) {
155156
self.emit('connect')
156157
})
157158

158-
con.on('readyForQuery', function () {
159+
con.on('readyForQuery', function (msg) {
159160
var activeQuery = self.activeQuery
161+
self._transactionStatus = msg.status
160162
self.activeQuery = null
161163
self.readyForQuery = true
162164
if (activeQuery) {

0 commit comments

Comments
 (0)