@@ -132,9 +132,9 @@ pub struct LargeObject<'a> {
132132impl < ' a > fmt:: Debug for LargeObject < ' a > {
133133 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
134134 fmt. debug_struct ( "LargeObject" )
135- . field ( "fd" , & self . fd )
136- . field ( "transaction" , & self . trans )
137- . finish ( )
135+ . field ( "fd" , & self . fd )
136+ . field ( "transaction" , & self . trans )
137+ . finish ( )
138138 }
139139}
140140
@@ -159,13 +159,12 @@ impl<'a> LargeObject<'a> {
159159 let stmt = try!( self . trans . prepare_cached ( "SELECT pg_catalog.lo_truncate64($1, $2)" ) ) ;
160160 stmt. execute ( & [ & self . fd , & len] ) . map ( |_| ( ) )
161161 } else {
162- let len: i32 = if len <= i32:: max_value ( ) as i64 {
162+ let len = if len <= i32:: max_value ( ) as i64 {
163163 len as i32
164164 } else {
165- return Err ( Error :: IoError ( io:: Error :: new (
166- io:: ErrorKind :: InvalidInput ,
167- "The database does not support objects larger than 2GB"
168- ) ) )
165+ return Err ( Error :: IoError ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
166+ "The database does not support objects \
167+ larger than 2GB") ) ) ;
169168 } ;
170169 let stmt = try!( self . trans . prepare_cached ( "SELECT pg_catalog.lo_truncate($1, $2)" ) ) ;
171170 stmt. execute ( & [ & self . fd , & len] ) . map ( |_| ( ) )
@@ -231,8 +230,11 @@ impl<'a> io::Seek for LargeObject<'a> {
231230 } ;
232231
233232 if self . has_64 {
234- let stmt = try_io ! ( self . trans. prepare_cached( "SELECT pg_catalog.lo_lseek64($1, $2, $3)" ) ) ;
235- Ok ( try_io ! ( stmt. query( & [ & self . fd, & pos, & kind] ) ) . iter ( ) . next ( ) . unwrap ( ) . get :: < _ , i64 > ( 0 ) as u64 )
233+ let stmt = try_io ! ( self . trans
234+ . prepare_cached( "SELECT pg_catalog.lo_lseek64($1, $2, $3)" ) ) ;
235+ let rows = try_io ! ( stmt. query( & [ & self . fd, & pos, & kind] ) ) ;
236+ let pos: i64 = rows. iter ( ) . next ( ) . unwrap ( ) . get ( 0 ) ;
237+ Ok ( pos as u64 )
236238 } else {
237239 let pos = if pos <= i32:: max_value ( ) as i64 {
238240 pos as i32
@@ -241,7 +243,9 @@ impl<'a> io::Seek for LargeObject<'a> {
241243 "cannot seek more than 2^31 bytes" ) ) ;
242244 } ;
243245 let stmt = try_io ! ( self . trans. prepare_cached( "SELECT pg_catalog.lo_lseek($1, $2, $3)" ) ) ;
244- Ok ( try_io ! ( stmt. query( & [ & self . fd, & pos, & kind] ) ) . iter ( ) . next ( ) . unwrap ( ) . get :: < _ , i32 > ( 0 ) as u64 )
246+ let rows = try_io ! ( stmt. query( & [ & self . fd, & pos, & kind] ) ) ;
247+ let pos: i64 = rows. iter ( ) . next ( ) . unwrap ( ) . get ( 0 ) ;
248+ Ok ( pos as u64 )
245249 }
246250 }
247251}
0 commit comments