xerions / mariaex Goto Github PK
View Code? Open in Web Editor NEWPure Elixir database driver for MariaDB / MySQL
License: Other
Pure Elixir database driver for MariaDB / MySQL
License: Other
This client has the same bug as postgrex had which is relying on timeouts and returning :normal when it isn't really supposed to. I have fixed this in postgrex, I recommend going through those changes and apply them to mariaex too:
elixir-ecto/postgrex@6908762...a016856
:)
18:38:11.339 [error] GenServer #PID<0.88.0> terminating
Last message: {:connect, %{hostname: "localhost", password: nil, port: "3306", user: "root"}}
State: %{backend_key: nil, opts: nil, parameters: %{}, queue: {[], []}, rows: [], seqnum: 0, sock: nil, sock_mod: Mariaex.Connection.Tcp, state: :ready, statement: nil, tail: "", transactions: 0, types: :types_removed}
** (exit) an exception was raised:
** (ErlangError) erlang error: {:function_clause, [{:inet_tcp, :getserv, ["3306"], [file: 'inet_tcp.erl', line: 35]}, {:gen_tcp, :connect1, 4, [file: 'gen_tcp.erl', line: 154]}, {:gen_tcp, :connect, 4, [file: 'gen_tcp.erl', line: 141]}, {Mariaex.Connection, :handle_call, 3, [file: 'lib/mariaex/mariaex.ex', line: 289]}, {:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 607]}, {:gen_server, :handle_msg, 5, [file: 'gen_server.erl', line: 639]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 237]}]}
(kernel) gen_tcp.erl:146: :gen_tcp.connect/4
(mariaex) lib/mariaex/mariaex.ex:289: Mariaex.Connection.handle_call/3
(stdlib) gen_server.erl:607: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:639: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
Here is a test case:
test "encoding bad parameters", context do
query("SELECT 1", [:badparam])
end
I have tried fixing this but, since parameters are only encoded later, we need a way to abort the current query and tell the client an error occurred. I am aware this mechanism exists for Postgrex so we can look there for inspiration.
Minimal failing example:
Ecto.Adapters.SQL.query Repo, "select TIME '00:00'", []
I am not sure what is causing them yet but this is a common failure in our builds since we have migrated to 0.2.1: https://travis-ci.org/elixir-lang/ecto/jobs/67628765
One possible root cause can be transactions. Because some tests run inside transactions, if the prepare statement cache is not meant to outlive a transaction, they will be discarded when the transaction rollback or commits. But I may be completely wrong.
Hi,
A lot of people are new to Elixir. How do you iterate over the list and access column data per row? Is there an example of it?
Hi!
When running CREATE TABLE
it doesn't return the {:ok, %Mariaex.Result{columns: [], command: :create, num_rows: 0, rows: []}}
as stated in the README documentation.
iex(1)> {:ok, p} = Mariaex.Connection.start_link(username: "root", database: "ecto_test")
{:ok, #PID<0.123.0>}
iex(2)> Mariaex.Connection.query(p, "CREATE TABLE test1 (id serial, title text)")
:ok
iex(3)> Mariaex.Connection.query(p, "INSERT INTO test1 VALUES(1, 'test')")
{:ok, %Mariaex.Result{columns: [], command: :insert, num_rows: 1, rows: []}}
iex(4)>
Should be:
iex(1)> {:ok, p} = Mariaex.Connection.start_link(username: "root", database: "ecto_test")
{:ok, #PID<0.123.0>}
iex(2)> Mariaex.Connection.query(p, "CREATE TABLE test1 (id serial, title text)")
{:ok, %Mariaex.Result{columns: [], command: :create, num_rows: 0, rows: []}}
iex(3)> Mariaex.Connection.query(p, "INSERT INTO test1 VALUES(1, 'test')")
{:ok, %Mariaex.Result{columns: [], command: :insert, num_rows: 1, rows: []}}
iex(4)>
I think it should be a simple fix, right? I don't have time right now, but I can take a look on monday.
Here is the error message:
** (exit) an exception was raised:
** (Mariaex.Error) (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ILIKE ?)' at line 1
(ecto) lib/ecto/adapters/sql.ex:185: Ecto.Adapters.SQL.query!/5
(ecto) lib/ecto/adapters/sql.ex:478: Ecto.Adapters.SQL.execute/6
(ecto) lib/ecto/repo/queryable.ex:95: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:15: Ecto.Repo.Queryable.all/4
I have a very simple ilike query to isolate this:
search_term = "John%"
people = Repo.all(
from p in Find.People,
where: ilike(p.fname, ^search_term)
)
From mix.lock
Mariaex: 0.4.3
Phoenix: 1.0.3
Ecto: 1.0.6
Phoenix_ecto: 1.2.0
The database:
MySQL 5.6.23
There are 2 failing tests:
1) test encode and decode timestamp (QueryTest)
test/query_test.exs:266
** (MatchError) no match of right hand side value: %Mariaex.Error{mariadb: %{code: 1067, message: "Invalid default value for 'ts2'"}, message: nil}
stacktrace:
test/query_test.exs:273
2) test encode and decode date (QueryTest)
test/query_test.exs:213
** (MatchError) no match of right hand side value: %Mariaex.Error{mariadb: %{code: 1292, message: "Incorrect date value: '0000-00-00' for column 'd' at row 1"}, message: nil}
stacktrace:
test/query_test.exs:223
At the moment, a replace statement with parameter is reported as unsupported query
Stored procedure can have multi result statements.
Related to #49.
mysql_conn |> Mariaex.Connection.query "
SELECT 1
"
** (EXIT from #PID<0.51.0>) an exception was raised:
** (CaseClauseError) no case clause matching: :query_send
lib/mariaex/protocol.ex:55: Mariaex.Protocol.dispatch/2
lib/mariaex/connection.ex:215: Mariaex.Connection.process/2
lib/mariaex/connection.ex:192: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:599: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
Because of Mix.Shell.Cmd/2 changed to Mix.Shell.Cmd/3, the tests should be changed to something, what elixir 1.0.0 and 1.1.0 independent.
Mariaex.Connection.start_link(hostname: "mysql.asdf.com", port: 3306, username: "test", password: "test", database: "testdb", timeout: 20000, keepalive_timeout: 20000, ssl: true, ssl_opts: [cacertfile: "rds-combined-ca-bundle.pem"])
Seems to default to non-ssl. Is there a problem with the way I'm using this? The documentation has absolutely nothing about SSL and Ecto (that uses mariaex for MySQL) suggests ssl: true and ssl_opts with Erlang documentation. I've tried for a few days and ended up nowhere. Offering help for implement if you guys don't have this done yet.
Hi Dmitry!
After some hard work we did I think it's time to release the first Mariaex version :)
Do you need help with this first release?
Thanks!
For better performance, it make sense to cache queries on client side. The implementation can cache query(use configurable size how big cache can be), and after it see the known query it can reuse it, without allocating and deallocating the query. All new queries, not known queries, which are reach the cache size, will deallocate old used queries in cache.
Currently Mariaex can communicate to MySQL via TCP sockets only. I think Unix sockets support should be added as well because having MySQL and app on the same server is quite a common scenario and in such case communication via Unix socket is preferred.
Today, if you pass bad credentials when starting the connection to the database, it fails with a case clause error on :tcp_closed. We should instead handle this case and return a proper error, saying we were unable to connect to the database.
Hello,
trying to insert 1Mio values using ecto Repo.insert, i got this after 16382 successfull operations
** (Mariaex.Error) (1461): Can't create more than max_prepared_stmt_count statements (current value: 16382)
lib/ecto/adapters/sql/worker.ex:26: Ecto.Adapters.SQL.Worker.query!/4
lib/ecto/adapters/sql.ex:187: Ecto.Adapters.SQL.use_worker/3
(app) lib/app.ex:27: App.Repo.log/2
lib/ecto/adapters/sql.ex:394: Ecto.Adapters.SQL.model/5
lib/ecto/repo/model.ex:32: anonymous fn/8 in Ecto.Repo.Model.insert/4
(stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
(stdlib) erl_eval.erl:227: :erl_eval.expr/5
(elixir) lib/enum.ex:1388: anonymous fn/3 in Enum.reduce/3
/cc @laurocaetano
If I perform a query like
SELECT people.id, people.name, pets.id, pets.name
FROM people
LEFT JOIN pets ON people.id = pets.person_id
I'll get a Mariaex.Result
with a columns
field of: ["id", "name", "id", "name"]
and rows
of `[[1, "Joe", 1, "Fluffy"], [1, "Joe", 2, "Fido"]].
This becomes really hard to deal with when the queries are more like
SELECT people.*, pets.*
When the query may return a different number of columns in the future.
Is there any way to have entries in the columns
field include the table name? Or, alternatively, get results as a list of nested data structures?
For example, the npm mysql package handles this problem by including a nestTables
option where you can either get results as a series of nested data structures, or specify a string for concatenating table name and column name: (https://www.npmjs.com/package/mysql#joins-with-overlapping-column-names).
As an example, if you specify host
instead of hostname
when configuring a connection, you'll most likely get econnrefused
. You'll see your host
value is totally right, only then to realize, sifting through the source code/documentation, that it should have been hostname
instead.
This particular error would have made much more sense if the error spit out the whole connection string it was using. I'm not sure if there are other places where the errors are super lean like this, but something worth considering, I think.
Other than that, Mariaex works great. :)
Is not supported call stored procedure?
Should be done for one of future release, for speedup adding bulk data.
After some benchmarks, client side decoding is slower, from 2% on 10 entries to more than 12% when returning 100 entries since more copying is required. We should revert the client side decoding changes.
iex(6)> Mariaex.Connection.query(p, "SELECT id, title FROM test1")
{:ok,
%Mariaex.Result{columns: ["id", "title"], command: :select, num_rows: 2,
rows: [{1, "test"}, {2, "test2"}]}}
iex(7)> Mariaex.Connection.query(p, "SELECT id, title FROM test1")
{:ok,
%Mariaex.Result{columns: ["id", "title"], command: :select, num_rows: 4,
rows: [{1, "test"}, {2, "test2"}, {1, "test"}, {2, "test2"}]}}
iex(8)> Mariaex.Connection.query(p, "SELECT id, title FROM test1")
{:ok,
%Mariaex.Result{columns: ["id", "title"], command: :select, num_rows: 6,
rows: [{1, "test"}, {2, "test2"}, {1, "test"}, {2, "test2"}, {1, "test"},
{2, "test2"}]}}
iex(9)> Mariaex.Connection.query(p, "SELECT id, title FROM test1")
{:ok,
%Mariaex.Result{columns: ["id", "title"], command: :select, num_rows: 8,
rows: [{1, "test"}, {2, "test2"}, {1, "test"}, {2, "test2"}, {1, "test"},
{2, "test2"}, {1, "test"}, {2, "test2"}]}}
iex(10)> Mariaex.Connection.query(p, "SELECT id, title FROM test1")
{:ok,
%Mariaex.Result{columns: ["id", "title"], command: :select, num_rows: 10,
rows: [{1, "test"}, {2, "test2"}, {1, "test"}, {2, "test2"}, {1, "test"},
{2, "test2"}, {1, "test"}, {2, "test2"}, {1, "test"}, {2, "test2"}]}}
I get the following error when trying to connect to mysql 5.1.73
iex(2)> {:ok, p} = Mariaex.Connection.start_link(hostname: "127.0.0.1", username: "root", password: "", database: "cebs_production")
* (exit) exited in: GenServer.call(#PID<0.118.0>, {:connect, [hostname: "127.0.0.1", username: "root", password: "", database: "cebs_production"]}, 5000)
* (EXIT) an exception was raised:
** (MatchError) no match of right hand side value: [""]
lib/mariaex/messages.ex:85: Mariaex.Messages.decode_handshake/1
lib/mariaex/messages.ex:255: Mariaex.Messages.decode/2
lib/mariaex/connection.ex:210: Mariaex.Connection.process/2
lib/mariaex/connection.ex:191: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:593: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:659: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
14:45:19.075 [error] GenServer #PID<0.118.0> terminating
Last message: {:tcp, #Port<0.5128>, <<52, 0, 0, 0, 10, 53, 46, 49, 46, 55, 51, 0, 250, 6, 0, 0, 112, 87, 66, 37, 47, 93, 105, 119, 0, 255, 247, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 86, 37, 85, 93, ...>>}
State: %{backend_key: nil, opts: [hostname: "127.0.0.1", username: "root", password: "***", database: "cebs_production"], parameter_types: [], parameters: %{}, queue: {[{{:connect, [hostname: "127.0.0.1", username: "root", password: "**", database: "cebs_production"]}, {#PID<0.105.0>, #Reference<0.0.0.575>}}], []}, rows: [], seqnum: 0, sock: {Mariaex.Connection.Tcp, #Port<0.5128>}, sock_mod: Mariaex.Connection.Tcp, state: :handshake, state_data: nil, statement: nil, statement_id: nil, substate: nil, tail: "", types: :types_removed}
* (exit) an exception was raised:
** (MatchError) no match of right hand side value: [""]
lib/mariaex/messages.ex:85: Mariaex.Messages.decode_handshake/1
lib/mariaex/messages.ex:255: Mariaex.Messages.decode/2
lib/mariaex/connection.ex:210: Mariaex.Connection.process/2
lib/mariaex/connection.ex:191: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:593: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:659: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
(elixir) lib/gen_server.ex:356: GenServer.call/3
lib/mariaex/connection.ex:63: Mariaex.Connection.start_link/1
iex(2)>
If the MySQL protocol supports it, we can cancel long running queries if we know the caller died. This has been added to the TDS driver and will be available in the postgrex one too. Here is a reference implementation:
Currently Mariaex doesn't support following field types:
The following insert is failing. However, if I remove the first field, it passes.
elixir
iex(7)> Conn.query p, "INSERT INTO messages (address_position
, created_at
, from
, message_type
, messageable_id
, messageable_type
, queue_position
, receiver_id
, receiver_type
, retry_attempt
, sender_id
, sender_type
, status
, to
, topic
, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [nil, {{2015, 3, 21}, {23, 3, 41, 0}}, nil, "Call", 94, "MultipartyNotification", nil, 1514, "Contact", nil, 1514, "Contact", "initial", "UCX/300@300", "Lab", {{2015, 3, 21}, {23, 3, 41, 0}}]
[warn] connection.query message: {:query, "INSERT INTO messages (address_position
, created_at
, from
, message_type
, messageable_id
, messageable_type
, queue_position
, receiver_id
, receiver_type
, retry_attempt
, sender_id
, sender_type
, status
, to
, topic
, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [nil, {{2015, 3, 21}, {23, 3, 41, 0}}, nil, "Call", 94, "MultipartyNotification", nil, 1514, "Contact", nil, 1514, "Contact", "initial", "UCX/300@300", "Lab", {{2015, 3, 21}, {23, 3, 41, 0}}], []}
{:error,
%Mariaex.Error{mariadb: %{code: 1048,
message: "Column 'created_at' cannot be null"}, message: nil}}
iex(8)> Conn.query p, "INSERT INTO messages (created_at
, from
, message_type
, messageable_id
, messageable_type
, queue_position
, receiver_id
, receiver_type
, retry_attempt
, sender_id
, sender_type
, status
, to
, topic
, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [{{2015, 3, 21}, {23, 3, 41, 0}}, nil, "Call", 94, "MultipartyNotification", nil, 1514, "Contact", nil, 1514, "Contact", "initial", "UCX/300@300", "Lab", {{2015, 3, 21}, {23, 3, 41, 0}}]
[warn] connection.query message: {:query, "INSERT INTO messages (created_at
, from
, message_type
, messageable_id
, messageable_type
, queue_position
, receiver_id
, receiver_type
, retry_attempt
, sender_id
, sender_type
, status
, to
, topic
, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [{{2015, 3, 21}, {23, 3, 41, 0}}, nil, "Call", 94, "MultipartyNotification", nil, 1514, "Contact", nil, 1514, "Contact", "initial", "UCX/300@300", "Lab", {{2015, 3, 21}, {23, 3, 41, 0}}], []}
{:ok,
%Mariaex.Result{columns: [], command: :insert, last_insert_id: 13954,
num_rows: 1, rows: nil}}
iex(9)>
Here is the schema for the table:
mysql> describe messages;
+------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| topic | varchar(255) | YES | | NULL | |
| status | varchar(255) | YES | | initial | |
| to | varchar(255) | YES | | NULL | |
| from | varchar(255) | YES | | NULL | |
| message_type | varchar(255) | YES | | NULL | |
| messageable_type | varchar(255) | YES | | NULL | |
| messageable_id | int(11) | YES | | NULL | |
| sender_type | varchar(255) | YES | | NULL | |
| sender_id | int(11) | YES | | NULL | |
| receiver_type | varchar(255) | YES | | NULL | |
| receiver_id | int(11) | YES | | NULL | |
| created_at | datetime | NO | | NULL | |
| updated_at | datetime | NO | | NULL | |
| address_position | int(11) | YES | | 0 | |
| retry_attempt | int(11) | YES | | 0 | |
| queue_position | int(11) | YES | | NULL | |
+------------------+--------------+------+-----+---------+----------------+
17 rows in set (0.00 sec)
Hi, can you tag 0.5.0? It is quite useful to get versioned tarballs :)
Connection cannot be established, when secure auth is turned off at the server. It fails with this error:
** (EXIT) an exception was raised:
** (MatchError) no match of right hand side value: <<254>>
(mariaex) lib/mariaex/messages.ex:118: Mariaex.Messages.decode_eof_resp/1
(mariaex) lib/mariaex/messages.ex:254: Mariaex.Messages.decode/2
(mariaex) lib/mariaex/connection.ex:251: Mariaex.Connection.process/2
(mariaex) lib/mariaex/connection.ex:222: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:593: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:659: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
I checked on the server for the secure auth setting:
> show variables like "%auth%";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| secure_auth | OFF |
+---------------+-------+
In this case even mysql
client cli needs --skip-secure-auth
without which it gets the following error:
ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)
Can we add the support for this ?
Found reference on how to fix this here - https://www.safaribooksonline.com/library/view/understanding-mysql-internals/0596009577/ch04s04.html
The coder does a lot of code generation and it expects particular callbacks to be implemented but there is no documented in both the API and callbacks to be implemented, making it very hard to debug or change the coder messages.
Hi!
It doesn't seem that Mariaex supports parameters on queries such as documented here: https://github.com/liveforeverx/mariaex/blob/master/lib/mariaex/connection.ex#L112
iex(1)> {:ok, p} = Mariaex.Connection.start_link(username: "root", database: "ecto_test")
{:ok, #PID<0.95.0>}
iex(2)> Mariaex.Connection.query(p, "CREATE TABLE test_1 (id serial, title text)")
:ok
iex(3)> Mariaex.Connection.query(p, "SELECT id FROM test_1 WHERE title like $1", ["%my%"])
{:error,
%Mariaex.Error{mariadb: %{code: 1054,
message: "Unknown column '$1' in 'where clause'"}, message: nil}}
Is there anything we can do to help fixing it? Thanks :)
When reading a boolean value from the database which is represented as a BIT(1) in the MySQL server (version 5.5.29) The following error is displayed:
** (FunctionClauseError) no function clause matching in Mariaex.Messages.handle_decode_bin_rows/2
stacktrace:
(mariaex) lib/mariaex/messages.ex:292: Mariaex.Messages.handle_decode_bin_rows({:bit, :field_type_bit}, <<1, 0, 2, 45, 49, 2, 45, 49, 2, 45, 49, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>)
(mariaex) lib/mariaex/messages.ex:288: Mariaex.Messages.decode_bin_rows/4
(mariaex) lib/mariaex/connection.ex:153: anonymous fn/4 in Mariaex.Connection.decode/2
(elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
(mariaex) lib/mariaex/connection.ex:153: Mariaex.Connection.decode/2
(mariaex) lib/mariaex/connection.ex:128: Mariaex.Connection.query/4
(ecto) lib/ecto/adapters/mysql/connection.ex:25: Ecto.Adapters.MySQL.Connection.query/4
(stdlib) timer.erl:197: :timer.tc/3
(ecto) lib/ecto/adapters/sql.ex:262: Ecto.Adapters.SQL.query/7
(ecto) lib/ecto/pool.ex:159: Ecto.Pool.do_run/4
(ecto) lib/ecto/adapters/sql.ex:247: Ecto.Adapters.SQL.query/6
(ecto) lib/ecto/adapters/sql.ex:225: Ecto.Adapters.SQL.query/5
(ecto) lib/ecto/adapters/sql.ex:183: Ecto.Adapters.SQL.query!/5
(ecto) lib/ecto/adapters/sql.ex:481: Ecto.Adapters.SQL.execute/6
(ecto) lib/ecto/repo/queryable.ex:95: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:15: Ecto.Repo.Queryable.all/4
(ecto) lib/ecto/repo/queryable.ex:44: Ecto.Repo.Queryable.one/4
This is a legacy database and changing the field to a TINYINT(1), which works, will be difficult (impractical).
Versions from mix.lock:
mariaex, "0.6.2"
phoenix, "1.1.2"
ecto, "1.1.1"
phoenix_ecto, "2.0.0"
related to elixir-ecto/ecto#1094
** (EXIT from #PID<0.50.0>) exited in: GenServer.call(#PID<0.54.0>, {:query, "show full processlist\n", [], []}, 5000)
** (EXIT) an exception was raised:
** (CaseClauseError) no case clause matching: :query_send
lib/mariaex/protocol.ex:56: Mariaex.Protocol.dispatch/2
lib/mariaex/connection.ex:222: Mariaex.Connection.process/2
lib/mariaex/connection.ex:195: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:593: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:659: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
Should this be happening?
Thanks for the quick turnaround on the last problem. Now I'm getting an error on password. I tried it both with providing password in the start_link and setting password in the env.
I get the following error when trying to connect to mysql 5.1.73
iex(1)> {:ok, p} = Mariaex.Connection.start_link(username: "root", database: "cebs_production")
** (exit) exited in: GenServer.call(#PID<0.113.0>, {:connect, [hostname: "localhost", password: "password", username: "root", database: "cebs_production"]}, 5000)
** (EXIT) an exception was raised:
** (FunctionClauseError) no function clause matching in Mariaex.Protocol.password/3
lib/mariaex/protocol.ex:111: Mariaex.Protocol.password("", "password", "2Ou%RNpkF[v_Z&J'~jw:")
lib/mariaex/protocol.ex:35: Mariaex.Protocol.dispatch/2
lib/mariaex/connection.ex:215: Mariaex.Connection.process/2
lib/mariaex/connection.ex:192: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:593: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:659: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
(elixir) lib/gen_server.ex:356: GenServer.call/3
lib/mariaex/connection.ex:63: Mariaex.Connection.start_link/1
iex(1)>
17:30:38.893 [error] GenServer #PID<0.113.0> terminating
Last message: {:tcp, #Port<0.5026>, <<52, 0, 0, 0, 10, 53, 46, 49, 46, 55, 51, 0, 14, 0, 0, 0, 50, 79, 117, 37, 82, 78, 112, 107, 0, 255, 247, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 91, 118, 95, 90, ...>>}
State: %{backend_key: nil, opts: [hostname: "localhost", password: "password", username: "root", database: "cebs_production"], parameter_types: [], parameters: %{}, queue: {[{{:connect, [hostname: "localhost", password: "password", username: "root", database: "cebs_production"]}, {#PID<0.111.0>, #Reference<0.0.0.616>}}], []}, rows: [], seqnum: 0, sock: {Mariaex.Connection.Tcp, #Port<0.5026>}, sock_mod: Mariaex.Connection.Tcp, state: :handshake, state_data: nil, statement: nil, statement_id: nil, substate: nil, tail: "", types: :types_removed}
** (exit) an exception was raised:
** (FunctionClauseError) no function clause matching in Mariaex.Protocol.password/3
lib/mariaex/protocol.ex:111: Mariaex.Protocol.password("", "password", "2Ou%RNpkF[v_Z&J'~jw:")
lib/mariaex/protocol.ex:35: Mariaex.Protocol.dispatch/2
lib/mariaex/connection.ex:215: Mariaex.Connection.process/2
lib/mariaex/connection.ex:192: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:593: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:659: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
postgrex supports decimal, mariaex should support it too.
If the goal is to mimic Postgrex, we no longer have transactions in Postgrex itself, so we can remove from Mariaex. :)
** (exit) exited in: GenServer.call(#PID<0.269.0>, {:query, "SELECT\n a, b\nFROM\n test\nWHERE\n id = 1", [], [timeout: 5000]}, 5000)
** (EXIT) an exception was raised:
** (CaseClauseError) no case clause matching: :query_send
(mariaex) lib/mariaex/protocol.ex:55: Mariaex.Protocol.dispatch/2
(mariaex) lib/mariaex/connection.ex:219: Mariaex.Connection.process/2
(mariaex) lib/mariaex/connection.ex:192: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:593: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:659: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
mariaex does not decode NULL properly
I have a column of TINYINT(4) with default value of 10 and when I select this column with mariaex it throws the error
** (exit) exited in: GenServer.call(#PID<0.135.0>, {:query, "SELECT L0.`weight` FROM `Test` AS L0 WHERE (L0.`id` = 1)", [], [timeout: 5000]}, 5000)
** (EXIT) an exception was raised:
** (CaseClauseError) no case clause matching: 10
(mariaex) lib/mariaex/messages.ex:303: Mariaex.Messages.parse_boolean_packet/1
(mariaex) lib/mariaex/messages.ex:281: Mariaex.Messages.decode_bin_rows/4
(mariaex) lib/mariaex/protocol.ex:96: Mariaex.Protocol.dispatch/2
(mariaex) lib/mariaex/connection.ex:219: Mariaex.Connection.process/2
(mariaex) lib/mariaex/connection.ex:192: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:593: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:659: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
(elixir) lib/gen_server.ex:356: GenServer.call/3
(ecto) lib/ecto/adapters/mysql/connection.ex:31: Ecto.Adapters.MySQL.Connection.query/4
(ecto) lib/ecto/adapters/sql/worker.ex:24: Ecto.Adapters.SQL.Worker.query!/4
(ecto) lib/ecto/adapters/sql.ex:187: Ecto.Adapters.SQL.use_worker/3
(person) lib/person.ex:2: Person.Repo.log/2
(ecto) lib/ecto/adapters/sql.ex:381: Ecto.Adapters.SQL.all/5
(ecto) lib/ecto/repo/queryable.ex:20: Ecto.Repo.Queryable.all/4
Because in messages.ex it's going to the below line but it should be an integer not a :boolean
defp handle_decode_bin_rows({:boolean, :field_type_tiny}, packet), do: parse_boolean_packet(packet)
I am using ecto with the mariaex adapter and when I run this query
SELECT L0.`dialeraddeddate` FROM `Test` AS L0 WHERE (L0.`id` = 1)
I get the following error:
** (EXIT) an exception was raised:
** (MatchError) no match of right hand side value: <<0>>
(mariaex) lib/mariaex/messages.ex:336: Mariaex.Messages.parse_date_packet/1
(mariaex) lib/mariaex/messages.ex:281: Mariaex.Messages.decode_bin_rows/4
(mariaex) lib/mariaex/protocol.ex:96: Mariaex.Protocol.dispatch/2
(mariaex) lib/mariaex/connection.ex:219: Mariaex.Connection.process/2
(mariaex) lib/mariaex/connection.ex:192: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:593: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:659: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
(elixir) lib/gen_server.ex:356: GenServer.call/3
(ecto) lib/ecto/adapters/mysql/connection.ex:31: Ecto.Adapters.MySQL.Connection.query/4
(ecto) lib/ecto/adapters/sql/worker.ex:24: Ecto.Adapters.SQL.Worker.query!/4
(ecto) lib/ecto/adapters/sql.ex:187: Ecto.Adapters.SQL.use_worker/3
(person) lib/person.ex:2: Person.Repo.log/2
(ecto) lib/ecto/adapters/sql.ex:381: Ecto.Adapters.SQL.all/5
(ecto) lib/ecto/repo/queryable.ex:20: Ecto.Repo.Queryable.all/4
The column is a MySQL date type set to be not null with a default value of 0000-00-00. Somehow the packet is getting a value of <<0>> I'm just not sure how.
I have many queries with Mariaex and got this error from mysql
Can't create more than max_prepared_stmt_count statements
With a bit of research if found that this may be because something is leaving prepared statements open, is that Mariaex?
refs: elixir-ecto/ecto#881
We'll need async queries in MariaEx so we can do parallel preloads in Ecto. I'll submit a PR on this within the next few days. Hope that's okay @liveforeverx :)
I was testing out Mariaex and it seems it is getting hung somewhere.
Debugging output is here:
http://tjheeta.github.io/2015/05/30/profiling-debugging-elixir-mariaex.html
DDLs would still execute, but all select statements would timeout
Can we Have the LICENSE in a separat File please
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.