Skip to content

fix: expose table grants in information_schema.TABLE_PRIVILEGES - #27697

Draft
ck89119 wants to merge 4 commits into
matrixorigin:mainfrom
ck89119:issue-27657-main
Draft

fix: expose table grants in information_schema.TABLE_PRIVILEGES#27697
ck89119 wants to merge 4 commits into
matrixorigin:mainfrom
ck89119:issue-27657-main

Conversation

@ck89119

@ck89119 ck89119 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

fixes #27657

What this PR does / why we need it:

information_schema.TABLE_PRIVILEGES was an empty base table even though table- and view-level grants are persisted in mo_catalog.mo_role_privs. This left JDBC/ORM authorization introspection with no object privilege rows.

This PR:

  • replaces the empty table with a tenant-scoped catalog-backed view for direct table- and view-level role grants;
  • maps concrete privileges to external names, including REFERENCE to REFERENCES;
  • expands internal TABLE ALL and TABLE OWNERSHIP rows into concrete privileges without exposing internal aggregate names;
  • deduplicates explicit and aggregate privilege sources and OR-aggregates grantability (ownership remains grantable according to existing authorization semantics);
  • preserves the six MySQL-compatible columns and widths;
  • excludes broader db.* and *.* grants from direct object rows;
  • adds a convergent v4.0.6 tenant upgrade from absent, historical base-table, stale-view, and target-view states;
  • adds unit coverage, access-control BVT coverage, and metadata result updates for the table-to-view transition.

Validation:

  • pkg/util/sysview and pkg/bootstrap/versions/v4_0_6 owning-package tests passed; v4.0.6 package coverage: 85.4%.
  • go vet ./pkg/util/sysview ./pkg/bootstrap/versions/v4_0_6 passed.
  • Exact-head make build passed after merging the latest main.
  • The expanded BVT passed twice on the same instance with result metadata comparison enabled (26/26 each). It covers ALL, ownership, duplicate/grantability aggregation, REFERENCE/REFERENCES, and VIEW grant/revoke.
  • Unfiltered aggregate queries over the view passed and returned no internal TABLE ALL, TABLE OWNERSHIP, or REFERENCE names.
  • Existing affected BVTs passed: mo_cloud.sql (170/170), information_schema.sql (8/8), and system_table.sql (40 passed, 1 existing ignore, 0 failed).
  • Persisted upgrade validation passed from pre-fix binary ae12701a88 (v4.0.6 offset 23): both the system tenant and an existing regular tenant converged from base tables to the canonical view at offset 24, the migrated tenant returned its direct SELECT grant, and a same-offset restart executed no TABLE_PRIVILEGES migration DDL.

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

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: information_schema.TABLE_PRIVILEGES stays empty after a supported table-level GRANT

2 participants