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 compatibility of DBIsVisible #14862

Merged
merged 4 commits into from
Feb 25, 2020
Merged

Conversation

imtbkcat
Copy link

What problem does this PR solve?

User with trigger/references/execute global privileges can not see all database names and use them, but in MySQL is okay.

in TiDB:

mysql u1@127.0.0.1:(none)> show grants;
+-----------------------------------------------------+
| Grants for User                                     |
+-----------------------------------------------------+
| GRANT References,Execute,Trigger ON *.* TO 'u1'@'%' |
+-----------------------------------------------------+
1 row in set
Time: 0.014s
mysql u1@127.0.0.1:(none)> show databases;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
+--------------------+
1 row in set

in MySQL:

mysql u1@127.0.0.1:test> show grants;
+----------------------------------+
| Grants for u1@%                  |
+----------------------------------+
| GRANT TRIGGER ON *.* TO 'u1'@'%' |
+----------------------------------+
1 row in set
Time: 0.014s
mysql u1@127.0.0.1:test> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
5 rows in set
Time: 0.014s
mysql u1@127.0.0.1:test> use test;
You are now connected to database "test" as user "u1"
Time: 0.001s
mysql u1@127.0.0.1:test> show tables;
+----------------+
| Tables_in_test |
+----------------+
| Ata            |
| atA            |
+----------------+
2 rows in set
Time: 0.014s
mysql u1@127.0.0.1:test>

mysql u1@127.0.0.1:test> show grants;
+----------------------------------+
| Grants for u1@%                  |
+----------------------------------+
| GRANT EXECUTE ON *.* TO 'u1'@'%' |
+----------------------------------+
1 row in set
Time: 0.015s
mysql u1@127.0.0.1:test> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
5 rows in set

What is changed and how it works?

add TriggerPriv, EcecutePriv, ReferencePriv into globalDBVisible

Check List

Tests

  • Unit test

Code changes

  • None

Side effects

  • None

Related changes

  • Need to cherry-pick to the release branch

Release note

c.Assert(err, IsNil)
isVisible = p.DBIsVisible("testvisdb6", "%", "visdb")
c.Assert(isVisible, IsTrue)
mustExec(c, se, "TRUNCATE TABLE 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.

The added tests can pass in the master too?

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 20, 2020
@tiancaiamao
Copy link
Contributor

Ping @crazycs520

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@jackysp
Copy link
Member

jackysp commented Feb 25, 2020

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 25, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Feb 25, 2020

/run-all-tests

@sre-bot sre-bot merged commit 8431c10 into pingcap:master Feb 25, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Feb 25, 2020

cherry pick to release-3.0 in PR #14939

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. status/LGT1 Indicates that a PR has LGTM 1. type/compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants