changed CHANGELOG.md
 
@@ -1,5 +1,10 @@
1
1
# Changelog
2
2
3
+ ## v0.6.3 (2022-09-22)
4
+
5
+ * Print query statement in error log
6
+ * Add count to table reader metadata
7
+
3
8
## v0.6.2 (2021-04-27)
4
9
5
10
* Implement the Table.Reader protocol for query result
changed hex_metadata.config
 
@@ -42,4 +42,4 @@
42
42
{<<"optional">>,true},
43
43
{<<"repository">>,<<"hexpm">>},
44
44
{<<"requirement">>,<<"~> 0.1.0">>}]]}.
45
- {<<"version">>,<<"0.6.2">>}.
45
+ {<<"version">>,<<"0.6.3">>}.
changed lib/myxql/client.ex
 
@@ -193,7 +193,7 @@ defmodule MyXQL.Client do
193
193
defp recv_packets(data, decode, decoder_state, result_state, timeout, client, partial \\ <<>>)
194
194
195
195
defp recv_packets(
196
- <<size::uint3, _seq::uint1, payload::string(size), rest::binary>> = data,
196
+ <<size::uint3(), _seq::uint1(), payload::string(size), rest::binary>> = data,
197
197
decoder,
198
198
{:more_results, resultset},
199
199
result_state,
 
@@ -215,7 +215,7 @@ defmodule MyXQL.Client do
215
215
end
216
216
217
217
defp recv_packets(
218
- <<size::uint3, _seq::uint1, payload::string(size), rest::binary>>,
218
+ <<size::uint3(), _seq::uint1(), payload::string(size), rest::binary>>,
219
219
decoder,
220
220
decoder_state,
221
221
result_state,
 
@@ -242,7 +242,7 @@ defmodule MyXQL.Client do
242
242
# If the packet size equals max packet size, save the payload, receive
243
243
# more data and try again
244
244
defp recv_packets(
245
- <<size::uint3, _seq::uint1, payload::string(size), rest::binary>>,
245
+ <<size::uint3(), _seq::uint1(), payload::string(size), rest::binary>>,
246
246
decoder,
247
247
decoder_state,
248
248
result_state,
changed lib/myxql/error.ex
 
@@ -14,11 +14,22 @@ defmodule MyXQL.Error do
14
14
}
15
15
16
16
@impl true
17
- def message(%{mysql: %{code: code, name: nil}, message: message}) do
18
- "(#{code}) " <> message
17
+ def message(e) do
18
+ if map = e.mysql do
19
+ IO.iodata_to_binary([
20
+ [?(, Integer.to_string(map.code), ?)],
21
+ build_name(map),
22
+ e.message,
23
+ build_query(e.statement)
24
+ ])
25
+ else
26
+ e.message
27
+ end
19
28
end
20
29
21
- def message(%{mysql: %{code: code, name: name}, message: message}) do
22
- "(#{code}) (#{name}) " <> message
23
- end
30
+ defp build_name(%{name: nil}), do: [?\s]
31
+ defp build_name(%{name: name}), do: [?\s, ?(, Atom.to_string(name), ?), ?\s]
32
+
33
+ defp build_query(nil), do: []
34
+ defp build_query(query_statement), do: ["\n\n query: ", query_statement]
24
35
end
changed lib/myxql/protocol.ex
 
@@ -37,7 +37,7 @@ defmodule MyXQL.Protocol do
37
37
encode_packet(rest, rest_size, next_sequence_id, max_packet_size)
38
38
]
39
39
else
40
- [<<payload_size::uint3, sequence_id::uint1>>, payload]
40
+ [<<payload_size::uint3(), sequence_id::uint1()>>, payload]
41
41
end
42
42
end
43
43
 
@@ -54,8 +54,8 @@ defmodule MyXQL.Protocol do
54
54
{last_insert_id, rest} = take_int_lenenc(rest)
55
55
56
56
<<
57
- status_flags::uint2,
58
- num_warnings::uint2,
57
+ status_flags::uint2(),
58
+ num_warnings::uint2(),
59
59
info::binary
60
60
>> = rest
61
61
 
@@ -69,7 +69,7 @@ defmodule MyXQL.Protocol do
69
69
end
70
70
71
71
defp decode_err_packet_body(
72
- <<code::uint2, _sql_state_marker::string(1), _sql_state::string(5), message::bits>>
72
+ <<code::uint2(), _sql_state_marker::string(1), _sql_state::string(5), message::bits>>
73
73
) do
74
74
err_packet(code: code, message: message)
75
75
end
 
@@ -78,14 +78,14 @@ defmodule MyXQL.Protocol do
78
78
decode_eof_packet_body(rest)
79
79
end
80
80
81
- defp decode_eof_packet_body(<<num_warnings::uint2, status_flags::uint2>>) do
81
+ defp decode_eof_packet_body(<<num_warnings::uint2(), status_flags::uint2()>>) do
82
82
eof_packet(
83
83
status_flags: status_flags,
84
84
num_warnings: num_warnings
85
85
)
86
86
end
87
87
88
- defp decode_connect_err_packet_body(<<code::uint2, message::bits>>) do
88
+ defp decode_connect_err_packet_body(<<code::uint2(), message::bits>>) do
89
89
err_packet(code: code, message: message)
90
90
end
91
91
 
@@ -99,23 +99,23 @@ defmodule MyXQL.Protocol do
99
99
{server_version, rest} = take_string_nul(rest)
100
100
101
101
<<
102
- conn_id::uint4,
102
+ conn_id::uint4(),
103
103
auth_plugin_data1::string(8),
104
104
0,
105
- capability_flags1::uint2,
106
- charset::uint1,
107
- status_flags::uint2,
108
- capability_flags2::uint2,
105
+ capability_flags1::uint2(),
106
+ charset::uint1(),
107
+ status_flags::uint2(),
108
+ capability_flags2::uint2(),
109
109
rest::binary
110
110
>> = rest
111
111
112
- <<capability_flags::uint4>> = <<capability_flags1::uint2, capability_flags2::uint2>>
112
+ <<capability_flags::uint4()>> = <<capability_flags1::uint2(), capability_flags2::uint2()>>
113
113
# all set in servers since MySQL 4.1
114
114
required_capabilities = [:client_protocol_41, :client_plugin_auth, :client_secure_connection]
115
115
116
116
with :ok <- ensure_capabilities(capability_flags, required_capabilities) do
117
117
<<
118
- auth_plugin_data_length::uint1,
118
+ auth_plugin_data_length::uint1(),
119
119
_::uint(10),
120
120
rest::binary
121
121
>> = rest
 
@@ -198,8 +198,8 @@ defmodule MyXQL.Protocol do
198
198
database = if database, do: <<database::binary, 0x00>>, else: ""
199
199
200
200
<<
201
- capability_flags::uint4,
202
- max_packet_size::uint4,
201
+ capability_flags::uint4(),
202
+ max_packet_size::uint4(),
203
203
charset,
204
204
0::uint(23),
205
205
<<username::binary, 0x00>>,
 
@@ -217,8 +217,8 @@ defmodule MyXQL.Protocol do
217
217
)
218
218
) do
219
219
<<
220
- capability_flags::uint4,
221
- max_packet_size::uint4,
220
+ capability_flags::uint4(),
221
+ max_packet_size::uint4(),
222
222
charset,
223
223
0::uint(23)
224
224
>>
 
