@@ -80,6 +80,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
80
80
, incoming = Buffer . alloc ( 0 )
81
81
, needsTypes = options . fetch_types
82
82
, backendParameters = { }
83
+ , portalId = Math . random ( ) . toString ( 36 ) . slice ( 2 )
84
+ , portalCount = 1
83
85
, statements = { }
84
86
, statementId = Math . random ( ) . toString ( 36 ) . slice ( 2 )
85
87
, statementCount = 1
@@ -168,6 +170,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
168
170
&& ! q . describeFirst
169
171
&& sent . length < max_pipeline
170
172
&& ( ! q . options . onexecute || q . options . onexecute ( connection ) )
173
+ && ! q . portal
171
174
} catch ( error ) {
172
175
sent . length === 0 && write ( Sync )
173
176
errored ( error )
@@ -199,9 +202,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
199
202
200
203
function prepared ( q ) {
201
204
return Buffer . concat ( [
202
- Bind ( q . parameters , q . statement . types , q . statement . name , q . cursorName ) ,
203
- q . cursorFn
204
- ? Execute ( '' , q . cursorRows )
205
+ Bind ( q . parameters , q . statement . types , q . statement . name , q . portal ) ,
206
+ q . portal
207
+ ? Execute ( q . portal , q . cursorRows )
205
208
: ExecuteUnnamed
206
209
] )
207
210
}
@@ -222,6 +225,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
222
225
223
226
! q . tagged && q . args . forEach ( x => handleValue ( x , parameters , types , options ) )
224
227
228
+ q . cursorRows && ( q . portal = 'P' + portalId + portalCount ++ )
225
229
q . prepare = options . prepare && ( 'prepare' in q . options ? q . options . prepare : true )
226
230
q . string = string
227
231
q . signature = q . prepare && types + string
@@ -794,7 +798,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
794
798
rows = 0
795
799
x === CLOSE
796
800
? write ( Close ( query . portal ) )
797
- : ( result = new Result ( ) , write ( Execute ( '' , query . cursorRows ) ) )
801
+ : ( result = new Result ( ) , write ( Execute ( query . portal , query . cursorRows ) ) )
798
802
} catch ( err ) {
799
803
write ( Sync )
800
804
query . reject ( err )
0 commit comments