Fix LOCAL INFILE options in mysql driver handshake#204
Fix LOCAL INFILE options in mysql driver handshake#204iagocavalcante wants to merge 10 commits intoelixir-ecto:masterfrom
Conversation
| end | ||
|
|
||
| defp decode_resultset(<<0xFB, rest::binary>>, _next_data, :initial, _row_decoder) do | ||
| {filename, ""} = take_string_nul(rest) |
There was a problem hiding this comment.
Base on the changes to take_string_nul, it seems you are not expecting a nul here? So maybe we should not call/change said function?
There was a problem hiding this comment.
You're right, we shouldn't change the function!
lib/myxql/protocol.ex
Outdated
| end | ||
|
|
||
| def decode_com_query_response(<<0xFB, rest::binary>>, "", :initial) do | ||
| {filename, _remaining} = take_string_nul(rest) |
There was a problem hiding this comment.
Are we sure we can discard the rest here? Or should we assert it is an empty string as well? Or nul even there?
There was a problem hiding this comment.
According here. The LOCAL INFILE request packet is
- 1 byte: 0xFB and
- N bytes: the filename as a NUL-terminated string
So after parsing the filename, there should be nothing left in the packet
There was a problem hiding this comment.
So we can match on the empty string as second tuple element as well!
| def take_string_nul(binary) do | ||
| [string, rest] = :binary.split(binary, <<0>>) | ||
| {string, rest} | ||
| def take_string_nul(binary) when is_binary(binary) do |
There was a problem hiding this comment.
Is this change still necessary?
There was a problem hiding this comment.
When I tested it without the changes to the method, an exception occurred when using the client. So its necessary
There was a problem hiding this comment.
But why? We said the filename is always followed by a nul byte, right? That will always return a two element list:
iex(2)> :binary.split(<<"/", 0>>, [<<0>>])
["/", ""]
There was a problem hiding this comment.
When I change it I got this error:
stopped: ** (MatchError) no match of right hand side value: ["/Users/iagocavalcante/Workspaces/i9Amazon/i9_processador/25332012000225-pdv_caixa_lancamento-20250618_210733-T-110.txt"]
(myxql 0.8.0-dev) lib/myxql/protocol/types.ex:74: MyXQL.Protocol.Types.take_string_nul/1
There was a problem hiding this comment.
What should I do to have this merged?
closes #203