@@ -665,6 +665,50 @@ impl InnerConnection {
665
665
Ok ( ( param_types, columns) )
666
666
}
667
667
668
+ fn read_rows ( & mut self , buf : & mut VecDeque < Vec < Option < Vec < u8 > > > > ) -> Result < bool > {
669
+ let more_rows;
670
+ loop {
671
+ match try!( self . read_message ( ) ) {
672
+ EmptyQueryResponse | CommandComplete { .. } => {
673
+ more_rows = false ;
674
+ break ;
675
+ }
676
+ PortalSuspended => {
677
+ more_rows = true ;
678
+ break ;
679
+ }
680
+ DataRow { row } => buf. push_back ( row) ,
681
+ ErrorResponse { fields } => {
682
+ try!( self . wait_for_ready ( ) ) ;
683
+ return DbError :: new ( fields) ;
684
+ }
685
+ CopyInResponse { .. } => {
686
+ try!( self . write_messages ( & [ CopyFail {
687
+ message : "COPY queries cannot be directly executed" ,
688
+ } ,
689
+ Sync ] ) ) ;
690
+ }
691
+ CopyOutResponse { .. } => {
692
+ loop {
693
+ match try!( self . read_message ( ) ) {
694
+ ReadyForQuery { .. } => break ,
695
+ _ => { }
696
+ }
697
+ }
698
+ return Err ( Error :: Io ( std_io:: Error :: new ( std_io:: ErrorKind :: InvalidInput ,
699
+ "COPY queries cannot be directly \
700
+ executed") ) ) ;
701
+ }
702
+ _ => {
703
+ self . desynchronized = true ;
704
+ return Err ( Error :: Io ( bad_response ( ) ) ) ;
705
+ }
706
+ }
707
+ }
708
+ try!( self . wait_for_ready ( ) ) ;
709
+ Ok ( more_rows)
710
+ }
711
+
668
712
fn make_stmt_name ( & mut self ) -> String {
669
713
let stmt_name = format ! ( "s{}" , self . next_stmt_id) ;
670
714
self . next_stmt_id += 1 ;
@@ -1358,50 +1402,6 @@ impl<'conn> Transaction<'conn> {
1358
1402
}
1359
1403
}
1360
1404
1361
- fn read_rows ( conn : & mut InnerConnection , buf : & mut VecDeque < Vec < Option < Vec < u8 > > > > ) -> Result < bool > {
1362
- let more_rows;
1363
- loop {
1364
- match try!( conn. read_message ( ) ) {
1365
- EmptyQueryResponse | CommandComplete { .. } => {
1366
- more_rows = false ;
1367
- break ;
1368
- }
1369
- PortalSuspended => {
1370
- more_rows = true ;
1371
- break ;
1372
- }
1373
- DataRow { row } => buf. push_back ( row) ,
1374
- ErrorResponse { fields } => {
1375
- try!( conn. wait_for_ready ( ) ) ;
1376
- return DbError :: new ( fields) ;
1377
- }
1378
- CopyInResponse { .. } => {
1379
- try!( conn. write_messages ( & [ CopyFail {
1380
- message : "COPY queries cannot be directly executed" ,
1381
- } ,
1382
- Sync ] ) ) ;
1383
- }
1384
- CopyOutResponse { .. } => {
1385
- loop {
1386
- match try!( conn. read_message ( ) ) {
1387
- ReadyForQuery { .. } => break ,
1388
- _ => { }
1389
- }
1390
- }
1391
- return Err ( Error :: Io ( std_io:: Error :: new ( std_io:: ErrorKind :: InvalidInput ,
1392
- "COPY queries cannot be directly \
1393
- executed") ) ) ;
1394
- }
1395
- _ => {
1396
- conn. desynchronized = true ;
1397
- return Err ( Error :: Io ( bad_response ( ) ) ) ;
1398
- }
1399
- }
1400
- }
1401
- try!( conn. wait_for_ready ( ) ) ;
1402
- Ok ( more_rows)
1403
- }
1404
-
1405
1405
/// A trait allowing abstraction over connections and transactions
1406
1406
pub trait GenericConnection {
1407
1407
/// Like `Connection::execute`.
0 commit comments