Skip to content

Fix MySQL parsing of GRANT, REVOKE, and CREATE VIEW#1538

Merged
iffyio merged 22 commits into
apache:mainfrom
mvzink:mysql-users
Jan 9, 2025
Merged

Fix MySQL parsing of GRANT, REVOKE, and CREATE VIEW#1538
iffyio merged 22 commits into
apache:mainfrom
mvzink:mysql-users

Conversation

@mvzink

@mvzink mvzink commented Nov 20, 2024

Copy link
Copy Markdown
Contributor
  • Support MySQL style 'user'@'host' syntax.
  • Support wildcards on grant objects: *.*.
  • Make CASCADE/RESTRICT in revoke statements optional since MySQL doesn't accept it.
  • Support optional MySQL parameters for create view: algorithm, definer (requires user@host syntax), and security context.

This is needed for parsing MySQL-style `'user'@'host'` grantee syntax.

As far as I can tell, no dialect allows quotes or backticks as part of
an identifier (regardless of whether it starts with `@`) without other
specific syntax (e.g. nested in another quote style and thus not
starting with `@`), so this shouldn't adversely affect non-MySQL
dialects.
Introduces a new `Grantee` enum to differentiate bare identifiers (every
other database: `root`) from user/host pairs (MySQL: `'root'@'%'`).

While we're here, make the CASCADE/RESTRICT syntax for REVOKE optional
since Postgres doesn't require it and MySQL doesn't allow it.

Add support for MySQL wildcard object syntax: `GRANT ALL ON *.* ...`
@mvzink

mvzink commented Nov 20, 2024

Copy link
Copy Markdown
Contributor Author

Would appreciate feedback on the naming the MySQL-specific params types (would a generic/non-branded name be better?) and the API change for wildcard support (didn't want to change all 107 parse_object_name callsites for an option that is so niche, but happy to be convinced otherwise).

Comment thread tests/sqlparser_mysql.rs
Comment thread tests/sqlparser_mysql.rs
Comment thread src/parser/mod.rs Outdated
Comment thread src/parser/mod.rs Outdated
Comment thread src/tokenizer.rs
Comment thread src/parser/mod.rs Outdated
Comment thread src/parser/mod.rs Outdated
Comment thread tests/sqlparser_mysql.rs
Comment thread tests/sqlparser_mysql.rs Outdated
Comment thread src/ast/mod.rs Outdated
Comment thread src/tokenizer.rs
Comment thread src/ast/mod.rs Outdated

@iffyio iffyio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mvzink! Left some minor comments I think with those and resolving conflicts on the branch this looks good to me!

Comment thread src/parser/mod.rs Outdated
Comment thread src/parser/mod.rs Outdated
Comment thread src/parser/mod.rs Outdated
Comment thread src/parser/mod.rs Outdated

@iffyio iffyio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @mvzink
cc @alamb

@iffyio

iffyio commented Dec 27, 2024

Copy link
Copy Markdown
Contributor

@mvzink it seems there's a couple conflicts in the branch could you take a look when you have some time?

@iffyio

iffyio commented Jan 8, 2025

Copy link
Copy Markdown
Contributor

Hi @mvzink sorry I just noticed this was since rebased, could I ask for another rebase and if you could just ping me when its done I'll prio merging it to avoid further conflicts 🙏

@mvzink

mvzink commented Jan 8, 2025

Copy link
Copy Markdown
Contributor Author

@iffyio resolved, but there were some significant changes to grantee parsing by @yoavcloud so maybe he should take a look too.

Comment thread src/parser/mod.rs Outdated
@mvzink

mvzink commented Jan 9, 2025

Copy link
Copy Markdown
Contributor Author

@iffyio I think this is good to go.

@iffyio iffyio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @mvzink!
cc @alamb

@iffyio iffyio merged commit 4fdf5e1 into apache:main Jan 9, 2025
@mvzink mvzink deleted the mysql-users branch January 10, 2025 17:21
ayman-sigma pushed a commit to sigmacomputing/sqlparser-rs that referenced this pull request Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants