53
53
} else {
54
54
encode ( client, & statement, params) ?
55
55
} ;
56
- let ( statement, responses) = start ( client, buf) . await ?;
56
+
57
+ let responses = start ( client, buf) . await ?;
58
+
57
59
Ok ( RowStream {
58
- statement,
60
+ statement : None ,
59
61
responses,
60
62
rows_affected : None ,
61
63
command_tag : None ,
@@ -116,11 +118,11 @@ where
116
118
} ) ?;
117
119
118
120
// now read the responses
119
- let ( statement , responses) = start ( client, buf) . await ?;
121
+ let responses = start ( client, buf) . await ?;
120
122
121
123
Ok ( RowStream {
122
124
parameter_description : None ,
123
- statement,
125
+ statement : None ,
124
126
responses,
125
127
command_tag : None ,
126
128
status : None ,
@@ -189,7 +191,8 @@ where
189
191
} else {
190
192
encode ( client, & statement, params) ?
191
193
} ;
192
- let ( _statement, mut responses) = start ( client, buf) . await ?;
194
+
195
+ let mut responses = start ( client, buf) . await ?;
193
196
194
197
let mut rows = 0 ;
195
198
loop {
@@ -205,27 +208,13 @@ where
205
208
}
206
209
}
207
210
208
- async fn start ( client : & InnerClient , buf : Bytes ) -> Result < ( Option < Statement > , Responses ) , Error > {
209
- let mut parameter_description: Option < ParameterDescriptionBody > = None ;
210
- let mut statement = None ;
211
+ async fn start ( client : & InnerClient , buf : Bytes ) -> Result < Responses , Error > {
211
212
let mut responses = client. send ( RequestMessages :: Single ( FrontendMessage :: Raw ( buf) ) ) ?;
212
213
213
214
loop {
214
215
match responses. next ( ) . await ? {
215
216
Message :: ParseComplete => { }
216
- Message :: BindComplete => return Ok ( ( statement, responses) ) ,
217
- Message :: ParameterDescription ( body) => {
218
- parameter_description = Some ( body) ; // tooo-o-ooo-o loooove
219
- }
220
- Message :: NoData => {
221
- statement = Some ( make_statement ( parameter_description. take ( ) . unwrap ( ) , None ) ?) ;
222
- }
223
- Message :: RowDescription ( body) => {
224
- statement = Some ( make_statement (
225
- parameter_description. take ( ) . unwrap ( ) ,
226
- Some ( body) ,
227
- ) ?) ;
228
- }
217
+ Message :: BindComplete => return Ok ( responses) ,
229
218
m => return Err ( Error :: unexpected_message ( m) ) ,
230
219
}
231
220
}
@@ -360,6 +349,21 @@ impl Stream for RowStream {
360
349
* this. command_tag = Some ( tag. to_string ( ) ) ;
361
350
}
362
351
}
352
+ Message :: ParameterDescription ( body) => {
353
+ * this. parameter_description = Some ( body) ;
354
+ }
355
+ Message :: NoData => {
356
+ * this. statement = Some ( make_statement (
357
+ this. parameter_description . take ( ) . unwrap ( ) ,
358
+ None ,
359
+ ) ?) ;
360
+ }
361
+ Message :: RowDescription ( body) => {
362
+ * this. statement = Some ( make_statement (
363
+ this. parameter_description . take ( ) . unwrap ( ) ,
364
+ Some ( body) ,
365
+ ) ?) ;
366
+ }
363
367
Message :: EmptyQueryResponse | Message :: PortalSuspended => { }
364
368
Message :: ReadyForQuery ( status) => {
365
369
* this. status = Some ( status. status ( ) ) ;
0 commit comments