Skip to content

fix(frontend): keep DDL ownership on matched role#24969

Open
ouyuanning wants to merge 7 commits into
matrixorigin:mainfrom
ouyuanning:fix-ownership-bug-main
Open

fix(frontend): keep DDL ownership on matched role#24969
ouyuanning wants to merge 7 commits into
matrixorigin:mainfrom
ouyuanning:fix-ownership-bug-main

Conversation

@ouyuanning

@ouyuanning ouyuanning commented Jun 12, 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:

issue #24956

What this PR does / why we need it:

This PR fixes DDL ownership when privileges are satisfied by secondary or inherited roles.

  • Track the role that actually satisfies CREATE DATABASE / CREATE TABLE privilege checks and use it as the DDL owner.
  • Map inherited privilege matches back to the active role that introduced the inheritance chain, so ownership is granted to the active primary or secondary role instead of the inherited leaf role.
  • Re-authenticate prepared DDL during EXECUTE so prepared CREATE DATABASE / CREATE TABLE also gets the correct owner role.
  • Revoke implicit ownership from the actual object owner role before DROP DATABASE / DROP TABLE, including multi-table DROP.
  • Propagate implicit ownership revoke errors instead of swallowing them.
  • Add frontend tests and BVT coverage for secondary-role DDL ownership and prepared DDL ownership cleanup.

Validation:

  • rtk git diff --check
  • rtk go test -mod=mod ./pkg/defines -count=1
  • rtk go test -mod=mod ./pkg/frontend -run TestCreateDatabaseOwnerRoleFollowsActiveInheritedRoleRoot|TestCreateTableOwnerRoleFollowsPrivilegeRole|Test_determineUserHasPrivilegeSet -count=1 could not complete locally because the frontend package fails to build with missing C header xxhash.h.
  • Without -mod=mod, local Go reports inconsistent vendoring between go.mod and vendor/modules.txt.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

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 kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants