Skip to content
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

*: bind user to some resource group #39561

Merged
merged 21 commits into from Dec 7, 2022

Conversation

BornChanger
Copy link
Contributor

@BornChanger BornChanger commented Dec 1, 2022

What problem does this PR solve?

Issue Number: Ref #38825

Problem Summary:
The Spec show details: https://docs.google.com/document/d/1P_D1R1qGMFjmjbGCxYjRodgp1Yeyx4dBvg2W1l_Eiy0/edit?n=1-page_Spec_template#

What is changed and how it works?

add support to bind user to resource group at create/alter user time.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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

@BornChanger BornChanger requested a review from a team as a code owner December 1, 2022 17:46
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Dec 1, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CbcWestwolf
  • tiancaiamao

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/invalid-title release-note-none needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 1, 2022
@BornChanger
Copy link
Contributor Author

/assign @nolouch @CbcWestwolf @glorv

@BornChanger
Copy link
Contributor Author

/unassign @nolouch @CbcWestwolf @glorv

@BornChanger
Copy link
Contributor Author

/cc @nolouch @CbcWestwolf @glorv

@BornChanger
Copy link
Contributor Author

/cc @tiancaiamao

Copy link
Contributor

@tiancaiamao tiancaiamao left a comment

Choose a reason for hiding this comment

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

Isn't the 'alter user RESOURCE GROUP ...' a DDL?
I don't see any of the change of ddl files in this PR.

parser/parser.y Outdated Show resolved Hide resolved

// special handling to existing users or root user initialized with insecure
if record.ResourceGroup == "" {
record.ResourceGroup = "default"
Copy link
Contributor

Choose a reason for hiding this comment

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

record is a shallow copy from the source, so change it here also change the original value.
Althrough the correctness still seem to be hold, it may data race here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just return "default", there is no need to change the record.ResourceGroup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

session/session.go Outdated Show resolved Hide resolved
parser/parser.y Outdated
@@ -12889,6 +12892,11 @@ CommentOrAttributeOption:
$$ = &ast.CommentOrAttributeOption{Type: ast.UserAttributeType, Value: $2}
}

| "RESOURCE" "GROUP" stringLit
Copy link
Member

Choose a reason for hiding this comment

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

I prefer to declare "RESOURCE" "GROUP" stringLit with a new term ResourceGroupOption, and add ResourceGroupOption into CreateUserStmt and AlterUserStmt after CommentOrAttributeOption, like

AlterUserStmt:
	"ALTER" "USER" IfExists UserSpecList RequireClauseOpt ConnectionOptions PasswordOrLockOptions CommentOrAttributeOption ResourceGroupOption

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my implementation, "resource group" is just one attribute for user, like email. which is stored in User_attributes column of mysql.user.

Copy link
Contributor

Choose a reason for hiding this comment

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

So can we just use 'alter user ... attribute ...' without provide an extra new syntax?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Resource group might be a frequently used attribute. So, we introduce new syntax for it following the pattern of comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to declare "RESOURCE" "GROUP" stringLit with a new term ResourceGroupOption, and add ResourceGroupOption into CreateUserStmt and AlterUserStmt after CommentOrAttributeOption, like

AlterUserStmt:
	"ALTER" "USER" IfExists UserSpecList RequireClauseOpt ConnectionOptions PasswordOrLockOptions CommentOrAttributeOption ResourceGroupOption

fixed

BornChanger and others added 3 commits December 6, 2022 09:47
Signed-off-by: BornChanger <dawn_catcher@126.com>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2022
@BornChanger BornChanger changed the title Bind user to some resource group DCL: Bind user to some resource group Dec 6, 2022
Copy link
Member

@CbcWestwolf CbcWestwolf left a comment

Choose a reason for hiding this comment

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

Rest LGTM

executor/simple.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 6, 2022
Co-authored-by: CbcWestwolf <1004626265@qq.com>
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 7, 2022
@tiancaiamao
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 7cef273

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 7, 2022
@BornChanger
Copy link
Contributor Author

/run-check_dev_2

@tiancaiamao tiancaiamao changed the title DCL: Bind user to some resource group *: bind user to some resource group Dec 7, 2022
@jackysp
Copy link
Member

jackysp commented Dec 7, 2022

/merge

@ti-chi-bot ti-chi-bot merged commit 8e3cbac into pingcap:master Dec 7, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Dec 7, 2022

TiDB MergeCI notify

✅ Well Done! New fixed [2] after this pr merged.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci/integration-cdc-test ✅ all 40 tests passed 21 min Fixed
idc-jenkins-ci-tidb/mybatis-test ✅ all 1 tests passed 3 min 54 sec Fixed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 17 tests passed 20 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 11 tests passed 11 min Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 6 min 23 sec Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 5 min 25 sec Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 5 min 3 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 4 min 30 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 2 min 34 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

@nolouch nolouch mentioned this pull request Dec 26, 2022
41 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants