@@ -777,20 +777,24 @@ object (self)
777
777
method status = wrap_conn Stub. connection_status
778
778
method error_message = wrap_conn Stub. error_message
779
779
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
792
797
major, minor, revision
793
- )
794
798
795
799
796
800
(* Commands and Queries *)
@@ -896,30 +900,28 @@ object (self)
896
900
| - 1 -> if Stub. endcopy conn <> 0 then signal_error conn else EndOfData
897
901
| 0 -> NoData
898
902
| 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
900
905
| _ -> assert false )
901
906
902
907
method putline buf =
903
908
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)
907
911
908
912
method putnbytes ?(pos = 0 ) ?len buf =
909
913
let buf_len = String. length buf in
910
914
let len = match len with Some len -> len | None -> buf_len - pos in
911
915
if len < 0 || pos < 0 || pos + len > buf_len then
912
916
invalid_arg " Postgresql.connection#putnbytes" ;
913
917
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)
917
920
918
921
method endcopy =
919
922
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)
923
925
924
926
925
927
(* High level *)
@@ -978,8 +980,7 @@ object (self)
978
980
match Stub. flush conn with
979
981
| 0 -> Successful
980
982
| 1 -> Data_left_to_send
981
- | _ -> signal_error conn
982
- )
983
+ | _ -> signal_error conn)
983
984
984
985
method socket =
985
986
wrap_conn (fun conn ->
0 commit comments