@@ -276,12 +276,12 @@ defmodule MyXQL.Protocol do
276
276
277
277
# https://dev.mysql.com/doc/internals/en/com-stmt-close.html
278
278
def encode_com({:com_stmt_close, statement_id}) do
279
- [0x19, <<statement_id::uint4>>]
279
+ [0x19, <<statement_id::uint4()>>]
280
280
end
281
281
282
282
# https://dev.mysql.com/doc/internals/en/com-stmt-reset.html
283
283
def encode_com({:com_stmt_reset, statement_id}) do
284
- [0x1A, <<statement_id::uint4>>]
284
+ [0x1A, <<statement_id::uint4()>>]
285
285
end
286
286
287
287
# https://dev.mysql.com/doc/internals/en/com-stmt-execute.html
 
@@ -299,9 +299,9 @@ defmodule MyXQL.Protocol do
299
299
300
300
<<
301
301
command,
302
- statement_id::uint4,
303
- flags::uint1,
304
- iteration_count::uint4,
302
+ statement_id::uint4(),
303
+ flags::uint1(),
304
+ iteration_count::uint4(),
305
305
params::binary
306
306
>>
307
307
end
 
@@ -310,8 +310,8 @@ defmodule MyXQL.Protocol do
310
310
def encode_com({:com_stmt_fetch, statement_id, num_rows}) do
311
311
<<
312
312
0x1C,
313
- statement_id::uint4,
314
- num_rows::uint4
313
+ statement_id::uint4(),
314
+ num_rows::uint4()
315
315
>>
316
316
end
317
317
 
