Skip to content
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

Do not raise exception when decoding packets #119

Open
wojtekmach opened this issue Sep 11, 2020 · 1 comment
Open

Do not raise exception when decoding packets #119

wojtekmach opened this issue Sep 11, 2020 · 1 comment

Comments

@wojtekmach
Copy link
Member

It crashes the connection:

iex(1)> {:ok, pid} = MyXQL.start_link([]); MyXQL.query!(pid, "SELECT TIME(ADDTIME('23:00:00', '02:00:00'))")
** (ArgumentError) cannot decode "1d 01:00:00" as time, negative or >= 24:00:00 values are not supported
    (myxql 0.4.2) lib/myxql/protocol/values.ex:511: MyXQL.Protocol.Values.time/6
    (myxql 0.4.2) lib/myxql/protocol/values.ex:481: MyXQL.Protocol.Values.decode_time/4
    (myxql 0.4.2) lib/myxql/protocol.ex:539: MyXQL.Protocol.decode_resultset/4
    (myxql 0.4.2) lib/myxql/client.ex:197: MyXQL.Client.recv_packets/6
    (myxql 0.4.2) lib/myxql/connection.ex:102: MyXQL.Connection.handle_execute/4
    (db_connection 2.2.1) lib/db_connection/holder.ex:316: DBConnection.Holder.holder_apply/4
    (db_connection 2.2.1) lib/db_connection.ex:1255: DBConnection.run_execute/5
    (db_connection 2.2.1) lib/db_connection.ex:1342: DBConnection.run/6
    (db_connection 2.2.1) lib/db_connection.ex:539: DBConnection.parsed_prepare_execute/5
    (db_connection 2.2.1) lib/db_connection.ex:532: DBConnection.prepare_execute/4
    (myxql 0.4.2) lib/myxql.ex:235: MyXQL.do_query/4
    (myxql 0.4.2) lib/myxql.ex:258: MyXQL.query!/4
iex(1)>
19:47:44.063 [error] GenServer #PID<0.217.0> terminating
** (DBConnection.ConnectionError) client #PID<0.213.0> stopped: ** (ArgumentError) cannot decode "1d 01:00:00" as time, negative or >= 24:00:00 values are not supported

Instead we should return an error tuple and later decide what to do with it.

We may still want to disconnect because if we stop decoding in the middle, there might be still data on the socket which may or may not be a problem.

@wojtekmach
Copy link
Member Author

This also makes CI occasionally fail: https://github.com/elixir-ecto/myxql/runs/1359973771?check_suite_focus=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant