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

privilege: fix privilege problem after upgrade #14177

Merged
merged 4 commits into from
Dec 23, 2019

Conversation

imtbkcat
Copy link

@imtbkcat imtbkcat commented Dec 23, 2019

What problem does this PR solve?

There are several privilege problem will occur after upgrade.

  • original user with all privilege will not be all after upgrade.
  • some user will add new privilege

What is changed and how it works?

for new privilege, add them reference to MySQL.
for new column which is 'N' originally, set them to 'Y' for user with all privilege.

Check List

Tests

  • Manual test (add detailed scripts or steps below)
    create user t1 (in v3.0.4)
    grant all on *.* to t1 (in v3.0.4)
    upgrade to master
    show grants for t1

Code changes

  • Has persistent data change

Side effects

  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

Release note

@imtbkcat
Copy link
Author

/run-all-tests

Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

LGTM

@imtbkcat
Copy link
Author

/run-all-tests

@imtbkcat
Copy link
Author

manual tested by this way:

use v2.1.18 version:

mysql> create user t1;
Query OK, 1 row affected (0.00 sec)

mysql> grant all on *.* to t1;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from mysql.user where user='t1'\G;
*************************** 1. row ***************************
                 Host: %
                 User: t1
             Password:
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          Delete_priv: Y
          Create_priv: Y
            Drop_priv: Y
         Process_priv: Y
           Grant_priv: Y
      References_priv: Y
           Alter_priv: Y
         Show_db_priv: Y
           Super_priv: Y
Create_tmp_table_priv: N
     Lock_tables_priv: N
         Execute_priv: Y
     Create_view_priv: N
       Show_view_priv: N
  Create_routine_priv: N
   Alter_routine_priv: N
           Index_priv: Y
     Create_user_priv: Y
           Event_priv: N
         Trigger_priv: Y
1 row in set (0.01 sec)

after upgrade to latest version:

mysql> show grants for t1;
+-----------------------------------------------------------+
| Grants for t1@%                                           |
+-----------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 't1'@'%' WITH GRANT OPTION |
+-----------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from mysql.user where user='t1'\G;
*************************** 1. row ***************************
                 Host: %
                 User: t1
             Password:
          Select_priv: Y
          Insert_priv: Y
          Update_priv: Y
          Delete_priv: Y
          Create_priv: Y
            Drop_priv: Y
         Process_priv: Y
           Grant_priv: Y
      References_priv: Y
           Alter_priv: Y
         Show_db_priv: Y
           Super_priv: Y
Create_tmp_table_priv: Y
     Lock_tables_priv: Y
         Execute_priv: Y
     Create_view_priv: Y
       Show_view_priv: Y
  Create_routine_priv: Y
   Alter_routine_priv: Y
           Index_priv: Y
     Create_user_priv: Y
           Event_priv: Y
         Trigger_priv: Y
     Create_role_priv: Y
       Drop_role_priv: Y
       Account_locked: N
        Shutdown_priv: Y
1 row in set (0.00 sec)

@tiancaiamao
Copy link
Contributor

LGTM

@imtbkcat imtbkcat added the status/can-merge Indicates a PR has been approved by a committer. label Dec 23, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 23, 2019

/run-all-tests

@sre-bot sre-bot merged commit f9cdebd into pingcap:master Dec 23, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 23, 2019

cherry pick to release-3.0 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/privilege status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants