Skip to content

[Bug]: GRANT/REVOKE reject MySQL-standard bare db.table syntax #31804

Closed

Description

@Ariznawlll

Description

GRANT <priv> ON db.table TO ... — the bare object reference without the TABLE keyword, which is the standard MySQL spelling used by every permission-management tool — fails with a parser error on MatrixOne. The parser only accepts the object-type keyword form:

GRANT SELECT ON TABLE agx.m TO r1;   -- OK (MO accepts)
GRANT SELECT ON agx.m    TO r1;      -- ERROR 1064: syntax error near " agx.m TO r1"
GRANT SELECT ON agx.*    TO r1;      -- 1064 (bare db.*)
GRANT SELECT ON *.*      TO r1;      -- 1064 near " *.* TO r1"  ← even global level!
GRANT SELECT ON vw       TO r1;      -- 1064 (bare unqualified)

MySQL 8.0 accepts all of these — object_type (TABLE|FUNCTION|PROCEDURE) is documented as optional in the GRANT grammar (GRANT priv ON [object_type] priv_level TO ...); the bare db.table, db.*, and *.* levels are the dominant spellings in the wild:

  • mysqldump --all-databases permission re-import scripts
  • Ansible/Salt/Terraform privilege modules (default templates use bare forms)
  • Liquibase/Flyway permission changelogs
  • DBA runbooks (every MySQL tutorial teaches GRANT SELECT ON mydb.* TO u)

Failure shape is a parser error, so none of the above degrade gracefully: the whole provisioning pipeline stops at line one. MO's own privilege model supports the semantics fine (with the keyword it works, including the object-type × privilege validity check — GRANT SELECT ON account * correctly rejects with "privilege select does not exist on object_type account"), so this is purely the grammar missing the optional-object_type form.

Also observed in the same session for completeness: the reciprocal REVOKE presumably shares the grammar shape (not independently verified in this report); the fix should cover both.

Impact

  • MySQL-standard provisioning toolchains fail wholesale against MO at the first GRANT, with a confusing syntax error that reads like a typo rather than a dialect difference.
  • Tutorials/StackOverflow-copy DBA flows fail verbatim, hurting time-to-first-success for new users.

Expected behavior

Parse GRANT <priv_list> ON <priv_level> TO ... with priv_level ∈ { *.*, db.*, db.table, table } and no object-type keyword (defaulting object_type to TABLE, per MySQL), plus the existing keyword forms. Same for REVOKE.

Reproduction

CREATE ROLE r1;
GRANT SELECT ON some_db.some_table TO r1;   -- 1064 on MO, OK on MySQL 8
GRANT SELECT ON some_db.* TO r1;            -- 1064
GRANT SELECT ON *.* TO r1;                  -- 1064

Verified on main c6683bd2f5 (2026-10-30 locally built, fresh bootstrap), pymysql + mysql CLI (rule out client encoding).

Activity

  1. added
    kind/bug
    on Oct 30, 2026
  2. added this to the MO-202610 milestone on Oct 30, 2026
  3. added theissue type on Oct 30, 2026
  4. Ariznawlll commented on Nov 2, 2026

    @Ariznawlll
    CollaboratorAuthor

    Retest on main@HEAD (c6683bd, built 2026-11-02): still present — all four bare forms still 1064: GRANT ALL ON db.* TO u, GRANT SELECT ON db.tbl TO u, GRANT ALL ON *.* TO u, REVOKE ALL ON db.* FROM u. The ON TABLE ... keyword remains mandatory.

  5. assigned and unassigned on Nov 4, 2026
  6. added a commit that references this issue on Nov 5, 2026
    80224b0
  7. XuPeng-SH commented on Nov 5, 2026

    @XuPeng-SH
    Contributor

    QA 交接:GRANT/REVOKE 现可省略 TABLE,构造与显式 TABLE 相同的表权限 AST,覆盖 .、db.*、db.table 和未限定表名;保留原有权限级别、选项及授权拒绝。旧 c6683bd 上的 1064 复测早于本次修复,不当作新版本反例。

    PR #32196 已于 2026-11-05 02:03:08 UTC 合入 main,merge SHA 80224b0314c6008ecb4de82d1e37b019d5e355df,最终 head 5cfcb401ac173cbe1380abdf2b83b2afb51c53b5。完整 issue 和 PR 讨论未见当前适用的已验证反例或未完成开发 follow-up,可交 QA。

    验证证据与限制:

    • 审查针对 4311fe84d50a509b1b202e0eebf530289c4202b6:规范生成结果字节一致,既有 796 个 token 常量和 2,049 个 action body 保留;两个 parser 包及新增 16 个顶层测试通过。复审未新跑在线 SQL/BVT 或 planner/explain。
    • 作者报告较早 ab5 基础的匹配源码 CGO 构建通过 SERIAL 28/28、bare grants 56/56,以及 grant_privs_role 226/226;相关语法、真实 DDL/catalog、授权拒绝和清理结果保留其原版本身份。作者详细原始日志未提供,不能改称最终 head 服务实测。
    • 最终 head 相比已审查版本,11 个交付文件均未变化,最终 head 与合并提交的完整代码树一致。最终 CI Required 失败原因为 matrixone-ci: cancelled,共享构建通过;清理任务明确在合并后请求取消该运行。未完成的 UT/SCA/BVT 不宣称通过,也没有据此确认产品缺陷。较早审查版本 CI 的通过保留旧 head 身份。
    • 本轮没有本地重跑产品测试;交接不代表验收通过,也不代表多 CN 或部署验证完成。

    建议 QA 将四类 bare 对象写法与显式 TABLE 对照,检查 GRANT 后的实际访问、REVOKE 后拒绝、合法选项和非授权用户拒绝,以及原 account 对象权限错误仍然保留。两条旧预期仅由语法拒绝改为支持,不应削弱授权检查。角色授权、proxy grant、WITH ADMIN OPTION 不属于本次改动范围。

    交由 @Ariznawlll 继续验证。

  8. slyunnn commented on Nov 10, 2026

    @slyunnn

    Regression and extended verification for #31804 (2026-11-10)

    Verification Environment

    • Frozen MatrixOne origin/main at test start, 2f6fcc772175d0c0e80ad97aac6d44360c513347, fix(backup): verify empty provider-copied objects without EOF failure (#32434). Fresh Go 1.27.1 macOS arm64 binary, verified native-library provenance and SQL git_version() agreed.
    • Complete native topology 2 CN / 1 TN / 1 Log service / Proxy, with both CNs co-located in the launcher process. Proxy 127.0.0.1:6001, CN1 127.0.0.1:16001 and CN2 127.0.0.1:16002 were connectable and each executed actual regression scenarios.
    • PyMySQL TCP COM_QUERY with real restricted-user sessions, and JDBC BVT. The original global privilege-cache value was captured and restored.

    What Was Covered

    • OK — Bare db.table, db.*, *.* and unqualified table forms through every endpoint. Compared each with explicit ON TABLE using real grant, access and revoke operations on the same live user connection.
    • OK — Table/database/global privilege boundaries, neighboring objects and another database. Bare and explicit forms revoked each other's grants successfully.
    • OK — Multiple privileges and WITH GRANT OPTION, actual INSERT / UPDATE, followed by explicit-form revoke and renewed access denial.
    • OK — Unauthorized-user grants, nonexistent-role rejection, no partial authorization, invalid SELECT ON ACCOUNT * rejection and immediate SELECT 1 after denied operations. Error 20101 remained an authorization/privilege rejection.
    • OK — Bare-grant BVT passed 56/56 and the broader permission-control BVT passed 226/226 statements per endpoint. All 23 selected parser test/subtest results passed normal/race. Both complete parser packages passed.
    • Not covered — External Ansible/Terraform/Liquibase applications or unrelated role/proxy-grant features.

    Findings

    Fix 80224b0314c6008ecb4de82d1e37b019d5e355df, fix(parser): support SERIAL columns and bare table grants, makes the object-type keyword optional while constructing the same table-privilege AST and retaining real authorization checks. Fix PR #32196

    The broad BVT's newly created tenant initially lacked the runner's default test database. Only that tenant's two session directives received an explicit information_schema default-database hint in a temporary fixture. System-user sessions kept their original default database, and the original SQL/golden assertions were preserved. This resolved the fixture failure.

    MOTR / BVT Coverage

    Reused grant_bare_object_test.go, tenant/privilege/bare_object_grant.sql and zz_accesscontrol/grant_privs_role.sql, supplemented by all four live privilege levels and explicit/bare cross-revocation. No duplicate MOTR commit was needed. Verification is included in the weekly description. Weekly MOTR PR #321

    Permission validation ran serially because it changes a shared global cache setting and named authorization objects. The cache was restored, users/roles/databases were removed, and owned services were stopped.

    Final Conclusion

    Fixed on the tested main build.

    Large-data regression is unnecessary. Grammar, privilege scope, actual access and connection-state behavior are directly covered by the small fixtures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions