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

session: support set current session's resource group name #41722

Merged
merged 17 commits into from
Mar 6, 2023

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Feb 24, 2023

What problem does this PR solve?

Issue Number: ref #38825

Problem Summary:

What is changed and how it works?

Add following two sql:

  • SET RESOURCE GROUP <name>; to change the resource group of the current session
  • SELECT current_resource_group(); to return the resource group of the current session
    Support set resource group name for the current session.

NOTE: currently, we don't do privilege for this statement. Will do it in the future version.

Check List

Tests

  • Unit test

Side effects

Documentation

  • Contains syntax changes

Release note

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

Support change and return the resource group name of current session.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 24, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • nolouch

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 release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 24, 2023
@glorv glorv requested review from nolouch and BornChanger February 24, 2023 09:08
Copy link
Member

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 28, 2023
@nolouch nolouch requested a review from tiancaiamao February 28, 2023 09:57
@nolouch
Copy link
Member

nolouch commented Feb 28, 2023

ptal @tiancaiamao @BornChanger

@@ -133,3 +133,17 @@ func TestUserAttributes(t *testing.T) {
rootTK.MustExec("alter user usr1 resource group rg1")
rootTK.MustQuery("select user_attributes from mysql.user where user = 'usr1'").Check(testkit.Rows(`{"metadata": {"comment": "comment1"}, "resource_group": "rg1"}`))
}

func TestSetResourceGroup(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add case to verify hint overrides session setting and session setting override use binding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Mar 2, 2023
@glorv
Copy link
Contributor Author

glorv commented Mar 2, 2023

@nolouch I have added support for SELECT CURRENT_RESOURCE_GROUP();, so PTAL again, thanks~

@glorv glorv force-pushed the session-rg-name branch from da44739 to 7ce5021 Compare March 3, 2023 02:03
@glorv
Copy link
Contributor Author

glorv commented Mar 3, 2023

/test unit-test

@glorv
Copy link
Contributor Author

glorv commented Mar 3, 2023

/test check-dev

@glorv
Copy link
Contributor Author

glorv commented Mar 3, 2023

/build

@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 Mar 3, 2023
@glorv
Copy link
Contributor Author

glorv commented Mar 3, 2023

@tiancaiamao PTAL, as this PR has introduced a new builtin function.

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 4, 2023
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 6, 2023
@glorv
Copy link
Contributor Author

glorv commented Mar 6, 2023

/test unit-test

parser/parser.y Outdated
currentTs "CURRENT_TIMESTAMP"
currentUser "CURRENT_USER"
currentRole "CURRENT_ROLE"
currentResourceGroup "CURRENT_RESOURCE_GROUP"
Copy link
Contributor

Choose a reason for hiding this comment

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

MySQL does not have CURRENT_RESOURCE_GROUP as a reserved keyword https://dev.mysql.com/doc/refman/8.0/en/keywords.html

Maybe we can make it non-keyword...
The different is that you can't create table CURRENT_RESOURCE_GROUP (...) after this change.

But the current way is still OK to me, since it follows the CURRENT_XXX as reserved keyword convention in MySQL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes, I think we can make it a non-keyword, so the compatibility should be better.

@glorv
Copy link
Contributor Author

glorv commented Mar 6, 2023

/test build

@glorv
Copy link
Contributor Author

glorv commented Mar 6, 2023

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 17c9d01

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 6, 2023
@glorv
Copy link
Contributor Author

glorv commented Mar 6, 2023

/test build

@ti-chi-bot
Copy link
Member

@glorv: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test unit-test

Use /test all to run all jobs.

In response to this:

/test build

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@glorv
Copy link
Contributor Author

glorv commented Mar 6, 2023

/test build

@glorv
Copy link
Contributor Author

glorv commented Mar 6, 2023

/test unit-test

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Mar 6, 2023
@glorv
Copy link
Contributor Author

glorv commented Mar 6, 2023

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 6960de8

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 6, 2023
@glorv
Copy link
Contributor Author

glorv commented Mar 6, 2023

/test unit-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

6 participants