Skip to content

*: adapt the show columns, show index and rename for column privilege #61679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: release-8.5-20250606-v8.5.2
Choose a base branch
from

Conversation

CbcWestwolf
Copy link
Member

@CbcWestwolf CbcWestwolf commented Jun 11, 2025

What problem does this PR solve?

Issue Number: ref #61706

Problem Summary:

What changed and how does it work?

Adapt the show columns, show index and rename for column privilege
This PR pick pkg/executor/show.go, pkg/executor/simple.go, pkg/parser/auth/auth.go, tests/integrationtest/t/executor/show.test and tests/integrationtest/r/executor/show.result in #61638

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 11, 2025
@CbcWestwolf CbcWestwolf mentioned this pull request Jun 11, 2025
13 tasks
@CbcWestwolf CbcWestwolf changed the title *: adapt the show columns, show index and rename for column privilege *: adapt the show columns, show index and rename for column privilege Jun 11, 2025
Copy link

codecov bot commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 81.57895% with 7 lines in your changes missing coverage. Please review.

Please upload report for BASE (release-8.5-20250606-v8.5.2@f43a133). Learn more about missing BASE report.

Additional details and impacted files
@@                       Coverage Diff                        @@
##             release-8.5-20250606-v8.5.2     #61679   +/-   ##
================================================================
  Coverage                               ?   57.0151%           
================================================================
  Files                                  ?       1770           
  Lines                                  ?     629075           
  Branches                               ?          0           
================================================================
  Hits                                   ?     358668           
  Misses                                 ?     246281           
  Partials                               ?      24126           
Flag Coverage Δ
integration 36.8581% <65.7894%> (?)
unit 72.6709% <71.0526%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9278% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 52.3308% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CbcWestwolf
Copy link
Member Author

/retest

1 similar comment
@CbcWestwolf
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot added the sig/planner SIG: Planner label Jun 12, 2025
@CbcWestwolf CbcWestwolf changed the title *: adapt the show columns, show index and rename for column privilege *: adapt the show columns, show index, show bindings and rename for column privilege Jun 12, 2025
@CbcWestwolf CbcWestwolf force-pushed the column-priv-852-show branch from de1990f to 7e9852a Compare June 12, 2025 02:18
Copy link

ti-chi-bot bot commented Jun 12, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bornchanger for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@CbcWestwolf CbcWestwolf changed the title *: adapt the show columns, show index, show bindings and rename for column privilege *: adapt the show columns, show index and rename for column privilege Jun 12, 2025
@CbcWestwolf CbcWestwolf requested a review from Copilot June 13, 2025 03:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adapts the behavior of the "show columns", "show index", and "rename" functionalities to properly enforce column-specific privileges. It updates integration tests, error expectations, privilege checking logic in executor code, and refactors user/host retrieval in the authentication module.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/integrationtest/t/executor/show.test Adds integration tests for column and index privilege enforcement.
tests/integrationtest/r/executor/show.result Updates expected outputs for the new privilege behaviors.
pkg/parser/auth/auth.go Introduces GetUserAndHostName for consistent user/host extraction.
pkg/executor/simple.go Renames user privileges in the mysql.columns_priv table.
pkg/executor/show.go Implements column-level privilege checks for SHOW queries.

create table test_show_columns_db.t (a int, b int);

--echo // no grant would report error
connect (test_show_columns_user, localhost, test_show_columns_user,,);
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The connection command contains a double comma which may indicate an empty parameter (such as an empty password). Consider adding a clarifying comment if this is intentional to improve readability.

Suggested change
connect (test_show_columns_user, localhost, test_show_columns_user,,);
connect (test_show_columns_user, localhost, test_show_columns_user,,); -- The double comma indicates an empty password for the connection.

Copilot uses AI. Check for mistakes.

@@ -717,6 +723,13 @@ func (e *ShowExec) fetchShowColumns(ctx context.Context) error {
} else if fieldPatternsLike != nil && !fieldPatternsLike.DoMatch(col.Name.L) {
continue
}
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Clarify via an inline comment that when table-level privileges are not granted, the code proceeds to check each column for specific privileges, with passColPrivCheck set when at least one column passes. This will help future maintainers understand the dual privilege check logic.

Suggested change
}
}
// If table-level privileges are not granted, proceed to check column-level privileges.
// Set passColPrivCheck to true if at least one column passes the privilege check.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant