Skip to content

Conversation

@h3n4l
Copy link
Member

@h3n4l h3n4l commented Jan 8, 2026

Summary

  • Reorder grant_statement alternatives so object_privilege is checked before role_name
  • Reorder revoke_statement alternatives so revoke_object_privileges is checked before revoke_system_privilege

This fixes an issue where keywords like DELETE, SELECT, etc. were incorrectly recognized as role_name instead of object_privilege because role_name (which matches any identifier via id_expression) appeared first in the alternatives list.

Test plan

  • Parser builds successfully with make build
  • All existing tests pass with make test

🤖 Generated with Claude Code

1. **`grant_statement` (line 2399-2406)**: Reordered the alternatives so `object_privilege` is checked first, then `system_privilege`, then `role_name`. Previously `role_name` was first, which caused keywords like `DELETE` to be incorrectly recognized as role names instead of object privileges.

2. **`revoke_statement` (line 2420-2422)**: Reordered to try `revoke_object_privileges` before `revoke_system_privilege`. This ensures that the more specific rule (with ON clause) is tried first.

The parser builds successfully and all tests pass.
Copilot AI review requested due to automatic review settings January 8, 2026 06:09
@h3n4l h3n4l enabled auto-merge (squash) January 8, 2026 06:10
@h3n4l h3n4l merged commit 5e19d5c into main Jan 8, 2026
8 of 9 checks passed
@h3n4l h3n4l deleted the vk/ab23-reorder-the-cand branch January 8, 2026 06:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a parser bug where SQL privilege keywords (like DELETE, SELECT, INSERT, UPDATE) were incorrectly being recognized as role names instead of object privileges in GRANT and REVOKE statements. The fix reorders grammar alternatives to prioritize more specific matches over general identifier matches.

  • Reordered grant_statement alternatives to check object_privilege before role_name
  • Reordered revoke_statement alternatives to check revoke_object_privileges before revoke_system_privilege

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
plsql/PlSqlParser.g4 Updated grammar rules to prioritize specific privilege keywords over general role name identifiers
plsql/plsql_parser.go Auto-generated parser code reflecting the grammar changes, including reordered interface methods, implementation methods, and state machine transitions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants