@@ -979,22 +979,14 @@ impl<'conn> Transaction<'conn> {
979979 }
980980
981981 /// Like `Connection::prepare`.
982- pub fn prepare < ' a > ( & ' a self , query : & str ) -> Result < Statement < ' a > > {
983- let mut conn = self . conn . conn . borrow_mut ( ) ;
984- if conn. trans_depth != self . depth {
985- return Err ( Error :: WrongTransaction ) ;
986- }
987- conn. prepare ( query, self . conn )
982+ pub fn prepare ( & self , query : & str ) -> Result < Statement < ' conn > > {
983+ self . conn . conn . borrow_mut ( ) . prepare ( query, self . conn )
988984 }
989985
990986 /// Like `Connection::prepare_copy_in`.
991- pub fn prepare_copy_in < ' a > ( & ' a self , table : & str , cols : & [ & str ] )
992- -> Result < CopyInStatement < ' a > > {
993- let mut conn = self . conn . conn . borrow_mut ( ) ;
994- if conn. trans_depth != self . depth {
995- return Err ( Error :: WrongTransaction ) ;
996- }
997- conn. prepare_copy_in ( table, cols, self . conn )
987+ pub fn prepare_copy_in ( & self , table : & str , cols : & [ & str ] )
988+ -> Result < CopyInStatement < ' conn > > {
989+ self . conn . conn . borrow_mut ( ) . prepare_copy_in ( table, cols, self . conn )
998990 }
999991
1000992 /// Like `Connection::execute`.
@@ -1004,11 +996,7 @@ impl<'conn> Transaction<'conn> {
1004996
1005997 /// Like `Connection::batch_execute`.
1006998 pub fn batch_execute ( & self , query : & str ) -> Result < ( ) > {
1007- let mut conn = self . conn . conn . borrow_mut ( ) ;
1008- if conn. trans_depth != self . depth {
1009- return Err ( Error :: WrongTransaction ) ;
1010- }
1011- conn. quick_query ( query) . map ( |_| ( ) )
999+ self . conn . conn . borrow_mut ( ) . quick_query ( query) . map ( |_| ( ) )
10121000 }
10131001
10141002 /// Like `Connection::transaction`.
@@ -1043,7 +1031,12 @@ impl<'conn> Transaction<'conn> {
10431031 if self . conn as * const _ != stmt. conn as * const _ {
10441032 return Err ( Error :: WrongConnection ) ;
10451033 }
1046- check_desync ! ( self . conn) ;
1034+ let conn = self . conn . conn . borrow ( ) ;
1035+ check_desync ! ( conn) ;
1036+ if conn. trans_depth != self . depth {
1037+ return Err ( Error :: WrongTransaction ) ;
1038+ }
1039+ drop ( conn) ;
10471040 stmt. lazy_query ( row_limit, params) . map ( |result| {
10481041 LazyRows {
10491042 _trans : self ,
0 commit comments