-
Notifications
You must be signed in to change notification settings - Fork 869
MySQL support #150
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
Comments
There's a high-quality open source MySQL parser included in the vitess project (https://godoc.org/github.com/youtube/vitess/go/vt/sqlparser#BuildParsedQuery). I'll take a look into using that. |
We actually are looking at using this for vitess in particular. Super excited you are at least looking at it. |
TiDB also has a pretty good standalone MySQL parser worth taking a look at: https://github.com/pingcap/parser I've been using sqlc in a hobby project and really love it. Would love to see MySQL support so I can use it at work too. |
@kyleconroy
The status of my branch is still very rough and lacking many implementations such as
It's basically only unit tests validating that basic parsing and generation is functional. |
@jmhodges @clintberry I just merged experimental MySQL support. It's not production ready, but should work for simple queries and schema. Please try it out and report any bugs. |
Wilco! Found some. Will make separate tickets (I can bring them back here and close the ones I make if you'd like) |
So i was chatting with @jmhodges earlier, I'd like to recommend against vitess for a couple reasons, after talking through with systay (Andres) (maintainer of the vitess query/parsing code)
Meanwhile, i was poking around tidb's parser, and according to this they should be fairly complete: pingcap/tidb#11486. This seems like a happier path. I'm pretty noob to compilers and AST so I could be totally wrong too. I know @jmhodges and @jmhodges have done a ton of work around the current parser that uses Vitess, so I'm curious about your thoughts. No idea how much work would need to be redone to switch parsers. I personally am just interested in getting the best possible MySQL support so whatever gets us there is best! And I'd be happy to contribute if you think this is a good idea, I'm just a compilers noob so it might take me a while. |
Upon closer examination, this does look like a viable alternative to
Me too! I'll definitely defer to @jmhodges on the difficulty of adding features to |
After writing my first patch to sqlparser, I can see how we might have more work than doing a conversion to the tidb parser. I think it's someone to trying out the conversion is worth a shot. (As a helper, do we have any contacts working on that project?) |
I have contacts! Most of their company is based in China though and they currently are on the Chinese New Year holidays, till sometime next week. Generally, I’ve found them super receptive and helpful. |
Hello, TiDB developer here. This is a cool project! We would love to help on this issue. |
Not sure if people here are familiar with the project, but I use go-queryset which supports MySQL and is similar in that it generates type-safe Go code from definitions. But the schema is defined with go structs. For simple schemas it is probably easier to make definitions with go structs, but for more complex schemas declaring them in SQL could be a lot nicer. From a first look, sqlc appears to generate more polished high-level query code, but it may be much less extensible than what go-queryset generates. I normally write my own higher-level wrappers around go-queryset functions (for example to just return a list like the list functions in this project do rather than having to pass in an array). |
@shenli Thank you so much for commenting. I wanted to make sure we had buy-in from TiDB before we switched parsers. It sounds like both projects (vitess and TiDB) would like us to use the TiDB parser! Consider this an official sign-off on the switch.
@gregwebs sqlc is dedicated to being SQL-first. go-queryset looks cool, but I think we're set with the current direction of the project. |
Oh, one last question for you @shenli. What's the best way for us to report missing features in the pingcap MySQL parser? Open a GitHub issue? |
Great to hear. I'll get working on the conversion. |
Okay, one problem I've seen with a conversion to the TiDB parser API is that it does not allow for returning the byte locations of syntax errors and adding that functionality would break its backwards compatibility. The possible parse errors are exposed as package-level variables (e.g. |
meta: (just want to clarify that vitess didn't recommend using the tidb parser. I recommended that after chatting through some details with a vitess maintainer, and gauged that it may be more work to use the Vitess parser than to switch. Vitess would love for us to contribute to their parser and get it to be more mysql compatible. But for the moment we would be the ones doing the work to make it so and not break their existing guarantees) |
It looks to me errors are returned as |
I don't see any place that the
which is just a
|
Which is honestly odd, because I'm not sure why that's not getting a specific error type at all? (Before the I surely could be missing something, but I still don't see a good place to put this in. Maybe @cmoog is having better luck |
Bah, okay, ErrSyntax is only returned if there's zero statements in a call to So, I was wrong about the backwards incompatibility! We could expose this stuff! It looks like this error string is coming from |
Yes, please open an issue in pingcap/parser repo. |
Basically the |
@mightyguava My first pass didn't go so well. That said, I should have an update by the end of this week or early next. If I can't get something together by then, I'd be all good with handing it off to another contributor. |
Thanks for the hard work! |
At long last, I can close this issue! MySQL support will be released in version 1.6.0, which is going out in the next few days. Thanks to everyone that's worked on MySQL support. |
Love this project idea! All of my tools are built on mysql 5.x and it'd be great to have that supported.
The text was updated successfully, but these errors were encountered: