We would like to announce that Plataformatec is working on a new MySQL driver called MyXQL. Our goal is to eventually integrate it with Ecto and make it the default MySQL driver in Ecto.
Today the main driver to talk to MySQL is Mariaex. The work on Mariaex started in December/2014 and it has been an extremely important software to the community. We are very thankful to the team behind Mariaex, as it allowed many companies dependent on MySQL databases to use Elixir in production through libraries like Ecto and Phoenix.
Many things happened since Mariaex launched:
Newer MySQL versions such as v5.7 and v8.0 which introduced new authentication modes, protocol changes, new data types and more. Unfortunately, for a project like Mariaex, it means support all of those features across different versions
Mariaex development started right after Elixir v1.0. This means it often does not leverage more recent Elixir idioms, such as the
withspecial form. Elixir v1.3 also introduced the new calendar types, which would conflict with the date/time types that ships with Mariaex
When Mariaex started, Ecto was on version v0.3.0. Since then, we released Ecto v1.0 and then Ecto v2.0. In Ecto v1.0, Ecto was the one responsible for handling connection pools, transactions and much more. However, in Ecto v2.0, we moved those concerns to drivers through a common project called DBConnection. This new approach makes the drivers more efficient and more useful outside of Ecto. James Fish led this effort and covered those topics in his ElixirConf EU 2017 talk. Despite the benefits, the migration meant more code churn to existing drivers
Due to these and other factors, I personally believe the Mariaex repository grew in complexity, which complicates its maintenance. Currently there are 40 open issues in the repository and 9 open pull requests.
We have long debated how to best improve Mariaex’ codebase. After careful consideration, we have decided the best approach is to start with a clean slate, as it would be hard to untangle the complexity accumulated throughout the years. This is what led to the creation of MyXQL.
The MyXQL effort is led by Wojtek Mach and our goals are:
MyXQL will require Elixir v1.4 (almost 2 years old) and MySQL v5.7.9+, which is the first General Availability release from the 5.7 branch, released in Oct/2015. This will allow us to support many features and data types recently added to MySQL and properly map them to their equivalents in Elixir
Leverage the knowledge we have gathered by writing and contributing to Postgrex and Mariaex drivers. In practice, we want the MyXQL adapter to mirror the organization and code structure found in Postgrex and apply the lessons that have been learned in Mariaex. The plan is to reuse parts from both projects, as deemed necessary
Note that MyXQL won’t be ready in time for the upcoming Ecto v3.0. For now, developers should continue to use Mariaex and we have already sent pull requests to ensure Mariaex is compatible with Ecto 3.0. Once MyXQL is ready, we will allow developers to choose between Mariaex and MyXQL. Although the migration should be seamless for the huge majority of users, this will give developers time to move from one tool to the other. Support for Mariaex will be eventually removed from
Ecto (or, to be more precise, removed from
The current code is work in progress. If your company or job heavily depends on MySQL, consider watching the MyXQL repository to follow the on-going work as well as take part in future discussions. It is important that other community members get involved with the codebase and contribute to ensure the codebase continues to grow healthily, regardless of external factors. It is not “high-profile” work but it is an essential part of the Elixir infrastructure.
Wojtek will also write a series of articles on Plataformatec’s blog covering all of the steps to write a database driver with DBConnection. We hope the series will make the whole process more accessible and easier for others to jump into.