@@ -101,19 +101,22 @@ class Query extends EventEmitter {
101
101
this . _checkForMultirow ( )
102
102
this . _result . addCommandComplete ( msg )
103
103
// need to sync after each command complete of a prepared statement
104
- this . maybeSync ( connection )
104
+ // if we were using a row count which results in multiple calls to _getRows
105
+ if ( this . rows ) {
106
+ this . maybeSync ( connection )
107
+ }
105
108
}
106
109
107
110
// if a named prepared statement is created with empty query text
108
111
// the backend will send an emptyQuery message but *not* a command complete message
109
112
// execution on the connection will hang until the backend receives a sync message
110
113
handleEmptyQuery ( connection ) {
111
- this . maybeSync ( connection )
114
+ // this.maybeSync(connection)
112
115
}
113
116
114
117
handleError ( err , connection ) {
115
118
// need to sync after error during a prepared statement
116
- this . maybeSync ( connection )
119
+ // this.maybeSync(connection)
117
120
if ( this . _canceledDueToError ) {
118
121
err = this . _canceledDueToError
119
122
this . _canceledDueToError = false
@@ -143,7 +146,7 @@ class Query extends EventEmitter {
143
146
// say "Therefore, an Execute phase is always terminated by the appearance of exactly one of these messages:
144
147
// CommandComplete, EmptyQueryResponse (if the portal was created from an empty query string), ErrorResponse, or PortalSuspended."
145
148
maybeSync ( connection ) {
146
- if ( this . isPreparedStatement && ! this . _hasSentSync ) {
149
+ if ( this . isPreparedStatement ) {
147
150
this . _hasSentSync = true
148
151
connection . sync ( )
149
152
}
@@ -181,7 +184,11 @@ class Query extends EventEmitter {
181
184
portal : this . portal ,
182
185
rows : rows ,
183
186
} )
184
- connection . flush ( )
187
+ if ( ! rows ) {
188
+ this . maybeSync ( connection )
189
+ } else {
190
+ connection . flush ( )
191
+ }
185
192
}
186
193
187
194
// http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
0 commit comments