Repository navigation
Description
Existing issue search:
- I have searched existing issues to avoid duplicates
Branch Name: main
Commit ID: e2459cc55f4b514893e19732743460bc5f16d552 (2026-11-09)
Environment: Local single-node launch (CN+TN+LogService in one launch config), macOS arm64, freshly compiled from current main, clean catalog. Server reported via VERSION(): 8.0.30-MatrixOne-v1.3.0. Client: mysql CLI.
Actual Behavior:
Object-level privileges cannot be granted to (or revoked from) a user at all. GRANT SELECT ON TABLE db.t TO <existing_user> fails with:
ERROR 20101 (HY000): internal error: there is no role <username>
even though the user exists (verified in mo_catalog.mo_user). The MySQL host-form GRANT ... TO 'user'@'host' is rejected earlier — at the parser, with a syntax error:
ERROR 1064 (42000) ... syntax error ... near "@'localhost'"
The shared "no role" message makes operational triage worse: it claims the named principal is missing when the real state is "only role grantees are supported".
Root cause (from source): the privilege-GRANT AST models grantees as Roles []*Role only (pkg/sql/parsers/tree/grant.go, GrantPrivilege), and the grant execution path resolves every grantee through the role table (mo_catalog.mo_role, via getSqlForRoleIdOfRole / roleIdOfRoleFormat in pkg/frontend/authenticate.go around line 5326). There is no user-grantee branch. The REVOKE path has the same resolution (fails identically when a user is named). For contrast, GRANT <role> TO <user> (role-grant, GrantTypeRole) works fine — the gap is specific to granting privileges on objects to users.
Expected Behavior (MySQL semantics): GRANT SELECT ON db.t TO user_name (and TO 'user'@'host') is standard, heavily-used MySQL syntax — nearly every migration script, BI tool, and framework grant step uses it. MO accepts the bare form without error, then fails resolution with a misleading "no role" message. Either users must be supported as direct grantees of object privileges, or the parser should reject the user-grantee form explicitly ("column/user grantees not supported; grant to a role"), not with a message that asserts the user does not exist.
Steps to Reproduce (deterministic, fresh session, no prerequisites beyond sys/root):
-- 1. Create the grantee user (verify it exists)
CREATE DATABASE regr;
CREATE TABLE regr.t (id INT PRIMARY KEY);
CREATE USER gu1 IDENTIFIED BY 'G1!';
SELECT user_id, user_name FROM mo_catalog.mo_user WHERE user_name = 'gu1'; -- row exists ✔
-- 2. Attempt to grant an object privilege to the user
GRANT SELECT ON TABLE regr.t TO gu1;
-- Actual: ERROR 20101 (HY000): internal error: there is no role gu1
-- Expected: OK (MySQL-compatible direct user grant), or at minimum an explicit
-- "user grantees unsupported" error that doesn't misreport the user's existence
-- 3. Parser behavior of the canonical MySQL host form
GRANT SELECT ON TABLE regr.t TO 'gu1'@'localhost';
-- Actual: ERROR 1064 (42000): syntax error near "@'localhost'"
-- Expected: accepted (MySQL semantics) or a clear unsupported-syntax error
-- 4. Control: the same grant to a ROLE works
CREATE ROLE gr_ok;
GRANT SELECT ON TABLE regr.t TO gr_ok; -- OK ✔ (proves the object grant path itself is fine)
-- 5. REVOKE has the same one-sided behavior
REVOKE SELECT ON TABLE regr.t FROM gu1;
-- Actual: ERROR 20101 (HY000): internal error: there is no role gu1Workaround for users today: wrap every user grant two extra statements (CREATE ROLE r; GRANT ... TO r; GRANT r TO user; SET DEFAULT ROLE r TO user;), which silently breaks all straight MySQL migration scripts.
Severity: compatibility + diagnosability. No data exposure — it's a fail-closed error — but it is a top-5 friction point for any MySQL workload migration, and the error text points operators toward debugging "why is my user missing" when the user is fine.
Cross-reference: related to the column-privilege grantee gap in #32443 (GRANT SELECT(col) TO <user> fails the same way, while TO PUBLIC silently degrades to full-table). Both trace to grantee resolution treating every name as a role.
Activity
[-][Bug]: Object-level GRANT/REVOKE cannot target a user at all — fails with misleading "there is no role <user>"; MySQL user-grantee syntax also rejected by parser[/-][+][Bug]: Object-level GRANT/REVOKE cannot target a user — misreports 'there is no role <user>'[/+]