Repository navigation
Description
Branch Name
nightly main build, matrixorigin/matrixone:nightly-7b911aea-arm64 (main @ 7b911ae, 2026-10-18 nightly)
Commit ID
SELECT git_version() = 7b911aea6874
Is there an existing issue for the same bug?
- I have checked the existing issues (searched: grant database privilege / do not have privilege / GRANT UPDATE DELETE table).
Actual Behavior
Several GRANT-related behaviors diverge from MySQL 8 and block minimal-privilege service accounts (verified while provisioning a database account for Keycloak 26.x):
A. Database-level and global GRANT ALL are rejected by the parser
CREATE USER keycloak IDENTIFIED BY '...';
GRANT ALL ON `keycloak`.* TO keycloak;
-- ERROR 1064 (42000): SQL parser error: ... syntax error at line 1 column 23 near " `keycloak`.* TO keycloak"
GRANT ALL ON *.* TO keycloak;
-- ERROR 1064 (42000): SQL parser error: ... syntax error near " *.* TO keycloak"B. UPDATE/DELETE can only be granted at table/view scope
GRANT UPDATE,DELETE ON DATABASE keycloak TO kcrole;
-- ERROR 20101 (HY000): internal error: the privilege "update" can only be granted to the object type "table" or "view"C. A non-admin role is denied DELETE even on tables created by that role itself — reproducible on a clean database:
-- as root (moadmin)
CREATE DATABASE keycloak_qa;
CREATE ROLE kcrole_qa;
GRANT ALL PRIVILEGES ON DATABASE keycloak_qa TO kcrole_qa;
GRANT kcrole_qa TO keycloak;
-- as sys#keycloak#kcrole_qa (account#user#role login): import schema, e.g.
CREATE TABLE credential (USER_ID VARCHAR(36) PRIMARY KEY);
-- still as sys#keycloak#kcrole_qa:
DELETE FROM credential WHERE USER_ID = 'x';
-- ERROR 20101 (HY000): internal error: do not have privilege to execute the statement
-- even after, as root:
GRANT UPDATE,DELETE ON TABLE keycloak_qa.credential TO kcrole_qa;
-- (persisted: mo_role_privs shows update/delete/table ownership rows for kcrole_qa)
-- the same DELETE is still denied for the role login, while root can delete freely.
-- Control: on a ROOT-created table granted with
GRANT UPDATE,DELETE ON TABLE keycloak_qa.root_made TO kcrole_qa;
-- DELETE as the role login SUCCEEDS.Observed grant asymmetry: INSERT/SELECT/CREATE TABLE/DROP TABLE work for the role login on its own schema; DELETE (and by extension the whole runtime write/update pattern of JPA apps) is denied unless operating as an account administrator such as root.
For comparison, provisioning the same application account as root (moadmin) works fully — which matches how other services are deployed on a dedicated account's accountadmin user, but blocks running third-party apps as a least-privilege user inside sys.
Expected Behavior
- Accept
GRANT <privs> ON db.* [TO user]with MySQL 8 semantics (or document the divergence and provide an equivalent single statement). - Make table-scoped UPDATE/DELETE grants effective regardless of the table creator's role membership.
- Clarify whether
USE <database>intentionally requires privileges beyondGRANT ... ON ACCOUNT/database (it is currently denied for non-privileged roles while URL-scoped connections work).
Steps to Reproduce
Follow the exact statements listed in section C above (all statements and outputs captured verbatim from a single mysql 8.0 CLI session against the nightly image).
Other Environment Information
- Server:
matrixorigin/matrixone:nightly-7b911aea-arm64docker, standalone, macOS arm64 (OrbStack) - Client: mysql CLI 8.0; the same behavior was first observed behind MySQL Connector/J 9.6.0 (Keycloak 26.6.4), where Liquibase/Hibernate DML fails with
do not have privilege to execute the statement
Consolidated tracking (2026-10-27)
| Item | Original issue | Status |
|---|---|---|
| Column-level GRANT silently widened to whole-table scope (column list discarded) | #30915 | open, tracked here |
GRANT ... ON TABLE <view> silently accepted but grants nothing |
#30887 | open, tracked here |
mo_catalog.mo_role_privs.privilege_level stores placeholder template 'd.t' |
#30676 | open, tracked here |
Original reproductions remain in the linked issues (closed as duplicates of this tracking issue).
Activity
daviszhen commentedon Oct 21, 2026
Rechecked on main
04fe057bd73520cdf30754f79f66f6505060ad1fwith a real MySQL role login. The results need to be separated:ON db.* TO usersyntax andUPDATE/DELETE ON DATABASEremain unsupported; this update does not claim otherwise. MatrixOne uses role grantees and distinct DATABASE-DDL / TABLE-DML object scopes.ON TABLE db.*is supported database-wide table scope, not one grant per table.For example, an administrator can use:
Then log in as
sys#app_user#app_rolewithapp_dbselected. Omit the DATABASE-DDL grant for runtime-only users. This does not grant moadmin/accountadmin or cross-database DML.Submitted the guide and real-protocol regression in #30720 (
63e7a285f2). It passes with privilege caching on/off, retaining the same role connection across committed grants/revokes, checking cross-database/delegation rejection, and confirming denied operations leave data unchanged. No authorization checks were relaxed. This is a documented supported equivalent and regression guard, not an implementation of MySQL's full privilege model; full Keycloak startup was not tested.docs(auth): document and verify least-privilege application roles (#3…
Ariznawlll commentedon Oct 22, 2026
Additional data point for section A (same parser-gap family, third form): the table-level form without the
TABLEkeyword is also rejected, and the standard MySQL user@host grantee spelling is unrepresentable in theTOclause entirely:MySQL 8.0.45 accepts all of the first five verbatim (
GRANT SELECT ON d4perm.secret TO 'u_nobody'@'localhost'shows asGRANT SELECT ON \d4perm`.`secret` TO ...`).Two distinct consequences beyond what section A already documents:
db.tbl(no keyword) is rejected, andu_nobodyfails withthere is no role u_nobodybecause the grantee position is resolved against roles only. The working path is the two-step role indirection (CREATE ROLE r; GRANT SELECT ON TABLE d.t TO r; GRANT r TO u_nobody;), which matches the "least-privilege app accounts blocked" theme but is broader: even granting to a pre-existing user directly is impossible.Repull condition: any of
GRANT <priv> ON [TABLE] db.tbl TO user[@host]working.aqqi666 commentedon Oct 26, 2026
Verification on latest nightly (2026-10-25,
matrixorigin/matrixone:nightly-b14d67a2-arm64)Re-ran the exact original sequence from the issue body as
sys#kcprobe_user#kcprobe_role(user = role member only, no account-admin):Gap C no longer reproduces ✅ (matches daviszhen's recheck on
04fe057b). The same sequence failed withERROR 20101on the 2026-10-18 nightly (nightly-7b911aea-arm64), so the fix landed between the two nightlies [not pinpointed to a specific PR].Supplementary probes on the same nightly
GRANT SELECT ON kcprobe_db.* TO kcprobe_roleERROR 1064near" kcprobe_db.* TO kcprobe_role"(gap A unchanged)GRANT SELECT,UPDATE,DELETE ON TABLE kcprobe_db.* TO kcprobe_rolemo_role_privsshowsselect/update/deleterows withobj_type=table, obj_id=<database id>— this is the one-statement database-wide table-scope grant form (gap B has a working equivalent)USE kcprobe_dbas role loginERROR 20101(do not have privilege to execute the statement);GRANT CONNECT ...to a role is rejected by the parser in both forms tried (GRANT CONNECT ON ACCOUNT TO role→ 1064 nearTO;GRANT CONNECT TO role→ 1064 nearTO). Connecting with the database on the command line / in the JDBC URL works fine, so this is CLI-ergonomics onlyNet for the Keycloak-style service-account provisioning pattern on current main:
Remaining open gaps in this issue: A (MySQL
ON db.*/*.*parser form),USEstatement CONNECT semantics for role logins.Ariznawlll commentedon Oct 29, 2026
Additional working syntax intelligence on main
c6683bd2f5(2026-10-29) for anyone fixing the parser gap in item A — three things an app port needs to know, none of which is discoverable from the 1064 message:The accepted object syntax requires an object-type keyword:
GRANT SELECT ON TABLE <db>.<obj> TO <role>andGRANT CONNECT ON ACCOUNT * TO <role>parse and record rows in mo_catalog.mo_role_privs. The MySQL-shapeGRANT ALL ON db.* TO u/GRANT SELECT ON db.tbl TO uvariants all die with 1064.TO <user>is not valid either — the grantee must be a role: even with the TABLE keyword,GRANT SELECT ON TABLE vdst.* TO someuserfails withERROR 20101: there is no role someuser. The working path isCREATE ROLE r; GRANT ... TO r; GRANT r TO someuser;— meaning every least-privilege migration (Keycloak, legacy app provisioning scripts) needs a 3-step rewrite, not a keyword fix.A role is not auto-activated for its grantee: after
GRANT r TO someuser, a fresh session of that user still hasCURRENT_ROLE()=publicand none of r's privileges apply until the user runsSET ROLE r(accepted only with autocommit — under an open transaction it dies withERROR 20101: administrative command is unsupported in transactions). So even the 3-step port ends in a runtime permission failure unless the app also sets the role per session — unlike MySQL where granting a privilege to a user (or their default role) is enough.Point 3 compounds the report: even after correcting GRANT syntax in application bootstrap code, the privileged account still fails at runtime because the role is dormant. Bundling an auto-activation story (MySQL-style DEFAULT ROLE semantics; see also the SET DEFAULT ROLE silent-no-op history) into this fix would make the least-privilege path actually usable end to end.
XuPeng-SH commentedon Nov 29, 2026
Consolidated duplicate #30874 into item A (database/global GRANT parsing).
Additional independent evidence retained:
3ad9adbb4c,GRANT SELECT ON qa2.* TO qa_u1returnsERROR 1064nearqa2.*.GRANT SELECT ON TABLE qa2.* TO qa_u1is accepted, isolating the optionalTABLEkeyword parser gap.7b911aea68base, so this is not a recent regression.Keep optional-
TABLEparsing fordb.*/*.*and the ordinary explicit-TABLEcontrol as independent acceptance cases. User-grantee semantics remain separately tracked and are not collapsed into this parser item.Administrative consolidation only; the bug remains open and unverified.