@@ -329,8 +329,8 @@ defmodule MyXQL.Protocol do
329
329
end
330
330
331
331
def decode_com_stmt_prepare_response(
332
- <<0x00, statement_id::uint4, num_columns::uint2, num_params::uint2, 0,
333
- num_warnings::uint2>>,
332
+ <<0x00, statement_id::uint4(), num_columns::uint2(), num_params::uint2(), 0,
333
+ num_warnings::uint2()>>,
334
334
next_data,
335
335
:initial
336
336
) do
 
@@ -423,7 +423,7 @@ defmodule MyXQL.Protocol do
423
423
null_bitmap_size = div(count + 7, 8)
424
424
new_params_bound_flag = 1
425
425
426
- <<null_bitmap::uint(null_bitmap_size), new_params_bound_flag::uint1, types::binary,
426
+ <<null_bitmap::uint(null_bitmap_size), new_params_bound_flag::uint1(), types::binary,
427
427
values::binary>>
428
428
end
429
429
 
@@ -465,12 +465,12 @@ defmodule MyXQL.Protocol do
465
465
466
466
<<
467
467
0x0C,
468
- _character_set::uint2,
469
- column_length::uint4,
470
- type::uint1,
471
- flags::uint2,
472
- _decimals::uint1,
473
- 0::uint2
468
+ _character_set::uint2(),
469
+ column_length::uint4(),
470
+ type::uint1(),
471
+ flags::uint2(),
472
+ _decimals::uint1(),
473
+ 0::uint2()
474
474
>> = rest
475
475
476
476
column_def(
 
@@ -518,7 +518,7 @@ defmodule MyXQL.Protocol do
518
518
end
519
519
520
520
defp decode_resultset(
521
- <<0xFE, num_warnings::uint2, status_flags::uint2>>,
521
+ <<0xFE, num_warnings::uint2(), status_flags::uint2()>>,
522
522
next_data,
523
523
{:column_defs_eof, column_defs},
524
524
_row_decoder
 
@@ -541,7 +541,7 @@ defmodule MyXQL.Protocol do
541
541
end
542
542
543
543
defp decode_resultset(
544
- <<0xFE, num_warnings::uint2, status_flags::uint2>>,
544
+ <<0xFE, num_warnings::uint2(), status_flags::uint2()>>,
545
545
_next_data,
546
546
{:rows, column_defs, num_rows, acc},
547
547
_row_decoder
changed lib/myxql/protocol/types.ex
 
@@ -22,19 +22,19 @@ defmodule MyXQL.Protocol.Types do
22
22
23
23
# https://dev.mysql.com/doc/internals/en/integer.html#packet-Protocol::LengthEncodedInteger
24
24
def encode_int_lenenc(int) when int < 251, do: <<int>>
25
- def encode_int_lenenc(int) when int < 0xFFFF, do: <<0xFC, int::uint2>>
26
- def encode_int_lenenc(int) when int < 0xFFFFFF, do: <<0xFD, int::uint3>>
27
- def encode_int_lenenc(int) when int < 0xFFFFFFFFFFFFFFFF, do: <<0xFE, int::uint8>>
25
+ def encode_int_lenenc(int) when int < 0xFFFF, do: <<0xFC, int::uint2()>>
26
+ def encode_int_lenenc(int) when int < 0xFFFFFF, do: <<0xFD, int::uint3()>>
27
+ def encode_int_lenenc(int) when int < 0xFFFFFFFFFFFFFFFF, do: <<0xFE, int::uint8()>>
28
28
29
29
def decode_int_lenenc(binary) do
30
30
{integer, ""} = take_int_lenenc(binary)
31
31
integer
32
32
end
33
33
34
- def take_int_lenenc(<<int::uint1, rest::binary>>) when int < 251, do: {int, rest}
35
- def take_int_lenenc(<<0xFC, int::uint2, rest::binary>>), do: {int, rest}
36
- def take_int_lenenc(<<0xFD, int::uint3, rest::binary>>), do: {int, rest}
37
- def take_int_lenenc(<<0xFE, int::uint8, rest::binary>>), do: {int, rest}
34
+ def take_int_lenenc(<<int::uint1(), rest::binary>>) when int < 251, do: {int, rest}
35
+ def take_int_lenenc(<<0xFC, int::uint2(), rest::binary>>), do: {int, rest}
36
+ def take_int_lenenc(<<0xFD, int::uint3(), rest::binary>>), do: {int, rest}
37
+ def take_int_lenenc(<<0xFE, int::uint8(), rest::binary>>), do: {int, rest}
38
38
39
39
# https://dev.mysql.com/doc/internals/en/string.html#packet-Protocol::FixedLengthString
40
40
defmacro string(size) do
changed lib/myxql/protocol/values.ex
 
@@ -187,7 +187,7 @@ defmodule MyXQL.Protocol.Values do
187
187
188
188
def encode_binary_value(value)
189
189
when is_integer(value) and value >= -1 <<< 63 and value < 1 <<< 64 do
190
- {:mysql_type_longlong, <<value::int8>>}
190
+ {:mysql_type_longlong, <<value::int8()>>}
191
191
end
192
192
193
193
def encode_binary_value(value) when is_float(value) do
 
@@ -202,11 +202,11 @@ defmodule MyXQL.Protocol.Values do
202
202
end
203
203
204
204
def encode_binary_value(%Date{year: year, month: month, day: day}) do
205
- {:mysql_type_date, <<4, year::uint2, month::uint1, day::uint1>>}
205
+ {:mysql_type_date, <<4, year::uint2(), month::uint1(), day::uint1()>>}
206
206
end
207
207
208
208
def encode_binary_value(:zero_date) do
209
- {:mysql_type_date, <<4, 0::uint2, 0::uint1, 0::uint1>>}
209
+ {:mysql_type_date, <<4, 0::uint2(), 0::uint1(), 0::uint1()>>}
210
210
end
211
211
212
212
def encode_binary_value(%Time{} = time), do: encode_binary_time(time)
 
@@ -269,7 +269,7 @@ defmodule MyXQL.Protocol.Values do
269
269
defp encode_geometry(geo) do
270
270
srid = geo.srid || 0
271
271
binary = %{geo | srid: nil} |> Geo.WKB.encode_to_iodata(:ndr) |> IO.iodata_to_binary()
272
- {:mysql_type_var_string, encode_string_lenenc(<<srid::uint4, binary::binary>>)}
272
+ {:mysql_type_var_string, encode_string_lenenc(<<srid::uint4(), binary::binary>>)}
273
273
end
274
274
end
275
275
 
@@ -283,7 +283,8 @@ defmodule MyXQL.Protocol.Values do
283
283
end
284
284
285
285
defp encode_binary_time(%Time{hour: hour, minute: minute, second: second, microsecond: {0, 0}}) do
286
- {:mysql_type_time, <<8, 0::uint1, 0::uint4, hour::uint1, minute::uint1, second::uint1>>}
286
+ {:mysql_type_time,
287
+ <<8, 0::uint1(), 0::uint4(), hour::uint1(), minute::uint1(), second::uint1()>>}
287
288
end
288
289
289
290
defp encode_binary_time(%Time{
 
@@ -293,7 +294,8 @@ defmodule MyXQL.Protocol.Values do
293
294
microsecond: {microsecond, _}
294
295
}) do
295
296
{:mysql_type_time,
296
- <<12, 0::uint1, 0::uint4, hour::uint1, minute::uint1, second::uint1, microsecond::uint4>>}
297
+ <<12, 0::uint1(), 0::uint4(), hour::uint1(), minute::uint1(), second::uint1(),
298
+ microsecond::uint4()>>}
297
299
end
298
300
299
301
defp encode_binary_datetime(%NaiveDateTime{
 
@@ -306,7 +308,8 @@ defmodule MyXQL.Protocol.Values do
306
308
microsecond: {0, 0}
307
309
}) do
308
310
{:mysql_type_datetime,
309
- <<7, year::uint2, month::uint1, day::uint1, hour::uint1, minute::uint1, second::uint1>>}
311
+ <<7, year::uint2(), month::uint1(), day::uint1(), hour::uint1(), minute::uint1(),
312
+ second::uint1()>>}
310
313
end
311
314
312
315
defp encode_binary_datetime(%NaiveDateTime{
 
@@ -319,8 +322,8 @@ defmodule MyXQL.Protocol.Values do
319
322
microsecond: {microsecond, _}
320
323
}) do
321
324
{:mysql_type_datetime,
322
- <<11, year::uint2, month::uint1, day::uint1, hour::uint1, minute::uint1, second::uint1,
323
- microsecond::uint4>>}
325
+ <<11, year::uint2(), month::uint1(), day::uint1(), hour::uint1(), minute::uint1(),
326
+ second::uint1(), microsecond::uint4()>>}
324
327
end
325
328
326
329
defp encode_binary_datetime(%DateTime{
 
@@ -334,8 +337,8 @@ defmodule MyXQL.Protocol.Values do
334
337
time_zone: "Etc/UTC"
335
338
}) do
336
339
{:mysql_type_datetime,
337
- <<11, year::uint2, month::uint1, day::uint1, hour::uint1, minute::uint1, second::uint1,
338
- microsecond::uint4>>}
340
+ <<11, year::uint2(), month::uint1(), day::uint1(), hour::uint1(), minute::uint1(),
341
+ second::uint1(), microsecond::uint4()>>}
339
342
end
340
343
341
344
defp encode_binary_datetime(%DateTime{} = datetime) do
 
@@ -418,7 +421,7 @@ defmodule MyXQL.Protocol.Values do
418
421
419
422
if Code.ensure_loaded?(Geo) do
420
423
# https://dev.mysql.com/doc/refman/8.0/en/gis-data-formats.html#gis-internal-format
421
- defp decode_geometry(<<srid::uint4, r::bits>>) do
424
+ defp decode_geometry(<<srid::uint4(), r::bits>>) do
422
425
srid = if srid == 0, do: nil, else: srid
423
426
r |> Geo.WKB.decode!() |> Map.put(:srid, srid)
424
427
end
 
@@ -434,28 +437,28 @@ defmodule MyXQL.Protocol.Values do
434
437
end
435
438
end
436
439
437
- defp decode_int1(<<v::int1, r::bits>>, null_bitmap, t, acc),
440
+ defp decode_int1(<<v::int1(), r::bits>>, null_bitmap, t, acc),
438
441
do: decode_binary_row(r, null_bitmap >>> 1, t, [v | acc])
439
442
440
- defp decode_uint1(<<v::uint1, r::bits>>, null_bitmap, t, acc),
443
+ defp decode_uint1(<<v::uint1(), r::bits>>, null_bitmap, t, acc),
441
444
do: decode_binary_row(r, null_bitmap >>> 1, t, [v | acc])
442
445
443
- defp decode_int2(<<v::int2, r::bits>>, null_bitmap, t, acc),
446
+ defp decode_int2(<<v::int2(), r::bits>>, null_bitmap, t, acc),
444
447
do: decode_binary_row(r, null_bitmap >>> 1, t, [v | acc])
445
448
446
- defp decode_uint2(<<v::uint2, r::bits>>, null_bitmap, t, acc),
449
+ defp decode_uint2(<<v::uint2(), r::bits>>, null_bitmap, t, acc),
447
450
do: decode_binary_row(r, null_bitmap >>> 1, t, [v | acc])
448
451
449
- defp decode_int4(<<v::int4, r::bits>>, null_bitmap, t, acc),
452
+ defp decode_int4(<<v::int4(), r::bits>>, null_bitmap, t, acc),
450
453
do: decode_binary_row(r, null_bitmap >>> 1, t, [v | acc])
451
454
452
- defp decode_uint4(<<v::uint4, r::bits>>, null_bitmap, t, acc),
455
+ defp decode_uint4(<<v::uint4(), r::bits>>, null_bitmap, t, acc),
453
456
do: decode_binary_row(r, null_bitmap >>> 1, t, [v | acc])
454
457
455
- defp decode_int8(<<v::int8, r::bits>>, null_bitmap, t, acc),
458
+ defp decode_int8(<<v::int8(), r::bits>>, null_bitmap, t, acc),
456
459
do: decode_binary_row(r, null_bitmap >>> 1, t, [v | acc])
457
460
458
- defp decode_uint8(<<v::uint8, r::bits>>, null_bitmap, t, acc),
461
+ defp decode_uint8(<<v::uint8(), r::bits>>, null_bitmap, t, acc),
459
462
do: decode_binary_row(r, null_bitmap >>> 1, t, [v | acc])
460
463
461
464
defp decode_float(<<v::32-signed-little-float, r::bits>>, null_bitmap, t, acc),
 
