Added proper syntax parsing for account names, along with DROP USER #97
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR primarily implements the changes necessary for account names, which required edits in the parser itself.
DROP USER
was implemented to test the name variations, so refer to the tests inparse_test.go
for how account names work (and to see why the changes were necessary). All parser tests were validated against a MySQL 8.0 instance.In a nutshell, account names take the form
user@host
, and bothuser
andhost
must be separate strings. The parser treated@
as a standard letter, and we used regex matching in GMS and Dolt to catch "invalid" names (@@system_var
is valid butwhat@@
is invalid). My first pass was to treat the entire account name as a string and split it using a regex, however I could not get it to pass all of the parser tests. This was the only way I could make it work with all tests passing.Notes:
DROP USER '';
looks like weird syntax, but an empty name means that all names match. In this case, you can assign some dbs/tables to be available to everyone.DROP USER ``;
is valid, but failed as we returned an error on empty quoted identifiers. MySQL allows empty quoted identifiers to parse, but rejects them as invalid names depending on the query. This has been fixed.ast_permissions.go
to put all of the statements dealing with users, grants, etc. For me,ast.go
operates very slowly and occasionally hangs for a few minutes, so I'm putting my new statements in a new file for now. I doubt you'll have pushback, but if so I can merge the file back intoast.go
when I'm done.