You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug][Compatibility]: GRANT ... ON TABLE <view> is silently accepted but never grants access (non-MySQL ON VIEW required) #30887
GRANT SELECT ON TABLE <db>.<view> — the MySQL form — is accepted silently but grants nothing. The user still gets 20101 do not have privilege to execute the statement. Access only works after the non-MySQL GRANT SELECT ON VIEW <db>.<view>.
MySQL (8.0/8.3) has no VIEW object type in GRANT: GRANT SELECT ON db.v TO u works for a view. So a MySQL-compatible grant script produces a silent no-op on a security-relevant statement.
Repro (fresh main@3ad9adbb4c, single-node)
createdatabaseif not exists vg;
use vg;
createtables(a intprimary key, b int);
insert into s values (1,10);
createviewvsasselect a,b from s;
create role vg_role;
grant connect on account * to vg_role;
grantselecton table vg.s to vg_role;
grantselecton table vg.vs to vg_role; -- MySQL form: accepted, no errorcreateuservg_u identified by 'Pwd123!@#' default role vg_role;
grant vg_role to vg_u;
Then, as vg_u:
set role vg_role;
selectcount(*) fromvg.s; -- works: 1 (base table privilege is effective)select*fromvg.vs; -- ERROR 20101 (HY000): internal error: do not have privilege to execute the statement
Adding the non-MySQL form fixes it immediately:
grantselecton view vg.vs to vg_role; -- as admin-- as vg_u againset role vg_role;
select*fromvg.vs; -- a b-- 1 10
Expected
Either of:
GRANT ... ON TABLE <view> should grant access to the view (MySQL behaviour), or
it should be rejected with a clear error (e.g. "object is a view, use ON VIEW"), instead of succeeding and doing nothing.
Evidence / classification
Reproduced identically on main@3ad9adbb4c and on the window base 7b911aea68 (differential run with two local builds) → pre-existing, not introduced by the recent commits.
Same user/role can read the base table in the failing state, so this is not a general privilege setup error.
Code pointers
pkg/frontend/authenticate.go:9772 and :9804 — the privilege path branches on astObjType == tree.OBJECT_TYPE_VIEW / checkPrivilegeObjectTypeAndPrivilegeLevel(..., tree.OBJECT_TYPE_VIEW, ...).
pkg/sql/parsers/dialect/mysql/mysql_sql.y:2660 vs :2676 — TABLE and VIEW map to different object types, so ON TABLE <view> records a table privilege that the view check never reads.
Related to the view-authorization work in #30799 / 6495ce9 (preserve view authorization across index joins and replacement), which is why this is routed to that author rather than left unassigned.
Activity
XuPeng-SH commentedon Oct 26, 2026
Duplicate of #30626 — merged into the consolidated privilege-enforcement tracking table in #30626. Original reproduction remains in this issue.