@@ -466,10 +469,15 @@ defmodule MyXQL.Protocol.Values do
466
469
467
470
# in theory it's supposed to be a `string_lenenc` field. However since MySQL decimals
468
471
# maximum precision is 65 digits, the size of the string will always fir on one byte.
469
- defp decode_decimal(<<n::uint1, string::string(n), r::bits>>, null_bitmap, t, acc),
472
+ defp decode_decimal(<<n::uint1(), string::string(n), r::bits>>, null_bitmap, t, acc),
470
473
do: decode_binary_row(r, null_bitmap >>> 1, t, [Decimal.new(string) | acc])
471
474
472
- defp decode_date(<<4, year::uint2, month::uint1, day::uint1, r::bits>>, null_bitmap, t, acc) do
475
+ defp decode_date(
476
+ <<4, year::uint2(), month::uint1(), day::uint1(), r::bits>>,
477
+ null_bitmap,
478
+ t,
479
+ acc
480
+ ) do
473
481
v = %Date{year: year, month: month, day: day}
474
482
decode_binary_row(r, null_bitmap >>> 1, t, [v | acc])
475
483
end
 
@@ -480,7 +488,8 @@ defmodule MyXQL.Protocol.Values do
480
488
end
481
489
482
490
defp decode_time(
483
- <<8, is_negative, days::uint4, hours::uint1, minutes::uint1, seconds::uint1, r::bits>>,
491
+ <<8, is_negative, days::uint4(), hours::uint1(), minutes::uint1(), seconds::uint1(),
492
+ r::bits>>,
484
493
null_bitmap,
485
494
t,
486
495
acc
 
@@ -490,8 +499,8 @@ defmodule MyXQL.Protocol.Values do
490
499
end
491
500
492
501
defp decode_time(
493
- <<12, is_negative, days::uint4, hours::uint1, minutes::uint1, seconds::uint1,
494
- microseconds::uint4, r::bits>>,
502
+ <<12, is_negative, days::uint4(), hours::uint1(), minutes::uint1(), seconds::uint1(),
503
+ microseconds::uint4(), r::bits>>,
495
504
null_bitmap,
496
505
t,
497
506
acc
 
@@ -521,7 +530,7 @@ defmodule MyXQL.Protocol.Values do
521
530
end
522
531
523
532
defp decode_datetime(
524
- <<4, year::uint2, month::uint1, day::uint1, r::bits>>,
533
+ <<4, year::uint2(), month::uint1(), day::uint1(), r::bits>>,
525
534
null_bitmap,
526
535
t,
527
536
acc,
 
@@ -532,8 +541,8 @@ defmodule MyXQL.Protocol.Values do
532
541
end
533
542
534
543
defp decode_datetime(
535
- <<7, year::uint2, month::uint1, day::uint1, hour::uint1, minute::uint1, second::uint1,
536
- r::bits>>,
544
+ <<7, year::uint2(), month::uint1(), day::uint1(), hour::uint1(), minute::uint1(),
545
+ second::uint1(), r::bits>>,
537
546
null_bitmap,
538
547
t,
539
548
acc,
 
@@ -544,8 +553,8 @@ defmodule MyXQL.Protocol.Values do
544
553
end
545
554
546
555
defp decode_datetime(
547
- <<11, year::uint2, month::uint1, day::uint1, hour::uint1, minute::uint1, second::uint1,
548
- microsecond::uint4, r::bits>>,
556
+ <<11, year::uint2(), month::uint1(), day::uint1(), hour::uint1(), minute::uint1(),
557
+ second::uint1(), microsecond::uint4(), r::bits>>,
549
558
null_bitmap,
550
559
t,
551
560
acc,
 
@@ -594,12 +603,12 @@ defmodule MyXQL.Protocol.Values do
594
603
}
595
604
end
596
605
597
- defp decode_string_lenenc(<<n::uint1, v::string(n), r::bits>>, null_bitmap, t, acc, decoder)
606
+ defp decode_string_lenenc(<<n::uint1(), v::string(n), r::bits>>, null_bitmap, t, acc, decoder)
598
607
when n < 251,
599
608
do: decode_binary_row(r, null_bitmap >>> 1, t, [decoder.(v) | acc])
600
609
601
610
defp decode_string_lenenc(
602
- <<0xFC, n::uint2, v::string(n), r::bits>>,
611
+ <<0xFC, n::uint2(), v::string(n), r::bits>>,
603
612
null_bitmap,
604
613
t,
605
614
acc,
 
@@ -608,7 +617,7 @@ defmodule MyXQL.Protocol.Values do
608
617
do: decode_binary_row(r, null_bitmap >>> 1, t, [decoder.(v) | acc])
609
618
610
619
defp decode_string_lenenc(
611
- <<0xFD, n::uint3, v::string(n), r::bits>>,
620
+ <<0xFD, n::uint3(), v::string(n), r::bits>>,
612
621
null_bitmap,
613
622
t,
614
623
acc,
 
@@ -617,7 +626,7 @@ defmodule MyXQL.Protocol.Values do
617
626
do: decode_binary_row(r, null_bitmap >>> 1, t, [decoder.(v) | acc])
618
627
619
628
defp decode_string_lenenc(
620
- <<0xFE, n::uint8, v::string(n), r::bits>>,
629
+ <<0xFE, n::uint8(), v::string(n), r::bits>>,
621
630
null_bitmap,
622
631
t,
623
632
acc,
 
@@ -625,16 +634,16 @@ defmodule MyXQL.Protocol.Values do
625
634
),
626
635
do: decode_binary_row(r, null_bitmap >>> 1, t, [decoder.(v) | acc])
627
636
628
- defp decode_json(<<n::uint1, v::string(n), r::bits>>, null_bitmap, t, acc) when n < 251,
637
+ defp decode_json(<<n::uint1(), v::string(n), r::bits>>, null_bitmap, t, acc) when n < 251,
629
638
do: decode_binary_row(r, null_bitmap >>> 1, t, [decode_json(v) | acc])
630
639
631
- defp decode_json(<<0xFC, n::uint2, v::string(n), r::bits>>, null_bitmap, t, acc),
640
+ defp decode_json(<<0xFC, n::uint2(), v::string(n), r::bits>>, null_bitmap, t, acc),
632
641
do: decode_binary_row(r, null_bitmap >>> 1, t, [decode_json(v) | acc])
633
642
634
- defp decode_json(<<0xFD, n::uint3, v::string(n), r::bits>>, null_bitmap, t, acc),
643
+ defp decode_json(<<0xFD, n::uint3(), v::string(n), r::bits>>, null_bitmap, t, acc),
635
644
do: decode_binary_row(r, null_bitmap >>> 1, t, [decode_json(v) | acc])
636
645
637
- defp decode_json(<<0xFE, n::uint8, v::string(n), r::bits>>, null_bitmap, t, acc),
646
+ defp decode_json(<<0xFE, n::uint8(), v::string(n), r::bits>>, null_bitmap, t, acc),
638
647
do: decode_binary_row(r, null_bitmap >>> 1, t, [decode_json(v) | acc])
639
648
640
649
defp decode_json(string), do: json_library().decode!(string)
 
@@ -643,16 +652,16 @@ defmodule MyXQL.Protocol.Values do
643
652
Application.get_env(:myxql, :json_library, Jason)
644
653
end
645
654
646
- defp decode_bit(<<n::uint1, v::string(n), r::bits>>, size, null_bitmap, t, acc) when n < 251,
655
+ defp decode_bit(<<n::uint1(), v::string(n), r::bits>>, size, null_bitmap, t, acc) when n < 251,
647
656
do: decode_binary_row(r, null_bitmap >>> 1, t, [decode_bit(v, size) | acc])
648
657
649
- defp decode_bit(<<0xFC, n::uint2, v::string(n), r::bits>>, size, null_bitmap, t, acc),
658
+ defp decode_bit(<<0xFC, n::uint2(), v::string(n), r::bits>>, size, null_bitmap, t, acc),
650
659
do: decode_binary_row(r, null_bitmap >>> 1, t, [decode_bit(v, size) | acc])
651
660
652
- defp decode_bit(<<0xFD, n::uint3, v::string(n), r::bits>>, size, null_bitmap, t, acc),
661
+ defp decode_bit(<<0xFD, n::uint3(), v::string(n), r::bits>>, size, null_bitmap, t, acc),
653
662
do: decode_binary_row(r, null_bitmap >>> 1, t, [decode_bit(v, size) | acc])
654
663
655
- defp decode_bit(<<0xFE, n::uint8, v::string(n), r::bits>>, size, null_bitmap, t, acc),
664
+ defp decode_bit(<<0xFE, n::uint8(), v::string(n), r::bits>>, size, null_bitmap, t, acc),
656
665
do: decode_binary_row(r, null_bitmap >>> 1, t, [decode_bit(v, size) | acc])
657
666
658
667
defp decode_bit(binary, size) do
changed lib/myxql/result.ex
 
@@ -44,11 +44,11 @@ end
44
44
if Code.ensure_loaded?(Table.Reader) do
45
45
defimpl Table.Reader, for: MyXQL.Result do
46
46
def init(%{columns: columns}) when columns in [nil, []] do
47
- {:rows, %{columns: []}, []}
47
+ {:rows, %{columns: [], count: 0}, []}
48
48
end
49
49
50
50
def init(result) do
51
- {:rows, %{columns: result.columns}, result.rows}
51
+ {:rows, %{columns: result.columns, count: result.num_rows}, result.rows}
52
52
end
53
53
end
54
54
end
changed mix.exs
 
@@ -1,7 +1,7 @@
1
1
defmodule MyXQL.MixProject do
2
2
use Mix.Project
3
3
4
- @version "0.6.2"
4
+ @version "0.6.3"
5
5
@source_url "https://github.com/elixir-ecto/myxql"
6
6
7
7
def project() do