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

Error when sending text queries #132

Closed
jdangerx opened this issue Sep 16, 2016 · 0 comments
Closed

Error when sending text queries #132

jdangerx opened this issue Sep 16, 2016 · 0 comments

Comments

@jdangerx
Copy link
Contributor

I'm trying to send an unprepared text query to a MySQL database. I'm creating a query, %Mariaex.Query{type: :text, statement: "SELECT 1, 2, 3"}, as a test - and it's causing an error:

iex(2)> Mariaex.execute(prod, %Mariaex.Query{type: :text, statement: "SELECT 1, 2, 3"}, [])
** (FunctionClauseError) no function clause matching in Mariaex.Protocol.handle_error/3
** (EXIT from #PID<0.819.0>) an exception was raised:
    ** (DBConnection.ConnectionError) client #PID<0.819.0> stopped: ** (FunctionClauseError) no function clause matching in Mariaex.Protocol.handle_error/3
    (mariaex) lib/mariaex/protocol.ex:397: Mariaex.Protocol.handle_error({:packet, 1, 1, {:column_count, 3}, <<3>>}, %Mariaex.Query{binary_as: nil, connection_ref: nil, name: "", parameter_types: [], reserved?: false, statement: "SELECT 1, 2, 3", statement_id: nil, type: :text, types: []}, %Mariaex.Protocol{binary_as: :field_type_var_string, buffer: "", cache: 2388016, catch_eof: false, connection_id: #PID<0.821.0>, connection_ref: #Reference<0.0.1.4568>, lru_cache: {100, 2392118}, opts: [socket_options: [], sock_type: :tcp, cache_size: 100, timeout: 5000, hostname: "<hostname>", port: 3306, username: "<username>", password: "<pass>", database: "<dbname>"], protocol57: false, rows: [], seqnum: 0, sock: {Mariaex.Connection.Tcp, #Port<0.18151>}, ssl_conn_state: :not_used, state: :column_count, state_data: nil, timeout: 5000})
    (db_connection) lib/db_connection.ex:739: DBConnection.handle/4
    (db_connection) lib/db_connection.ex:797: anonymous fn/4 in DBConnection.run_execute/4
    (db_connection) lib/db_connection.ex:882: DBConnection.run_begin/3
    (db_connection) lib/db_connection.ex:830: DBConnection.run_meter/3
    (db_connection) lib/db_connection.ex:502: DBConnection.execute/4
    (mariaex) lib/mariaex.ex:228: Mariaex.execute/4
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6

        (db_connection) lib/db_connection/connection.ex:238: DBConnection.Connection.handle_cast/2
        (connection) lib/connection.ex:812: Connection.handle_async/3
        (stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
        (stdlib) gen_server.erl:681: :gen_server.handle_msg/5
        (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

So it looks like we have a pattern match fail here:
https://github.com/xerions/mariaex/blob/master/lib/mariaex/protocol.ex#L394-L399

But why would the packet being sent back have the wrong pattern?

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

2 participants