We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 862877a commit 05a1082Copy full SHA for 05a1082
README.md
@@ -202,6 +202,7 @@ function.
202
```ocaml
203
type value =
204
[ `Int of int
205
+ | `Int64 of Int64.t
206
| `Float of float
207
| `String of string
208
| `Bytes of bytes
@@ -218,6 +219,7 @@ provided to extract the OCaml types directly from a field:
218
219
220
221
val int : Field.t -> int
222
+val int64 : Field.t -> Int64.t
223
val float : Field.t -> float
224
val string : Field.t -> string
225
val bytes : Field.t -> bytes
@@ -231,6 +233,7 @@ For nullable fields, the following analogous functions are also provided:
231
233
232
234
235
val int_opt : Field.t -> int option
236
+val int64_opt : Field.t -> Int64.t option
237
val float_opt : Field.t -> float option
238
val string_opt : Field.t -> string option
239
val bytes_opt : Field.t -> bytes option
examples/async/nonblocking_async_example.ml
@@ -66,6 +66,7 @@ let print_row row =
66
printf "%20s " name;
67
match M.Field.value field with
68
| `Int i -> printf "%d\n%!" i
69
+ | `Int64 i -> printf "%Ld\n%!" i
70
| `Float x -> printf "%f\n%!" x
71
| `String s -> printf "%s\n%!" s
72
| `Bytes b -> printf "%s\n%!" (Caml_bytes.to_string b)
examples/blocking/blocking_example.ml
@@ -17,6 +17,7 @@ let print_row row =
17
18
19
20
21
22
23
| `Bytes b -> printf "%s\n%!" (Bytes.to_string b)
examples/lwt/nonblocking_lwt_example.ml
@@ -52,6 +52,7 @@ let print_row row =
52
Lwt_io.printf "%20s " name >>= fun () ->
53
54
| `Int i -> Lwt_io.printf "%d\n%!" i
55
+ | `Int64 i -> Lwt_io.printf "%Ld\n%!" i
56
| `Float x -> Lwt_io.printf "%f\n%!" x
57
| `String s -> Lwt_io.printf "%s\n%!" s
58
| `Bytes b -> Lwt_io.printf "%s\n%!" (Bytes.to_string b)
examples/nonblocking/nonblocking_stress_test.ml
@@ -69,6 +69,7 @@ module Make (W : Mariadb.Nonblocking.Wait) = struct
let string_of_value = function
| `Null -> "NULL"
| `Int i -> sprintf "(%d : int)" i
+ | `Int64 i -> sprintf "(%Ld : int64)" i
73
| `Float x -> sprintf "(%.8g : float)" x
74
| `String s -> sprintf "(%S : string)" s
75
| `Bytes s -> sprintf "(%S : bytes)" (Bytes.to_string s)
@@ -89,7 +90,10 @@ module Make (W : Mariadb.Nonblocking.Wait) = struct
89
90
| `Null, _ | _, `Null -> false
91
| `Int i, `Int i' -> i = i'
92
| `Int i, `Float x | `Float x, `Int i -> float_of_int i = x
93
+ | `Int64 i, `Int x | `Int x, `Int64 i -> Int64.(equal i (of_int x))
94
+ | `Int64 i, `Float x | `Float x, `Int64 i -> Int64.to_float i = x
95
| `Int _, _ | _, `Int _ -> false
96
+ | `Int64 _, _ | _, `Int64 _ -> false
97
| `Float x, `Float x' -> equal_float x x'
98
| `Float _, _ | _, `Float _ -> false
99
| `String s, `String s' -> s = s'
examples/select/nonblocking_select_example.ml
@@ -55,6 +55,7 @@ let print_row row =
59
60
61
lib/bind.ml
@@ -124,6 +124,15 @@ let int ?(unsigned = false) b param ~at =
124
~unsigned:(if unsigned then yes else no)
125
~at
126
127
+let int64 ?(unsigned = false) b param ~at =
128
+ let p = allocate int64_t param in
129
+ bind b
130
+ ~buffer:(coerce (ptr int64_t) (ptr void) p)
131
+ ~size:(sizeof int64_t)
132
+ ~mysql_type:T.Type.long_long
133
+ ~unsigned:(if unsigned then yes else no)
134
+ ~at
135
+
136
let float b param ~at =
137
let p = allocate float param in
138
bind b
lib/common.ml
@@ -339,6 +339,7 @@ module Stmt = struct
339
match arg with
340
| `Null -> Bind.null b ~at
341
| `Int i -> Bind.int b i ~at
342
+ | `Int64 i -> Bind.int64 b i ~at
343
| `Float x -> Bind.float b x ~at
344
| `String s -> Bind.string b s ~at
345
| `Bytes s -> Bind.blob b s ~at
lib/field.ml
@@ -5,6 +5,7 @@ module T = Ffi_bindings.Types(Ffi_generated_types)
5
6
[ `Null
7
| `Int of int
8
9
10
11
@@ -81,8 +82,8 @@ let convert field typ unsigned =
81
82
| `Short, false -> `Int (UInt.to_int (cast_to uint field))
83
| (`Int24 | `Long), true -> `Int (UInt32.to_int (cast_to uint32_t field))
84
| (`Int24 | `Long), false -> `Int (Int32.to_int (cast_to int32_t field))
- | `Long_long, true -> `Int (UInt64.to_int (cast_to uint64_t field))
85
- | `Long_long, false -> `Int (Int64.to_int (cast_to int64_t field))
+ | `Long_long, true -> `Int64 (UInt64.to_int64 (cast_to uint64_t field))
86
+ | `Long_long, false -> `Int64 (cast_to int64_t field)
87
| `Float, _ -> `Float (cast_to float field)
88
| `Double, _ -> `Float (cast_to double field)
| #to_string, _ -> `String (Bytes.to_string (to_bytes field))
@@ -104,6 +105,11 @@ let int field =
104
105
| `Int i -> i
106
| _ -> err field ~info:"an integer"
107
108
+let int64 field =
109
+ match value field with
110
+ | `Int64 i -> i
111
+ | _ -> err field ~info:"an 64-bit integer"
112
113
let float field =
114
match value field with
115
| `Float x -> x
@@ -130,6 +136,12 @@ let int_opt field =
| `Null -> None
| _ -> err field ~info:"a nullable integer"
139
+let int64_opt field =
140
141
+ | `Int64 i -> Some i
142
+ | `Null -> None
143
+ | _ -> err field ~info:"a nullable 64-bit integer"
144
145
let float_opt field =
146
147
| `Float x -> Some x
lib/mariadb.ml
@@ -29,6 +29,7 @@ module type S = sig
29
30
31
32
+ | `Int64 of int64
33
34
35
@@ -41,12 +42,14 @@ module type S = sig
41
42
val can_be_null : t -> bool
43
44
val int : t -> int
45
+ val int64 : t -> Int64.t
46
val float : t -> float
47
val string : t -> string
48
val bytes : t -> bytes
49
val time : t -> Time.t
50
51
val int_opt : t -> int option
+ val int64_opt : t -> Int64.t option
val float_opt : t -> float option
val string_opt : t -> string option
val bytes_opt : t -> bytes option
0 commit comments