-
Notifications
You must be signed in to change notification settings - Fork 9
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
MySQL support (DELIMITER) #89
Comments
This could be difficult because the Peggy parser can't scan forward to a semi-colon if the point of Delimiter is to provide an alternate to the semi-colon. For the opening of the block, how about just treating About the termination of the block, like where
That will skip anything that is invalid up to the next terminator. This will allow the parser to process any .sql file in any dialect, simply ignoring whatever it doesn't understand and allowing it to terminate correctly without the PeggySyntaxError here. I have zero experience with Peggy but that syntax seems to leave open the idea that a terminating delimiter like Anything good in there? |
As you're hinting, this approach is only useful for skipping the parsing of all the code that's using a different delimiter. I think it's better applied to the general ignoring of unsupported syntax. My thinking about the handling of So that in first pass one would parse a stream of client commands:
And then the SQL-commands would be fed to the actual SQL parser for further parsing. This process would mimic how the mysql client parses the commands and server parses the pure SQL statements. This first phase of parsing might need to be done with something different than Peggy to be able to handle this changing delimiter character. I'm not 100% confident, but I have a strong feeling that this changing in the meaning of the delimiter character changes this into a context-dependent grammar (in contrast to context-free grammars that ordinary parser-generators tackle). Thankfully the syntax is pretty simple, so hand-rolling a parser for that shouldn't be that hard. |
Support the DELIMITER command used by the mysql client, as in:
There are many other commands that the
mysql
client supports, butdelimiter
is one of the most frequently used ones. Unfortunately it's also the trickiest to support.The text was updated successfully, but these errors were encountered: