fix(mysql): support IF EXISTS/IF NOT EXISTS in trigger/revoke syntax#60
Merged
fix(mysql): support IF EXISTS/IF NOT EXISTS in trigger/revoke syntax#60
Conversation
rebelice
approved these changes
Feb 27, 2026
There was a problem hiding this comment.
Pull request overview
This PR enhances the MySQL parser to support additional conditional and error-handling syntax in DDL statements, specifically adding support for IF EXISTS and IF NOT EXISTS clauses in REVOKE and CREATE TRIGGER statements, as well as the IGNORE UNKNOWN USER clause in REVOKE statements.
Changes:
- Added
IF EXISTSsupport to REVOKE statements - Added
IF NOT EXISTSsupport to CREATE TRIGGER statements - Added
IGNORE UNKNOWN USERtrailing clause support to REVOKE statements
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| mysql/MySQLParser.g4 | Updated grammar rules to add optional ifNotExists to createTrigger, optional ifExists and ignoreUnknownUser to revoke, and defined new ignoreUnknownUser rule |
| mysql/mysqlparser_visitor.go | Added VisitIgnoreUnknownUser method to visitor interface (auto-generated) |
| mysql/mysqlparser_listener.go | Added EnterIgnoreUnknownUser and ExitIgnoreUnknownUser methods to listener interface (auto-generated) |
| mysql/mysqlparser_base_visitor.go | Implemented VisitIgnoreUnknownUser method in base visitor (auto-generated) |
| mysql/mysqlparser_base_listener.go | Implemented EnterIgnoreUnknownUser and ExitIgnoreUnknownUser methods in base listener (auto-generated) |
| mysql/examples/revoke_if_exists_select.sql | Added test example for REVOKE IF EXISTS syntax |
| mysql/examples/revoke_if_exists_ignore_unknown_user.sql | Added test example for REVOKE IF EXISTS with IGNORE UNKNOWN USER |
| mysql/examples/create_trigger_if_not_exists.sql | Added test example for CREATE TRIGGER IF NOT EXISTS syntax |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
CREATE TRIGGER IF NOT EXISTSREVOKE IF EXISTS ...IGNORE UNKNOWN USERinREVOKETesting