Next Mission, Pluggable SQL Parser
Lately I’ve been fairly busy tackling bugs in Drizzle that I wanted to fix before we start rolling out tarballs which should be announced by the community soon. I’ve now committed fixes for those bugs so I am going to spend the spare time I’ve gained on something else, namely making the SQL parser pluggable.
It is a known fact that most of the time spent in processing a query in MySQL and Drizzle is in the SQL parser and naturally, many people are eager to improve it. For example, take a look at this blog post by Jay on how the current parser is expensive.
When people approach me about Drizzle in Japan, most people seem to request a pluggable query parser as well, simply because they know that it can be improved. So it makes sense for Drizzle, as a project to provide a easy way to improve the damn thing without forcing the developers to study extra things like server architecture and concurrency control (though it’s nice to know these things!).
The first version is going to be very simple. Everything behind the current entry point of the SQL Parser will be modularized and pushed out from the core, leaving only the plugin hook. Ultimately, a parser module will only have to do the following:
- Check if the given SQL string is malicious
- Process/Parse the given SQL string
- Update/Populate the Session object (known as THD in MySQL)
As for the interface, I’m suspecting that it will remain the same as the mysql_parse() function :
bool sql_parse(Session *session, const char *query, const size_t query_len, const char **found_semicolon);
But I can’t say for sure at this stage of course. Also as mentioned by Brian, we ideally need a multi-stage interface that will take care of parser failure, which I’m hoping to introduce in the second version.
This task is really high in my priority queue so hopefully this entry will help pressure me into concentrating on it (I’m terrible at this since I tend to hop between OSS projects).
My goal is to get the first version done by the MySQL Conference in Santa Clara, CA in april.

