-
Notifications
You must be signed in to change notification settings - Fork 72
Fix LOCAL INFILE options in mysql driver handshake #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
335c162
c903ff5
e111258
e3fa07b
c5be00e
c2d5ea5
66e99ed
31207c5
7405353
e65d102
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,14 +27,16 @@ defmodule MyXQL.Protocol.Types do | |
def encode_int_lenenc(int) when int < 0xFFFFFFFFFFFFFFFF, do: <<0xFE, int::uint8()>> | ||
|
||
def decode_int_lenenc(binary) do | ||
{integer, ""} = take_int_lenenc(binary) | ||
{integer, _rest} = take_int_lenenc(binary) | ||
integer | ||
end | ||
|
||
def take_int_lenenc(<<int::uint1(), rest::binary>>) when int < 251, do: {int, rest} | ||
def take_int_lenenc(<<0xFB, rest::binary>>), do: {nil, rest} | ||
def take_int_lenenc(<<0xFC, int::uint2(), rest::binary>>), do: {int, rest} | ||
def take_int_lenenc(<<0xFD, int::uint3(), rest::binary>>), do: {int, rest} | ||
def take_int_lenenc(<<0xFE, int::uint8(), rest::binary>>), do: {int, rest} | ||
def take_int_lenenc(<<0xFF, rest::binary>>), do: {:error, rest} | ||
|
||
# https://dev.mysql.com/doc/internals/en/string.html#packet-Protocol::FixedLengthString | ||
defmacro string(size) do | ||
|
@@ -68,8 +70,13 @@ defmodule MyXQL.Protocol.Types do | |
|
||
def take_string_nul(""), do: {nil, ""} | ||
|
||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change still necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But why? We said the filename is always followed by a nul byte, right? That will always return a two element list:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I change it I got this error:
|
||
case :binary.split(binary, <<0>>) do | ||
[string] -> | ||
{string, ""} | ||
|
||
[string, rest] -> | ||
{string, rest} | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Base on the changes to
take_string_nul
, it seems you are not expecting anul
here? So maybe we should not call/change said function?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, we shouldn't change the function!