@@ -777,20 +777,24 @@ object (self)
777777 method status = wrap_conn Stub. connection_status
778778 method error_message = wrap_conn Stub. error_message
779779 method backend_pid = wrap_conn Stub. backend_pid
780- method server_version = wrap_conn (fun conn ->
781- let v = Stub. server_version conn in
782- if v = 0 then begin
783- let message = if Stub. connection_status conn = Bad
784- then " server_version failed because the connection was bad"
785- else " server_version failed for an unknown reason"
786- in
787- raise (Error (Connection_failure message))
788- end ;
789- let revision = v mod 100 in
790- let minor = (v / 100 ) mod 100 in
791- let major = v / (100 * 100 ) in
780+
781+ method server_version =
782+ let version =
783+ wrap_conn (fun conn ->
784+ let version = Stub. server_version conn in
785+ if version <> 0 then version
786+ else
787+ let msg =
788+ if Stub. connection_status conn = Bad
789+ then " server_version failed because the connection was bad"
790+ else " server_version failed for an unknown reason"
791+ in
792+ raise (Error (Connection_failure msg)))
793+ in
794+ let major = version / (100 * 100 ) in
795+ let minor = (version / 100 ) mod 100 in
796+ let revision = version mod 100 in
792797 major, minor, revision
793- )
794798
795799
796800 (* Commands and Queries *)
@@ -896,30 +900,28 @@ object (self)
896900 | - 1 -> if Stub. endcopy conn <> 0 then signal_error conn else EndOfData
897901 | 0 -> NoData
898902 | n when n > 0 ->
899- if Bytes. get buf (pos + n - 1 ) = '\n' then DataRead n else PartDataRead n
903+ if Bytes. get buf (pos + n - 1 ) = '\n' then DataRead n
904+ else PartDataRead n
900905 | _ -> assert false )
901906
902907 method putline buf =
903908 wrap_conn (fun conn ->
904- if (Stub. putline conn buf <> 0 ) && not (Stub. is_nonblocking conn) then
905- signal_error conn
906- )
909+ if Stub. putline conn buf <> 0 && not (Stub. is_nonblocking conn) then
910+ signal_error conn)
907911
908912 method putnbytes ?(pos = 0 ) ?len buf =
909913 let buf_len = String. length buf in
910914 let len = match len with Some len -> len | None -> buf_len - pos in
911915 if len < 0 || pos < 0 || pos + len > buf_len then
912916 invalid_arg " Postgresql.connection#putnbytes" ;
913917 wrap_conn (fun conn ->
914- if (Stub. putnbytes conn buf pos len <> 0 ) && not (Stub. is_nonblocking conn) then
915- signal_error conn
916- )
918+ if Stub. putnbytes conn buf pos len <> 0 && not (Stub. is_nonblocking conn)
919+ then signal_error conn)
917920
918921 method endcopy =
919922 wrap_conn (fun conn ->
920- if (Stub. endcopy conn <> 0 ) && not (Stub. is_nonblocking conn) then
921- signal_error conn
922- )
923+ if Stub. endcopy conn <> 0 && not (Stub. is_nonblocking conn) then
924+ signal_error conn)
923925
924926
925927 (* High level *)
@@ -978,8 +980,7 @@ object (self)
978980 match Stub. flush conn with
979981 | 0 -> Successful
980982 | 1 -> Data_left_to_send
981- | _ -> signal_error conn
982- )
983+ | _ -> signal_error conn)
983984
984985 method socket =
985986 wrap_conn (fun conn ->
0 commit comments